forked from aaronosb/cookie-authorizer-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
58 lines (58 loc) · 1.84 KB
/
serverless.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
service:
name: cookie-authorizer-example
provider:
name: aws
runtime: python3.7
stage: dev
region: us-east-1
functions:
example:
handler: code/hello_world.lambda_handler
description:
events:
- http:
path: /
method: get
cors:
origins:
- https://example.com # <-- You have to specify origins wildcards will result in CORS Errors
allowCredentials: true
authorizer:
name: cookieAuthFunction
resultTtlInSeconds: 300
type: request # <-- Make sure the authorizer type is request
cookieAuthFunction:
handler: code/auth.lambda_handler
resources:
# The following are necessary to avoid CORS Errors making debugging difficult if your function fails
Resources:
GatewayResponseDefault4XX:
Type: "AWS::ApiGateway::GatewayResponse"
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'https://example.com'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
gatewayresponse.header.Access-Control-Allow-Credentials: "'true'"
ResponseType: DEFAULT_4XX
RestApiId:
Ref: "ApiGatewayRestApi"
GatewayResponseDefault5XX:
Type: "AWS::ApiGateway::GatewayResponse"
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'https://example.com'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
gatewayresponse.header.Access-Control-Allow-Credentials: "'true'"
ResponseType: DEFAULT_5XX
RestApiId:
Ref: "ApiGatewayRestApi"
S3Bucket:
Type: "AWS::S3::Bucket"
package:
excludeDevDependencies: True
exclude:
- venv/**
- diagrams/**
- example-frontend/**
- README.md
- node_modules/**