Skip to content

Instantly share code, notes, and snippets.

@mlabouardy
Last active November 14, 2018 21:15
Show Gist options
  • Select an option

  • Save mlabouardy/24ab6756dcaf2cb0e33a68ad0bbe5936 to your computer and use it in GitHub Desktop.

Select an option

Save mlabouardy/24ab6756dcaf2cb0e33a68ad0bbe5936 to your computer and use it in GitHub Desktop.
Lambda authorizer
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