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 headers.final classConfiguresContent-Security-Policyresponse header.final classThe content type headers.final classConfigures the Cross-Origin-Embedder-Policy header.final classConfigures the Cross-Origin-Opener-Policy header.final classConfigures the Cross-Origin-Resource-Policy header.final classConfiguresFeature-Policyresponse header.final classConfigures frame options response header.final classConfigures Strict Transport Security response header.final classConfiguresPermissions-Policyresponse header.final classConfiguresReferrer-Policyresponse header.final classConfigures x-xss-protection response header. -
Method Summary
Modifier and TypeMethodDescriptioncache(Customizer<ServerHttpSecurity.HeaderSpec.CacheSpec> cacheCustomizer) Configures cache control headers.contentSecurityPolicy(Customizer<ServerHttpSecurity.HeaderSpec.ContentSecurityPolicySpec> contentSecurityPolicyCustomizer) ConfiguresContent-Security-Policyresponse header.contentTypeOptions(Customizer<ServerHttpSecurity.HeaderSpec.ContentTypeOptionsSpec> contentTypeOptionsCustomizer) Configures content type response headers.crossOriginEmbedderPolicy(Customizer<ServerHttpSecurity.HeaderSpec.CrossOriginEmbedderPolicySpec> crossOriginEmbedderPolicyCustomizer) Configures the Cross-Origin-Embedder-Policy header.crossOriginOpenerPolicy(Customizer<ServerHttpSecurity.HeaderSpec.CrossOriginOpenerPolicySpec> crossOriginOpenerPolicyCustomizer) Configures the Cross-Origin-Opener-Policy header.crossOriginResourcePolicy(Customizer<ServerHttpSecurity.HeaderSpec.CrossOriginResourcePolicySpec> crossOriginResourcePolicyCustomizer) Configures the Cross-Origin-Resource-Policy header.disable()Disables http response headers.featurePolicy(String policyDirectives) Deprecated.For removal in 7.0.frameOptions(Customizer<ServerHttpSecurity.HeaderSpec.FrameOptionsSpec> frameOptionsCustomizer) Configures frame options response headers.hsts(Customizer<ServerHttpSecurity.HeaderSpec.HstsSpec> hstsCustomizer) Configures the Strict Transport Security response headers.permissionsPolicy(Customizer<ServerHttpSecurity.HeaderSpec.PermissionsPolicySpec> permissionsPolicyCustomizer) ConfiguresPermissions-Policyresponse header.referrerPolicy(Customizer<ServerHttpSecurity.HeaderSpec.ReferrerPolicySpec> referrerPolicyCustomizer) ConfiguresReferrer-Policyresponse header.writer(ServerHttpHeadersWriter serverHttpHeadersWriter) Configures custom headers writer.xssProtection(Customizer<ServerHttpSecurity.HeaderSpec.XssProtectionSpec> xssProtectionCustomizer) Configures x-xss-protection response header.
-
Method Details
-
disable
Disables http response headers.- Returns:
- the
ServerHttpSecurityto continue configuring
-
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
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
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
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
-
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
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
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
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
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
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
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:
-