Last active
November 14, 2018 21:15
-
-
Save mlabouardy/24ab6756dcaf2cb0e33a68ad0bbe5936 to your computer and use it in GitHub Desktop.
Lambda authorizer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const TOKEN = process.env.TOKEN; | |
| const generatePolicy = (effect, methodArn) => { | |
| return { | |
| 'policyDocument': { | |
| 'Version': '2012-10-17', | |
| 'Statement': [ | |
| { | |
| 'Sid': '1', | |
| 'Action': 'execute-api:Invoke', | |
| 'Effect': effect, | |
| 'Resource': methodArn | |
| } | |
| ] | |
| } | |
| } | |
| } | |
| exports.handler = async (event, context) => { | |
| if(event.authorizationToken == TOKEN){ | |
| return generatePolicy('ALLOW', event.methodArn) | |
| } | |
| return generatePolicy('DENY', event.methodArn) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment