Class ServerHttpSecurity.HeaderSpec
java.lang.Object
org.springframework.security.config.web.server.ServerHttpSecurity.HeaderSpec
- Enclosing class:
 - ServerHttpSecurity
 
Configures HTTP Response Headers.
- Since:
 - 5.0
 - See Also:
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classConfigures cache control headersfinal classConfiguresContent-Security-Policyresponse header.final classThe content type headersfinal classConfigures the Cross-Origin-Embedder-Policy headerfinal classConfigures the Cross-Origin-Opener-Policy headerfinal classConfigures the Cross-Origin-Resource-Policy headerfinal classConfiguresFeature-Policyresponse header.final classConfigures frame options response headerfinal classConfigures Strict Transport Security response headerfinal classConfiguresPermissions-Policyresponse header.final classConfiguresReferrer-Policyresponse header.final classConfigures x-xss-protection response header - 
Method Summary
Modifier and TypeMethodDescriptionand()Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0.cache()Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0.cache(Customizer<ServerHttpSecurity.HeaderSpec.CacheSpec> cacheCustomizer) Configures cache control headersprotected voidconfigure(ServerHttpSecurity http) contentSecurityPolicy(String policyDirectives) Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0.contentSecurityPolicy(Customizer<ServerHttpSecurity.HeaderSpec.ContentSecurityPolicySpec> contentSecurityPolicyCustomizer) ConfiguresContent-Security-Policyresponse header.Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0.contentTypeOptions(Customizer<ServerHttpSecurity.HeaderSpec.ContentTypeOptionsSpec> contentTypeOptionsCustomizer) Configures content type response headersDeprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0.crossOriginEmbedderPolicy(Customizer<ServerHttpSecurity.HeaderSpec.CrossOriginEmbedderPolicySpec> crossOriginEmbedderPolicyCustomizer) Configures the Cross-Origin-Embedder-Policy header.Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0.crossOriginOpenerPolicy(Customizer<ServerHttpSecurity.HeaderSpec.CrossOriginOpenerPolicySpec> crossOriginOpenerPolicyCustomizer) Configures the Cross-Origin-Opener-Policy header.Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0.crossOriginResourcePolicy(Customizer<ServerHttpSecurity.HeaderSpec.CrossOriginResourcePolicySpec> crossOriginResourcePolicyCustomizer) Configures the Cross-Origin-Resource-Policy header.disable()Disables http response headersfeaturePolicy(String policyDirectives) Deprecated.For removal in 7.0.Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0.frameOptions(Customizer<ServerHttpSecurity.HeaderSpec.FrameOptionsSpec> frameOptionsCustomizer) Configures frame options response headershsts()Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0.hsts(Customizer<ServerHttpSecurity.HeaderSpec.HstsSpec> hstsCustomizer) Configures the Strict Transport Security response headersDeprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0.permissionsPolicy(Customizer<ServerHttpSecurity.HeaderSpec.PermissionsPolicySpec> permissionsPolicyCustomizer) ConfiguresPermissions-Policyresponse header.Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0.referrerPolicy(Customizer<ServerHttpSecurity.HeaderSpec.ReferrerPolicySpec> referrerPolicyCustomizer) ConfiguresReferrer-Policyresponse header.referrerPolicy(ReferrerPolicyServerHttpHeadersWriter.ReferrerPolicy referrerPolicy) Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0.writer(ServerHttpHeadersWriter serverHttpHeadersWriter) Configures custom headers writerDeprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0.xssProtection(Customizer<ServerHttpSecurity.HeaderSpec.XssProtectionSpec> xssProtectionCustomizer) Configures x-xss-protection response header. 
- 
Method Details
- 
and
Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0. UseServerHttpSecurity.headers(Customizer)orheaders(Customizer.withDefaults())to stick with defaults. See the documentation for more details.Allows method chaining to continue configuring theServerHttpSecurity- Returns:
 - the 
ServerHttpSecurityto continue configuring 
 - 
disable
Disables http response headers- Returns:
 - the 
ServerHttpSecurityto continue configuring 
 - 
cache
Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0. Usecache(Customizer)orcache(Customizer.withDefaults())to stick with defaults. See the documentation for more details.Configures cache control headers- Returns:
 - the 
ServerHttpSecurity.HeaderSpec.CacheSpecto configure 
 - 
cache
public ServerHttpSecurity.HeaderSpec cache(Customizer<ServerHttpSecurity.HeaderSpec.CacheSpec> cacheCustomizer) Configures cache control headers- Parameters:
 cacheCustomizer- theCustomizerto provide more options for theServerHttpSecurity.HeaderSpec.CacheSpec- Returns:
 - the 
ServerHttpSecurity.HeaderSpecto customize 
 - 
contentTypeOptions
@Deprecated(since="6.1", forRemoval=true) public ServerHttpSecurity.HeaderSpec.ContentTypeOptionsSpec contentTypeOptions()Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0. UsecontentTypeOptions(Customizer)insteadConfigures content type response headers- Returns:
 - the 
ServerHttpSecurity.HeaderSpec.ContentTypeOptionsSpecto configure 
 - 
