2024-05-29 11:51:04 -04:00

42 lines
843 B
JavaScript

'use strict'
module.exports.simpleAuthorizer = async (event) => {
if (event.headers.authorization === 'secretToken') {
return { isAuthorized: true }
}
return { isAuthorized: false }
}
module.exports.standardAuthorizer = async (event) => {
if (event.headers.authorization === 'secretToken') {
return {
principalId: 'userId',
policyDocument: {
Version: '2012-10-17',
Statement: [
{
Action: 'execute-api:Invoke',
Effect: 'Allow',
Resource: event.routeArn,
},
],
},
}
}
return {
principalId: 'userId',
policyDocument: {
Version: '2012-10-17',
Statement: [
{
Action: 'execute-api:Invoke',
Effect: 'Deny',
Resource: event.routeArn,
},
],
},
}
}