aws-auth-policy

0.1.0 • Public • Published

aws-policy-generator

Module version of AWS AuthPolicy for generating auth policies for AWS Gateway API Authorizers.

Input

var AuthPolicy = require("./auth-policy");

var apiOptions = {};
apiOptions.region = "us-east-1";
apiOptions.restApiId = "XXXX";
apiOptions.stage = "dev";

var authPolicy = new AuthPolicy("user|XXXX", 51505150, apiOptions);
authPolicy.allowMethod(AuthPolicy.HttpVerb.ALL, "/*");
var generated = authPolicy.build();

var policyJson = JSON.stringify(generated);
console.log(policyJson);

Output

{
  "principalId": "user|XXXX",
  "policyDocument": {
    "Version": "2012-10-17",
    "Statement": [
      {
        "Action": "execute-api:Invoke",
        "Effect": "Allow",
        "Resource": [
          "arn:aws:execute-api:us-east-1:51505150:XXXX/dev/*/*"
        ]
      }
    ]
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i aws-auth-policy

Weekly Downloads

158

Version

0.1.0

License

MIT

Last publish

Collaborators

  • amowu