[go: nahoru, domu]

Skip to content

Proof of concept to demonstrate how to create a API Authorizer with Cognito.

Notifications You must be signed in to change notification settings

raphaelbh/aws-apigateway-authorizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS API Authorizer + Cognito

Project Status

Proof of concept to demonstrate how to create a API Authorizer with Cognito.

Tech Stack:

  • ApiGateway
  • Cognito
  • JWT

Requirements

docker

Installation

Update bootstrap/docker-compose.yaml with the correct env variables:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_DEFAULT_REGION
$ (cd bootstrap && docker-compose up)

Usage

Set the follow env variables (application/.env)

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_DEFAULT_REGION
  • USER_POOL_ID
  • USER_POOL_CLIENT_ID

Getting access token

import application.cognito as cognito

user = {
    'username': 'raphaeldias.ti@gmail.com',
    'password': 'Mudar@123'
}

jwt = cognito.initiate_auth(user)
access_token = jwt['body']['access_token'] 

Requesting api

import requests

headers = {'Authorization' : 'Bearer ' + $access_token}
response = requests.get($API_URL, headers=headers)

Running Tests

Set the follow env variables (tests/.env)

  • API_URL
$ export PYTHONPATH=application 
$ pytest --cache-clear tests/

Tech Stack

docker python aws

Reference

Feedback

If you have any feedback, please contact me at raphaeldias.ti@gmail.com

github linkedin

About

Proof of concept to demonstrate how to create a API Authorizer with Cognito.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages