UNPKG

13.6 kBTypeScriptView Raw
1import { Duration, Resource } from '@aws-cdk/core';
2import { Construct } from 'constructs';
3/**
4 * Represents a response headers policy.
5 */
6export interface IResponseHeadersPolicy {
7 /**
8 * The ID of the response headers policy
9 * @attribute
10 **/
11 readonly responseHeadersPolicyId: string;
12}
13/**
14 * Properties for creating a Response Headers Policy
15 */
16export interface ResponseHeadersPolicyProps {
17 /**
18 * A unique name to identify the response headers policy.
19 *
20 * @default - generated from the `id`
21 */
22 readonly responseHeadersPolicyName?: string;
23 /**
24 * A comment to describe the response headers policy.
25 *
26 * @default - no comment
27 */
28 readonly comment?: string;
29 /**
30 * A configuration for a set of HTTP response headers that are used for cross-origin resource sharing (CORS).
31 *
32 * @default - no cors behavior
33 */
34 readonly corsBehavior?: ResponseHeadersCorsBehavior;
35 /**
36 * A configuration for a set of custom HTTP response headers.
37 *
38 * @default - no custom headers behavior
39 */
40 readonly customHeadersBehavior?: ResponseCustomHeadersBehavior;
41 /**
42 * A configuration for a set of security-related HTTP response headers.
43 *
44 * @default - no security headers behavior
45 */
46 readonly securityHeadersBehavior?: ResponseSecurityHeadersBehavior;
47}
48/**
49 * A Response Headers Policy configuration
50 *
51 * @resource AWS::CloudFront::ResponseHeadersPolicy
52 */
53export declare class ResponseHeadersPolicy extends Resource implements IResponseHeadersPolicy {
54 /** Use this managed policy to allow simple CORS requests from any origin. */
55 static readonly CORS_ALLOW_ALL_ORIGINS: IResponseHeadersPolicy;
56 /** Use this managed policy to allow CORS requests from any origin, including preflight requests. */
57 static readonly CORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT: IResponseHeadersPolicy;
58 /** Use this managed policy to add a set of security headers to all responses that CloudFront sends to viewers. */
59 static readonly SECURITY_HEADERS: IResponseHeadersPolicy;
60 /** Use this managed policy to allow simple CORS requests from any origin and add a set of security headers to all responses that CloudFront sends to viewers. */
61 static readonly CORS_ALLOW_ALL_ORIGINS_AND_SECURITY_HEADERS: IResponseHeadersPolicy;
62 /** Use this managed policy to allow CORS requests from any origin, including preflight requests, and add a set of security headers to all responses that CloudFront sends to viewers. */
63 static readonly CORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT_AND_SECURITY_HEADERS: IResponseHeadersPolicy;
64 /**
65 * Import an existing Response Headers Policy from its ID.
66 */
67 static fromResponseHeadersPolicyId(scope: Construct, id: string, responseHeadersPolicyId: string): IResponseHeadersPolicy;
68 private static fromManagedResponseHeadersPolicy;
69 readonly responseHeadersPolicyId: string;
70 constructor(scope: Construct, id: string, props?: ResponseHeadersPolicyProps);
71 private _renderCorsConfig;
72 private _renderCustomHeadersConfig;
73 private _renderSecurityHeadersConfig;
74}
75/**
76 * Configuration for a set of HTTP response headers that are used for cross-origin resource sharing (CORS).
77 * CloudFront adds these headers to HTTP responses that it sends for CORS requests that match a cache behavior
78 * associated with this response headers policy.
79 */
80export interface ResponseHeadersCorsBehavior {
81 /**
82 * A Boolean that CloudFront uses as the value for the Access-Control-Allow-Credentials HTTP response header.
83 */
84 readonly accessControlAllowCredentials: boolean;
85 /**
86 * A list of HTTP header names that CloudFront includes as values for the Access-Control-Allow-Headers HTTP response header.
87 * You can specify `['*']` to allow all headers.
88 */
89 readonly accessControlAllowHeaders: string[];
90 /**
91 * A list of HTTP methods that CloudFront includes as values for the Access-Control-Allow-Methods HTTP response header.
92 */
93 readonly accessControlAllowMethods: string[];
94 /**
95 * A list of origins (domain names) that CloudFront can use as the value for the Access-Control-Allow-Origin HTTP response header.
96 * You can specify `['*']` to allow all origins.
97 */
98 readonly accessControlAllowOrigins: string[];
99 /**
100 * A list of HTTP headers that CloudFront includes as values for the Access-Control-Expose-Headers HTTP response header.
101 * You can specify `['*']` to expose all headers.
102 *
103 * @default - no headers exposed
104 */
105 readonly accessControlExposeHeaders?: string[];
106 /**
107 * A number that CloudFront uses as the value for the Access-Control-Max-Age HTTP response header.
108 *
109 * @default - no max age
110 */
111 readonly accessControlMaxAge?: Duration;
112 /**
113 * A Boolean that determines whether CloudFront overrides HTTP response headers received from the origin with the ones specified in this response headers policy.
114 */
115 readonly originOverride: boolean;
116}
117/**
118 * Configuration for a set of HTTP response headers that are sent for requests that match a cache behavior
119 * that’s associated with this response headers policy.
120 */
121export interface ResponseCustomHeadersBehavior {
122 /**
123 * The list of HTTP response headers and their values.
124 */
125 readonly customHeaders: ResponseCustomHeader[];
126}
127/**
128 * An HTTP response header name and its value.
129 * CloudFront includes this header in HTTP responses that it sends for requests that match a cache behavior that’s associated with this response headers policy.
130 */
131export interface ResponseCustomHeader {
132 /**
133 * The HTTP response header name.
134 */
135 readonly header: string;
136 /**
137 * A Boolean that determines whether CloudFront overrides a response header with the same name
138 * received from the origin with the header specified here.
139 */
140 readonly override: boolean;
141 /**
142 * The value for the HTTP response header.
143 */
144 readonly value: string;
145}
146/**
147 * Configuration for a set of security-related HTTP response headers.
148 * CloudFront adds these headers to HTTP responses that it sends for requests that match a cache behavior
149 * associated with this response headers policy.
150 */
151export interface ResponseSecurityHeadersBehavior {
152 /**
153 * The policy directives and their values that CloudFront includes as values for the Content-Security-Policy HTTP response header.
154 *
155 * @default - no content security policy
156 */
157 readonly contentSecurityPolicy?: ResponseHeadersContentSecurityPolicy;
158 /**
159 * Determines whether CloudFront includes the X-Content-Type-Options HTTP response header with its value set to nosniff.
160 *
161 * @default - no content type options
162 */
163 readonly contentTypeOptions?: ResponseHeadersContentTypeOptions;
164 /**
165 * Determines whether CloudFront includes the X-Frame-Options HTTP response header and the header’s value.
166 *
167 * @default - no frame options
168 */
169 readonly frameOptions?: ResponseHeadersFrameOptions;
170 /**
171 * Determines whether CloudFront includes the Referrer-Policy HTTP response header and the header’s value.
172 *
173 * @default - no referrer policy
174 */
175 readonly referrerPolicy?: ResponseHeadersReferrerPolicy;
176 /**
177 * Determines whether CloudFront includes the Strict-Transport-Security HTTP response header and the header’s value.
178 *
179 * @default - no strict transport security
180 */
181 readonly strictTransportSecurity?: ResponseHeadersStrictTransportSecurity;
182 /**
183 * Determines whether CloudFront includes the X-XSS-Protection HTTP response header and the header’s value.
184 *
185 * @default - no xss protection
186 */
187 readonly xssProtection?: ResponseHeadersXSSProtection;
188}
189/**
190 * The policy directives and their values that CloudFront includes as values for the Content-Security-Policy HTTP response header.
191 */
192export interface ResponseHeadersContentSecurityPolicy {
193 /**
194 * The policy directives and their values that CloudFront includes as values for the Content-Security-Policy HTTP response header.
195 */
196 readonly contentSecurityPolicy: string;
197 /**
198 * A Boolean that determines whether CloudFront overrides the Content-Security-Policy HTTP response header
199 * received from the origin with the one specified in this response headers policy.
200 */
201 readonly override: boolean;
202}
203/**
204 * Determines whether CloudFront includes the X-Content-Type-Options HTTP response header with its value set to nosniff.
205 */
206export interface ResponseHeadersContentTypeOptions {
207 /**
208 * A Boolean that determines whether CloudFront overrides the X-Content-Type-Options HTTP response header
209 * received from the origin with the one specified in this response headers policy.
210 */
211 readonly override: boolean;
212}
213/**
214 * Determines whether CloudFront includes the X-Frame-Options HTTP response header and the header’s value.
215 */
216export interface ResponseHeadersFrameOptions {
217 /**
218 * The value of the X-Frame-Options HTTP response header.
219 */
220 readonly frameOption: HeadersFrameOption;
221 /**
222 * A Boolean that determines whether CloudFront overrides the X-Frame-Options HTTP response header
223 * received from the origin with the one specified in this response headers policy.
224 */
225 readonly override: boolean;
226}
227/**
228 * Determines whether CloudFront includes the Referrer-Policy HTTP response header and the header’s value.
229 */
230export interface ResponseHeadersReferrerPolicy {
231 /**
232 * The value of the Referrer-Policy HTTP response header.
233 */
234 readonly referrerPolicy: HeadersReferrerPolicy;
235 /**
236 * A Boolean that determines whether CloudFront overrides the Referrer-Policy HTTP response header
237 * received from the origin with the one specified in this response headers policy.
238 */
239 readonly override: boolean;
240}
241/**
242 * Determines whether CloudFront includes the Strict-Transport-Security HTTP response header and the header’s value.
243 */
244export interface ResponseHeadersStrictTransportSecurity {
245 /**
246 * A number that CloudFront uses as the value for the max-age directive in the Strict-Transport-Security HTTP response header.
247 */
248 readonly accessControlMaxAge: Duration;
249 /**
250 * A Boolean that determines whether CloudFront includes the includeSubDomains directive in the Strict-Transport-Security HTTP response header.
251 *
252 * @default false
253 */
254 readonly includeSubdomains?: boolean;
255 /**
256 * A Boolean that determines whether CloudFront overrides the Strict-Transport-Security HTTP response header
257 * received from the origin with the one specified in this response headers policy.
258 */
259 readonly override: boolean;
260 /**
261 * A Boolean that determines whether CloudFront includes the preload directive in the Strict-Transport-Security HTTP response header.
262 *
263 * @default false
264 */
265 readonly preload?: boolean;
266}
267/**
268 * Determines whether CloudFront includes the X-XSS-Protection HTTP response header and the header’s value.
269 */
270export interface ResponseHeadersXSSProtection {
271 /**
272 * A Boolean that determines whether CloudFront includes the mode=block directive in the X-XSS-Protection header.
273 *
274 * @default false
275 */
276 readonly modeBlock?: boolean;
277 /**
278 * A Boolean that determines whether CloudFront overrides the X-XSS-Protection HTTP response header
279 * received from the origin with the one specified in this response headers policy.
280 */
281 readonly override: boolean;
282 /**
283 * A Boolean that determines the value of the X-XSS-Protection HTTP response header.
284 * When this setting is true, the value of the X-XSS-Protection header is 1.
285 * When this setting is false, the value of the X-XSS-Protection header is 0.
286 */
287 readonly protection: boolean;
288 /**
289 * A reporting URI, which CloudFront uses as the value of the report directive in the X-XSS-Protection header.
290 * You cannot specify a ReportUri when ModeBlock is true.
291 *
292 * @default - no report uri
293 */
294 readonly reportUri?: string;
295}
296/**
297 * Enum representing possible values of the X-Frame-Options HTTP response header.
298 */
299export declare enum HeadersFrameOption {
300 /**
301 * The page can only be displayed in a frame on the same origin as the page itself.
302 */
303 DENY = "DENY",
304 /**
305 * The page can only be displayed in a frame on the specified origin.
306 */
307 SAMEORIGIN = "SAMEORIGIN"
308}
309/**
310 * Enum representing possible values of the Referrer-Policy HTTP response header.
311 */
312export declare enum HeadersReferrerPolicy {
313 /**
314 * The referrer policy is not set.
315 */
316 NO_REFERRER = "no-referrer",
317 /**
318 * The referrer policy is no-referrer-when-downgrade.
319 */
320 NO_REFERRER_WHEN_DOWNGRADE = "no-referrer-when-downgrade",
321 /**
322 * The referrer policy is origin.
323 */
324 ORIGIN = "origin",
325 /**
326 * The referrer policy is origin-when-cross-origin.
327 */
328 ORIGIN_WHEN_CROSS_ORIGIN = "origin-when-cross-origin",
329 /**
330 * The referrer policy is same-origin.
331 */
332 SAME_ORIGIN = "same-origin",
333 /**
334 * The referrer policy is strict-origin.
335 */
336 STRICT_ORIGIN = "strict-origin",
337 /**
338 * The referrer policy is strict-origin-when-cross-origin.
339 */
340 STRICT_ORIGIN_WHEN_CROSS_ORIGIN = "strict-origin-when-cross-origin",
341 /**
342 * The referrer policy is unsafe-url.
343 */
344 UNSAFE_URL = "unsafe-url"
345}