@Generated(value="jsii-pacmak/1.50.0 (build d1830a4)", date="2022-01-11T17:58:48.873Z") @Stability(value=Stable) public interface ResponseSecurityHeadersBehavior extends software.amazon.jsii.JsiiSerializable
CloudFront adds these headers to HTTP responses that it sends for requests that match a cache behavior associated with this response headers policy.
Example:
// Using an existing managed response headers policy
S3Origin bucketOrigin;
Distribution.Builder.create(this, "myDistManagedPolicy")
.defaultBehavior(BehaviorOptions.builder()
.origin(bucketOrigin)
.responseHeadersPolicy(ResponseHeadersPolicy.CORS_ALLOW_ALL_ORIGINS)
.build())
.build();
// Creating a custom response headers policy -- all parameters optional
ResponseHeadersPolicy myResponseHeadersPolicy = ResponseHeadersPolicy.Builder.create(this, "ResponseHeadersPolicy")
.responseHeadersPolicyName("MyPolicy")
.comment("A default policy")
.corsBehavior(ResponseHeadersCorsBehavior.builder()
.accessControlAllowCredentials(false)
.accessControlAllowHeaders(List.of("X-Custom-Header-1", "X-Custom-Header-2"))
.accessControlAllowMethods(List.of("GET", "POST"))
.accessControlAllowOrigins(List.of("*"))
.accessControlExposeHeaders(List.of("X-Custom-Header-1", "X-Custom-Header-2"))
.accessControlMaxAge(Duration.seconds(600))
.originOverride(true)
.build())
.customHeadersBehavior(ResponseCustomHeadersBehavior.builder()
.customHeaders(List.of(ResponseCustomHeader.builder().header("X-Amz-Date").value("some-value").override(true).build(), ResponseCustomHeader.builder().header("X-Amz-Security-Token").value("some-value").override(false).build()))
.build())
.securityHeadersBehavior(ResponseSecurityHeadersBehavior.builder()
.contentSecurityPolicy(ResponseHeadersContentSecurityPolicy.builder().contentSecurityPolicy("default-src https:;").override(true).build())
.contentTypeOptions(ResponseHeadersContentTypeOptions.builder().override(true).build())
.frameOptions(ResponseHeadersFrameOptions.builder().frameOption(HeadersFrameOption.DENY).override(true).build())
.referrerPolicy(ResponseHeadersReferrerPolicy.builder().referrerPolicy(HeadersReferrerPolicy.NO_REFERRER).override(true).build())
.strictTransportSecurity(ResponseHeadersStrictTransportSecurity.builder().accessControlMaxAge(Duration.seconds(600)).includeSubdomains(true).override(true).build())
.xssProtection(ResponseHeadersXSSProtection.builder().protection(true).modeBlock(true).reportUri("https://example.com/csp-report").override(true).build())
.build())
.build();
Distribution.Builder.create(this, "myDistCustomPolicy")
.defaultBehavior(BehaviorOptions.builder()
.origin(bucketOrigin)
.responseHeadersPolicy(myResponseHeadersPolicy)
.build())
.build();
| Modifier and Type | Interface and Description |
|---|---|
static class |
ResponseSecurityHeadersBehavior.Builder
A builder for
ResponseSecurityHeadersBehavior |
static class |
ResponseSecurityHeadersBehavior.Jsii$Proxy
An implementation for
ResponseSecurityHeadersBehavior |
| Modifier and Type | Method and Description |
|---|---|
static ResponseSecurityHeadersBehavior.Builder |
builder() |
default ResponseHeadersContentSecurityPolicy |
getContentSecurityPolicy()
The policy directives and their values that CloudFront includes as values for the Content-Security-Policy HTTP response header.
|
default ResponseHeadersContentTypeOptions |
getContentTypeOptions()
Determines whether CloudFront includes the X-Content-Type-Options HTTP response header with its value set to nosniff.
|
default ResponseHeadersFrameOptions |
getFrameOptions()
Determines whether CloudFront includes the X-Frame-Options HTTP response header and the header’s value.
|
default ResponseHeadersReferrerPolicy |
getReferrerPolicy()
Determines whether CloudFront includes the Referrer-Policy HTTP response header and the header’s value.
|
default ResponseHeadersStrictTransportSecurity |
getStrictTransportSecurity()
Determines whether CloudFront includes the Strict-Transport-Security HTTP response header and the header’s value.
|
default ResponseHeadersXSSProtection |
getXssProtection()
Determines whether CloudFront includes the X-XSS-Protection HTTP response header and the header’s value.
|
@Stability(value=Stable) @Nullable default ResponseHeadersContentSecurityPolicy getContentSecurityPolicy()
Default: - no content security policy
@Stability(value=Stable) @Nullable default ResponseHeadersContentTypeOptions getContentTypeOptions()
Default: - no content type options
@Stability(value=Stable) @Nullable default ResponseHeadersFrameOptions getFrameOptions()
Default: - no frame options
@Stability(value=Stable) @Nullable default ResponseHeadersReferrerPolicy getReferrerPolicy()
Default: - no referrer policy
@Stability(value=Stable) @Nullable default ResponseHeadersStrictTransportSecurity getStrictTransportSecurity()
Default: - no strict transport security
@Stability(value=Stable) @Nullable default ResponseHeadersXSSProtection getXssProtection()
Default: - no xss protection
@Stability(value=Stable) static ResponseSecurityHeadersBehavior.Builder builder()
Copyright © 2022. All rights reserved.