contentTypeOptions
public ServerHttpSecurity.HeaderSpec contentTypeOptions(Customizer<ServerHttpSecurity.HeaderSpec.ContentTypeOptionsSpec> contentTypeOptionsCustomizer) Configures content type response headers- Parameters:
 contentTypeOptionsCustomizer- theCustomizerto provide more options for theServerHttpSecurity.HeaderSpec.ContentTypeOptionsSpec- Returns:
 - the 
ServerHttpSecurity.HeaderSpecto customize 
 - 
frameOptions
@Deprecated(since="6.1", forRemoval=true) public ServerHttpSecurity.HeaderSpec.FrameOptionsSpec frameOptions()Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0. UseframeOptions(Customizer)orframeOptions(Customizer.withDefaults())to stick with defaults. See the documentation for more details.Configures frame options response headers- Returns:
 - the 
ServerHttpSecurity.HeaderSpec.FrameOptionsSpecto configure 
 - 
frameOptions
public ServerHttpSecurity.HeaderSpec frameOptions(Customizer<ServerHttpSecurity.HeaderSpec.FrameOptionsSpec> frameOptionsCustomizer) Configures frame options response headers- Parameters:
 frameOptionsCustomizer- theCustomizerto provide more options for theServerHttpSecurity.HeaderSpec.FrameOptionsSpec- Returns:
 - the 
ServerHttpSecurity.HeaderSpecto customize 
 - 
writer
Configures custom headers writer- Parameters:
 serverHttpHeadersWriter- theServerHttpHeadersWriterto provide custom headers writer- Returns:
 - the 
ServerHttpSecurity.HeaderSpecto customize - Since:
 - 5.3.0
 
 - 
hsts
Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0. Usehsts(Customizer)orhsts(Customizer.withDefaults())to stick with defaults. See the documentation for more details.Configures the Strict Transport Security response headers- Returns:
 - the 
ServerHttpSecurity.HeaderSpec.HstsSpecto configure 
 - 
hsts
public ServerHttpSecurity.HeaderSpec hsts(Customizer<ServerHttpSecurity.HeaderSpec.HstsSpec> hstsCustomizer) Configures the Strict Transport Security response headers- Parameters:
 hstsCustomizer- theCustomizerto provide more options for theServerHttpSecurity.HeaderSpec.HstsSpec- Returns:
 - the 
ServerHttpSecurity.HeaderSpecto customize 
 - 
configure
 - 
xssProtection
@Deprecated(since="6.1", forRemoval=true) public ServerHttpSecurity.HeaderSpec.XssProtectionSpec xssProtection()Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0. UsexssProtection(Customizer)orxssProtection(Customizer.withDefaults())to stick with defaults. See the documentation for more details.Configures x-xss-protection response header.- Returns:
 - the 
ServerHttpSecurity.HeaderSpec.XssProtectionSpecto configure 
 - 
xssProtection
public ServerHttpSecurity.HeaderSpec xssProtection(Customizer<ServerHttpSecurity.HeaderSpec.XssProtectionSpec> xssProtectionCustomizer) Configures x-xss-protection response header.- Parameters:
 xssProtectionCustomizer- theCustomizerto provide more options for theServerHttpSecurity.HeaderSpec.XssProtectionSpec- Returns:
 - the 
ServerHttpSecurity.HeaderSpecto customize 
 - 
contentSecurityPolicy
@Deprecated(since="6.1", forRemoval=true) public ServerHttpSecurity.HeaderSpec.ContentSecurityPolicySpec contentSecurityPolicy(String policyDirectives) Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0. UsecontentSecurityPolicy(Customizer)instead.ConfiguresContent-Security-Policyresponse header.- Parameters:
 policyDirectives- the policy directive(s)- Returns:
 - the 
ServerHttpSecurity.HeaderSpec.ContentSecurityPolicySpecto configure 
 - 
contentSecurityPolicy
public ServerHttpSecurity.HeaderSpec contentSecurityPolicy(Customizer<ServerHttpSecurity.HeaderSpec.ContentSecurityPolicySpec> contentSecurityPolicyCustomizer) ConfiguresContent-Security-Policyresponse header.- Parameters:
 contentSecurityPolicyCustomizer- theCustomizerto provide more options for theServerHttpSecurity.HeaderSpec.ContentSecurityPolicySpec- Returns:
 - the 
ServerHttpSecurity.HeaderSpecto customize 
 - 
featurePolicy
@Deprecated public ServerHttpSecurity.HeaderSpec.FeaturePolicySpec featurePolicy(String policyDirectives) Deprecated.For removal in 7.0. UsepermissionsPolicy(Customizer)instead.ConfiguresFeature-Policyresponse header.- Parameters:
 policyDirectives- the policy- Returns:
 - the 
ServerHttpSecurity.HeaderSpec.FeaturePolicySpecto configure 
 - 
permissionsPolicy
@Deprecated(since="6.1", forRemoval=true) public ServerHttpSecurity.HeaderSpec.PermissionsPolicySpec permissionsPolicy()Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0. UsepermissionsPolicy(Customizer)instead.ConfiguresPermissions-Policyresponse header.- Returns:
 - the 
