Class ResponseHeadersStrictTransportSecurity
Determines whether CloudFront includes the Strict-Transport-Security HTTP response header and the header’s value.
Inheritance
Implements
Namespace: Amazon.CDK.AWS.CloudFront
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class ResponseHeadersStrictTransportSecurity : Object, IResponseHeadersStrictTransportSecurity
Syntax (vb)
Public Class ResponseHeadersStrictTransportSecurity
Inherits Object
Implements IResponseHeadersStrictTransportSecurity
Remarks
ExampleMetadata: infused
Examples
// Using an existing managed response headers policy
S3Origin bucketOrigin;
new Distribution(this, "myDistManagedPolicy", new DistributionProps {
DefaultBehavior = new BehaviorOptions {
Origin = bucketOrigin,
ResponseHeadersPolicy = ResponseHeadersPolicy.CORS_ALLOW_ALL_ORIGINS
}
});
// Creating a custom response headers policy -- all parameters optional
var myResponseHeadersPolicy = new ResponseHeadersPolicy(this, "ResponseHeadersPolicy", new ResponseHeadersPolicyProps {
ResponseHeadersPolicyName = "MyPolicy",
Comment = "A default policy",
CorsBehavior = new ResponseHeadersCorsBehavior {
AccessControlAllowCredentials = false,
AccessControlAllowHeaders = new [] { "X-Custom-Header-1", "X-Custom-Header-2" },
AccessControlAllowMethods = new [] { "GET", "POST" },
AccessControlAllowOrigins = new [] { "*" },
AccessControlExposeHeaders = new [] { "X-Custom-Header-1", "X-Custom-Header-2" },
AccessControlMaxAge = Duration.Seconds(600),
OriginOverride = true
},
CustomHeadersBehavior = new ResponseCustomHeadersBehavior {
CustomHeaders = new [] { new ResponseCustomHeader { Header = "X-Amz-Date", Value = "some-value", Override = true }, new ResponseCustomHeader { Header = "X-Amz-Security-Token", Value = "some-value", Override = false } }
},
SecurityHeadersBehavior = new ResponseSecurityHeadersBehavior {
ContentSecurityPolicy = new ResponseHeadersContentSecurityPolicy { ContentSecurityPolicy = "default-src https:;", Override = true },
ContentTypeOptions = new ResponseHeadersContentTypeOptions { Override = true },
FrameOptions = new ResponseHeadersFrameOptions { FrameOption = HeadersFrameOption.DENY, Override = true },
ReferrerPolicy = new ResponseHeadersReferrerPolicy { ReferrerPolicy = HeadersReferrerPolicy.NO_REFERRER, Override = true },
StrictTransportSecurity = new ResponseHeadersStrictTransportSecurity { AccessControlMaxAge = Duration.Seconds(600), IncludeSubdomains = true, Override = true },
XssProtection = new ResponseHeadersXSSProtection { Protection = true, ModeBlock = false, ReportUri = "https://example.com/csp-report", Override = true }
},
RemoveHeaders = new [] { "Server" },
ServerTimingSamplingRate = 50
});
new Distribution(this, "myDistCustomPolicy", new DistributionProps {
DefaultBehavior = new BehaviorOptions {
Origin = bucketOrigin,
ResponseHeadersPolicy = myResponseHeadersPolicy
}
});
Synopsis
Constructors
ResponseHeadersStrictTransportSecurity() |
Properties
AccessControlMaxAge | A number that CloudFront uses as the value for the max-age directive in the Strict-Transport-Security HTTP response header. |
IncludeSubdomains | A Boolean that determines whether CloudFront includes the includeSubDomains directive in the Strict-Transport-Security HTTP response header. |
Override | A Boolean that determines whether CloudFront overrides the Strict-Transport-Security HTTP response header received from the origin with the one specified in this response headers policy. |
Preload | A Boolean that determines whether CloudFront includes the preload directive in the Strict-Transport-Security HTTP response header. |
Constructors
ResponseHeadersStrictTransportSecurity()
public ResponseHeadersStrictTransportSecurity()
Properties
AccessControlMaxAge
A number that CloudFront uses as the value for the max-age directive in the Strict-Transport-Security HTTP response header.
public Duration AccessControlMaxAge { get; set; }
Property Value
IncludeSubdomains
A Boolean that determines whether CloudFront includes the includeSubDomains directive in the Strict-Transport-Security HTTP response header.
public Nullable<bool> IncludeSubdomains { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: false
Override
A Boolean that determines whether CloudFront overrides the Strict-Transport-Security HTTP response header received from the origin with the one specified in this response headers policy.
public bool Override { get; set; }
Property Value
System.Boolean
Preload
A Boolean that determines whether CloudFront includes the preload directive in the Strict-Transport-Security HTTP response header.
public Nullable<bool> Preload { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: false