Skip to content

API Gateway Lambda function to support JSON Web Tokens

Notifications You must be signed in to change notification settings

long-bai/lambda-jwt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lambda API Gateway support for JSON Web Tokens

API Gateway custom Lambda function for JSON Web Token: https://jwt.io/introduction/

To Generate your own private key

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -nodes

Upload to AWS

Log into the AWS console and create an empty "jwtAuthorize" function using Node.js.

Create or copy your public key as "cert.pem" in this folder.

Run

npm install
grunt deploy --account-id=<your account id>

Tie this function to your AWS API Gateway

Go to the AWS console and choose your API gateway. Under "Resources" choose "Custom Authorizers". Create a new authorizer with the identityToken source of method.request.header.Authorization and a Token validation expression of Bearer [^\.]+\.[^\.]+\.[^\.]+ and associate it with your newly created jwtAuthorizer Lambda function.

About

API Gateway Lambda function to support JSON Web Tokens

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%