ServerHttpSecurity.HeaderSpec.PermissionsPolicySpecto configure 
 - 
permissionsPolicy
public ServerHttpSecurity.HeaderSpec permissionsPolicy(Customizer<ServerHttpSecurity.HeaderSpec.PermissionsPolicySpec> permissionsPolicyCustomizer) ConfiguresPermissions-Policyresponse header.- Parameters:
 permissionsPolicyCustomizer- theCustomizerto provide more options for theServerHttpSecurity.HeaderSpec.PermissionsPolicySpec- Returns:
 - the 
ServerHttpSecurity.HeaderSpecto customize 
 - 
referrerPolicy
@Deprecated(since="6.1", forRemoval=true) public ServerHttpSecurity.HeaderSpec.ReferrerPolicySpec referrerPolicy(ReferrerPolicyServerHttpHeadersWriter.ReferrerPolicy referrerPolicy) Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0. UsereferrerPolicy(Customizer)instead.ConfiguresReferrer-Policyresponse header.- Parameters:
 referrerPolicy- the policy to use- Returns:
 - the 
ServerHttpSecurity.HeaderSpec.ReferrerPolicySpecto configure 
 - 
referrerPolicy
@Deprecated(since="6.1", forRemoval=true) public ServerHttpSecurity.HeaderSpec.ReferrerPolicySpec referrerPolicy()Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0. UsereferrerPolicy(Customizer)instead.ConfiguresReferrer-Policyresponse header.- Returns:
 - the 
ServerHttpSecurity.HeaderSpec.ReferrerPolicySpecto configure 
 - 
referrerPolicy
public ServerHttpSecurity.HeaderSpec referrerPolicy(Customizer<ServerHttpSecurity.HeaderSpec.ReferrerPolicySpec> referrerPolicyCustomizer) ConfiguresReferrer-Policyresponse header.- Parameters:
 referrerPolicyCustomizer- theCustomizerto provide more options for theServerHttpSecurity.HeaderSpec.ReferrerPolicySpec- Returns:
 - the 
ServerHttpSecurity.HeaderSpecto customize 
 - 
crossOriginOpenerPolicy
@Deprecated(since="6.1", forRemoval=true) public ServerHttpSecurity.HeaderSpec.CrossOriginOpenerPolicySpec crossOriginOpenerPolicy()Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0. UsecrossOriginOpenerPolicy(Customizer)instead.Configures the Cross-Origin-Opener-Policy header.- Returns:
 - the 
ServerHttpSecurity.HeaderSpec.CrossOriginOpenerPolicySpecto configure - Since:
 - 5.7
 - See Also:
 
 - 
crossOriginOpenerPolicy
public ServerHttpSecurity.HeaderSpec crossOriginOpenerPolicy(Customizer<ServerHttpSecurity.HeaderSpec.CrossOriginOpenerPolicySpec> crossOriginOpenerPolicyCustomizer) Configures the Cross-Origin-Opener-Policy header.- Returns:
 - the 
ServerHttpSecurity.HeaderSpecto customize - Since:
 - 5.7
 - See Also:
 
 - 
crossOriginEmbedderPolicy
@Deprecated(since="6.1", forRemoval=true) public ServerHttpSecurity.HeaderSpec.CrossOriginEmbedderPolicySpec crossOriginEmbedderPolicy()Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0. UsecrossOriginEmbedderPolicy(Customizer)instead.Configures the Cross-Origin-Embedder-Policy header.- Returns:
 - the 
ServerHttpSecurity.HeaderSpec.CrossOriginEmbedderPolicySpecto configure - Since:
 - 5.7
 - See Also:
 
 - 
crossOriginEmbedderPolicy
public ServerHttpSecurity.HeaderSpec crossOriginEmbedderPolicy(Customizer<ServerHttpSecurity.HeaderSpec.CrossOriginEmbedderPolicySpec> crossOriginEmbedderPolicyCustomizer) Configures the Cross-Origin-Embedder-Policy header.- Returns:
 - the 
ServerHttpSecurity.HeaderSpecto customize - Since:
 - 5.7
 - See Also:
 
 - 
crossOriginResourcePolicy
@Deprecated(since="6.1", forRemoval=true) public ServerHttpSecurity.HeaderSpec.CrossOriginResourcePolicySpec crossOriginResourcePolicy()Deprecated, for removal: This API element is subject to removal in a future version.For removal in 7.0. UsecrossOriginResourcePolicy(Customizer)instead.Configures the Cross-Origin-Resource-Policy header.- Returns:
 - the 
ServerHttpSecurity.HeaderSpec.CrossOriginResourcePolicySpecto configure - Since:
 - 5.7
 - See Also:
 
 - 
crossOriginResourcePolicy
public ServerHttpSecurity.HeaderSpec crossOriginResourcePolicy(Customizer<ServerHttpSecurity.HeaderSpec.CrossOriginResourcePolicySpec> crossOriginResourcePolicyCustomizer) Configures the Cross-Origin-Resource-Policy header.- Returns:
 - the 
ServerHttpSecurity.HeaderSpecto customize - Since:
 - 5.7
 - See Also:
 
 
 -