2022-01-27 15:21:58 +01:00

42 lines
850 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,
},
],
},
};
};