forked from serverless/examples
/
serverless.yml
55 lines (51 loc) · 1.53 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
service: aws-custom-authorizer-auth0
provider:
name: aws
runtime: nodejs6.10
region: us-west-2
environment:
AUTH0_CLIENT_ID: ${file(./secrets.json):AUTH0_CLIENT_ID}
AUTH0_CLIENT_SECRET: ${file(./secrets.json):AUTH0_CLIENT_SECRET}
functions:
auth:
handler: handler.auth
cors: true
publicEndpoint:
handler: handler.publicEndpoint
events:
- http:
path: api/public
method: post
cors: true
privateEndpoint:
handler: handler.privateEndpoint
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'