MCPcopy Create free account
hub / github.com/serverless/examples / generatePolicy

Function generatePolicy

aws-node-auth0-custom-authorizers-api/handler.js:8–23  ·  view source on GitHub ↗
(principalId, effect, resource)

Source from the content-addressed store, hash-verified

6
7// Policy helper function
8const generatePolicy = (principalId, effect, resource) => {
9 const authResponse = {};
10 authResponse.principalId = principalId;
11 if (effect && resource) {
12 const policyDocument = {};
13 policyDocument.Version = '2012-10-17';
14 policyDocument.Statement = [];
15 const statementOne = {};
16 statementOne.Action = 'execute-api:Invoke';
17 statementOne.Effect = effect;
18 statementOne.Resource = resource;
19 policyDocument.Statement[0] = statementOne;
20 authResponse.policyDocument = policyDocument;
21 }
22 return authResponse;
23};
24
25// Reusable Authorizer function, set on `authorizer` field in serverless.yml
26module.exports.auth = (event, context, callback) => {

Callers 1

handler.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected