Skip to content

sharathkramadas/sls-authz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless JWT Authorization - Python

Prerequisites

  • Python 3.8
  • Python PIP
  • Node
  • NPM
  • Httpie
  • AWS credentials configured using aws cli

Instructions

  • Step 1: Install serverless module
npm install -g serverless
  • Step 2: Install serverless plugins
sls plugin install -n serverless-python-requirements
  • Step 3: Deploy function
sls deploy
  • Step 4: Fetch the API Gateway url and run the function
http GET <your-gateway-url>

You should see a 401 Unauthorized

  • Step 5: Generate a JWT token
pip install pyjwt
python3 -c 'import jwt; print(jwt.encode({"user":"John"},"secret",algorithm="HS256"))'

Copy the token

  • Step 6: Send an authorized request
http GET <your-gateway-url> Authorization:<your-token>

About

An AWS Serverless Authorization using JWT.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages