https://github.com/kdcio/aws-policy
This package will generate AWS auth policy for API Gateway lambda authorizer.
https://github.com/kdcio/aws-policy
api api-gateway authentication authorizer aws hacktoberfest lambda policy
Last synced: about 1 month ago
JSON representation
This package will generate AWS auth policy for API Gateway lambda authorizer.
- Host: GitHub
- URL: https://github.com/kdcio/aws-policy
- Owner: kdcio
- License: mit
- Created: 2020-05-18T08:23:04.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-05-13T08:22:53.000Z (about 1 year ago)
- Last Synced: 2025-05-13T09:32:00.082Z (about 1 year ago)
- Topics: api, api-gateway, authentication, authorizer, aws, hacktoberfest, lambda, policy
- Language: JavaScript
- Homepage:
- Size: 1.18 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# AWS Policy Generator
This package will generate AWS auth policy for [API Gateway lambda authorizer](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html).
[](https://www.npmjs.com/package/@kdcio/aws-policy) [](https://bundlephobia.com/result?p=@kdcio/aws-policy) [](https://github.com/kdcio/aws-policy/actions?query=workflow%3Abuild) [](https://snyk.io/test/github/kdcio/aws-policy?targetFile=package.json) [](https://sonarcloud.io/dashboard?id=kdcio_aws-policy) [](https://sonarcloud.io/dashboard?id=kdcio_aws-policy) [](https://sonarcloud.io/dashboard?id=kdcio_aws-policy) [](https://github.com/kdcio/aws-policy/blob/master/LICENSE)
## Install
```terminal
npm i @kdcio/aws-policy
```
## Usage
```javascript
import generatePolicy from '@kdcio/aws-policy';
export const handler = (event) => {
const user = {
name: 'Ian',
username: 'ian',
role: 'admin',
};
const resources = [
'GET/users',
'POST/users',
'GET/users/*',
'PUT/users/*',
'DELETE/users/*',
];
return generatePolicy({
context: { ...user },
principalId: user.username,
effect: 'Allow',
methodArn: event.methodArn,
resources,
});
};
```
## Further Reading
[Output from an Amazon API Gateway Lambda authorizer](https://docs.aws.amazon.com/en_pv/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html)