serverless-sam
Version:
Serverless framework plugin to export AWS SAM templates for a service
55 lines (51 loc) • 1.56 kB
YAML
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'