Interface ResponseHeadersContentSecurityPolicy
- All Superinterfaces:
software.amazon.jsii.JsiiSerializable
- All Known Implementing Classes:
ResponseHeadersContentSecurityPolicy.Jsii$Proxy
@Generated(value="jsii-pacmak/1.104.0 (build e79254c)",
date="2024-11-27T16:50:54.342Z")
@Stability(Stable)
public interface ResponseHeadersContentSecurityPolicy
extends software.amazon.jsii.JsiiSerializable
The policy directives and their values that CloudFront includes as values for the Content-Security-Policy HTTP response header.
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(false).reportUri("https://example.com/csp-report").override(true).build()) .build()) .removeHeaders(List.of("Server")) .serverTimingSamplingRate(50) .build(); Distribution.Builder.create(this, "myDistCustomPolicy") .defaultBehavior(BehaviorOptions.builder() .origin(bucketOrigin) .responseHeadersPolicy(myResponseHeadersPolicy) .build()) .build();
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final class
A builder forResponseHeadersContentSecurityPolicy
static final class
An implementation forResponseHeadersContentSecurityPolicy
-
Method Summary
Modifier and TypeMethodDescriptionbuilder()
The policy directives and their values that CloudFront includes as values for the Content-Security-Policy HTTP response header.A Boolean that determines whether CloudFront overrides the Content-Security-Policy HTTP response header received from the origin with the one specified in this response headers policy.Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Method Details
-
getContentSecurityPolicy
The policy directives and their values that CloudFront includes as values for the Content-Security-Policy HTTP response header. -
getOverride
A Boolean that determines whether CloudFront overrides the Content-Security-Policy HTTP response header received from the origin with the one specified in this response headers policy. -
builder
-