All Projects → borisrozumnuk → cognitojwt

borisrozumnuk / cognitojwt

Licence: MIT license
Decode and verify Amazon Cognito JWT tokens

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to cognitojwt

asyncio-socks-server
A SOCKS proxy server implemented with the powerful python cooperative concurrency framework asyncio.
Stars: ✭ 154 (+208%)
Mutual labels:  asyncio
postmodel
ORM library for Python 3.6+, asyncio. Provides Django ORM like API.
Stars: ✭ 15 (-70%)
Mutual labels:  asyncio
fastapi-framework
A FastAPI Framework for things like Database, Redis, Logging, JWT Authentication, Rate Limits and Sessions
Stars: ✭ 26 (-48%)
Mutual labels:  asyncio
fastapi-azure-auth
Easy and secure implementation of Azure AD for your FastAPI APIs 🔒 B2C, single- and multi-tenant support.
Stars: ✭ 174 (+248%)
Mutual labels:  asyncio
aiotunnel
HTTP tunnel on top of aiohttp and asyncio
Stars: ✭ 29 (-42%)
Mutual labels:  asyncio
aws-mobilehub-helper-ios
ARCHIVED: Use https://github.com/aws/aws-sdk-ios/
Stars: ✭ 41 (-18%)
Mutual labels:  cognito
glacier
❄️ Building Python CLI using docstrings and typehints 🐍
Stars: ✭ 84 (+68%)
Mutual labels:  asyncio
fast-api-sqlalchemy-template
Dockerized web application on FastAPI, sqlalchemy1.4, PostgreSQL
Stars: ✭ 25 (-50%)
Mutual labels:  asyncio
stream video server
demonstrates how to create video streaming server with the help of aiohttp and opencv
Stars: ✭ 15 (-70%)
Mutual labels:  asyncio
AsyncIO
.NET library for handling asynchronous file system operations
Stars: ✭ 20 (-60%)
Mutual labels:  asyncio
gozeit
GoZeit
Stars: ✭ 19 (-62%)
Mutual labels:  cognito
aioflask
Flask running on asyncio!
Stars: ✭ 192 (+284%)
Mutual labels:  asyncio
pyladies-courseware
Homework/task submit and review web app · based on React and Python aiohttp
Stars: ✭ 14 (-72%)
Mutual labels:  asyncio
quart-motor
Motor support for Quart applications
Stars: ✭ 14 (-72%)
Mutual labels:  asyncio
aioamqp consumer
consumer/producer/rpc library built over aioamqp
Stars: ✭ 36 (-28%)
Mutual labels:  asyncio
nextion
Nextion serial client
Stars: ✭ 14 (-72%)
Mutual labels:  asyncio
aiohttp-mako
mako template renderer for aiohttp.web
Stars: ✭ 32 (-36%)
Mutual labels:  asyncio
aioapns
An efficient APNs Client Library for Python/asyncio
Stars: ✭ 60 (+20%)
Mutual labels:  asyncio
fbemissary
A bot framework for the Facebook Messenger platform, built on asyncio and aiohttp
Stars: ✭ 30 (-40%)
Mutual labels:  asyncio
tellerbot
Telegram Bot for over-the-counter trading
Stars: ✭ 17 (-66%)
Mutual labels:  asyncio

Build Status

Decode and verify Amazon Cognito JWT tokens

Note: tested on Python >= 3.6, compatible with PEP-492 (async/await coroutines syntax)

Installation

Package works in two modes: synchronous - requests as http-client and asynchronous - aiohttp as http-client. In order to avoid installing unnecessary dependencies I separated installation flow into two modes:

  • Async mode - pip install cognitojwt[async]
  • Sync mode - pip install cognitojwt[sync]

Usage

import cognitojwt

id_token = '<YOUR_TOKEN_HERE>'
REGION = '**-****-*'
USERPOOL_ID = 'eu-west-1_*******'
APP_CLIENT_ID = '1p3*********'

# Sync mode
verified_claims: dict = cognitojwt.decode(
    id_token,
    REGION,
    USERPOOL_ID,
    app_client_id=APP_CLIENT_ID,  # Optional
    testmode=True  # Disable token expiration check for testing purposes
)

# Async mode
verified_claims: dict = await cognitojwt.decode_async(
    id_token,
    REGION,
    USERPOOL_ID,
    app_client_id=APP_CLIENT_ID,  # Optional
    testmode=True  # Disable token expiration check for testing purposes
)

Note: if the application is deployed inside a private vpc without internet gateway, the application will not be able to download the JWKS file. In this case set the AWS_COGNITO_JWKS_PATH environment variable referencing the absolute or relative path of the jwks.json file.

It is possible to allow multiple app client ids by passing the value as a Container instance such as a list or tuple:

ALLOWED_CLIENT_IDS = ('client_one', 'client_two')

verified_claims: dict = cognitojwt.decode(
    id_token,
    REGION,
    USERPOOL_ID,
    app_client_id=ALLOWED_CLIENT_IDS,
    testmode=True  # Disable token expiration check for testing purposes
)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].