aws-api-gateway-policy-generator
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

AWS-API-Gateway-Policy-Generator

It is a simple tool that can be used with a custom authorizer to generate policy documents. You have to feed a dictionary of policy statements keyed by unique names (called claims). When a set of claims are fed to the generator, it in turn generates a policy document by attaching policy statements linked with the claims.

The Policy statements in the policy map are standard Amazon policy documents.

Sample Policy Map

 
const policyMap = {
    'CreateUser': [
        {'Resource': 'test resource'},
        {'Resource': 'denied resource', 'Effect': 'deny'},
        {'Resource': 'another resource', 'Action': 'execute-api:Invoke'}
    ],
    'UpdateUser': [
        {'Resource': 'some other resource'}
    ]
};
 

Installation

npm install aws-api-gateway-policy-generator --save

Usage

 
const policyMap = {
    'CreateUser': [
        {'Resource': 'test resource'},
        {'Resource': 'denied resource', 'Effect': 'deny'},
        {'Resource': 'another resource', 'Action': 'execute-api:Invoke'}
    ],
    'UpdateUser': [
        {'Resource': 'some other resource'}
    ]
};
 
const generator = new PolicyGenerator(policyMap);
 
const claims = ['CreateUser', 'SomeOther'];
const document = generator.generatePolicyDocument(claims);
 

Refer the demo/ directory for a complete implementation.

Contributing

Package Sidebar

Install

npm i aws-api-gateway-policy-generator

Weekly Downloads

9

Version

0.0.3

License

MIT

Last publish

Collaborators

  • 99xtechnology
  • pasinducw