-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
Copy pathserverless.yml
63 lines (58 loc) · 1.67 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
59
60
61
62
63
service: aws-custom-authorizer-auth0
package:
exclude:
- ./**
include:
- vendored/**
- lambda_handlers.py
provider:
name: aws
runtime: python3.6
region: us-east-1
environment:
AUTH0_CLIENT_ID: ${file(./secrets.json):AUTH0_CLIENT_ID}
AUTH0_CLIENT_PUBLIC_KEY: ${file(./public_key)}
PYTHONPATH: "/var/runtime:/var/task/vendored"
functions:
auth:
handler: lambda_handlers.auth
cors: true
publicEndpoint:
handler: lambda_handlers.public_endpoint
events:
- http:
path: api/public
method: post
cors: true
privateEndpoint:
handler: lambda_handlers.private_endpoint
events:
- http:
path: api/private
method: post
# See custom authorizer docs here: http://bit.ly/2gXw9pO
authorizer: auth
cors: true
resources:
Resources:
# This response is needed for custom authorizer failures cors support ¯\_(ツ)_/¯
GatewayResponse:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: EXPIRED_TOKEN
RestApiId:
Ref: 'ApiGatewayRestApi'
StatusCode: '401'
AuthFailureGatewayResponse:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: UNAUTHORIZED
RestApiId:
Ref: 'ApiGatewayRestApi'
StatusCode: '401'