Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vin65/npm-auth0-authorizer
Auth0 API Gateway Custom Authorizer
https://github.com/vin65/npm-auth0-authorizer
api-gateway api-gateway-custom-authorizer auth0 auth0-audience authorization json jsonwebtoken jwt-auth lambda nodejs npm serverless serverless-framework
Last synced: about 1 month ago
JSON representation
Auth0 API Gateway Custom Authorizer
- Host: GitHub
- URL: https://github.com/vin65/npm-auth0-authorizer
- Owner: Vin65
- Created: 2017-11-28T23:23:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-08T23:24:51.000Z (almost 7 years ago)
- Last Synced: 2024-11-18T19:09:27.526Z (about 2 months ago)
- Topics: api-gateway, api-gateway-custom-authorizer, auth0, auth0-audience, authorization, json, jsonwebtoken, jwt-auth, lambda, nodejs, npm, serverless, serverless-framework
- Language: JavaScript
- Homepage:
- Size: 31.3 KB
- Stars: 4
- Watchers: 12
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Installation
1. `npm install --save npm-auth0-authorizer`2. Ensure the following environment variables are defined within your project:
- AUTH0_DOMAIN (example: https://yourwebsite.auth0.com/)
- AUTH0_AUDIENCE (The unique identifier of the target API you want to access.)
- AUTH0_ALGORITHM (default: RS256)# Usage
- handler.js
```javascript
import auth0Authorizer from 'npm-auth0-authorizer/methods/auth0Authorizer';module.exports.auth0Authorizer = function(event, context, callback){
auth0Authorizer(event).then(success => {
return callback(null, success);
}).catch(err => {
return callback(err);
});
};
```- serverless.yml
```yaml
functions:
auth0Authorizer:
handler: handler.auth0Authorizer
lambdaYouWishToProtect:
handler: handler.test
events:
- http:
path: protect-me
method: get
integration: lambda
authorizer:
name: auth0Authorizer
resultTtlInSeconds: 0
identitySource: method.request.header.Authorization
```