Skip to main content
https://github.com/labd/django-cognito-jwt/workflows/Python%20Tests/badge.svg http://codecov.io/github/LabD/django-cognito-jwt/coverage.svg?branch=master https://img.shields.io/pypi/v/django-cognito-jwt.svg Documentation Status

Django Cognito JWT

An Authentication backend for Django Rest Framework for AWS Cognito JWT tokens

Installation

pip install django-cognito-jwt

Usage

Add the following lines to your Django settings.py file:

COGNITO_AWS_REGION = '<aws region>' # 'eu-central-1'
COGNITO_USER_POOL = '<user pool>'   # 'eu-central-1_xYzaq'
COGNITO_AUDIENCE = '<client id>'

(Optional) If you want to cache the Cognito public keys between requests you can enable the COGNITO_PUBLIC_KEYS_CACHING_ENABLED setting (it only works if you have the Django CACHES setup to anything other than the dummy backend).

COGNITO_PUBLIC_KEYS_CACHING_ENABLED = True
COGNITO_PUBLIC_KEYS_CACHING_TIMEOUT = 60*60*24  # 24h caching, default is 300s

Also update the rest framework settings to use the correct authentication backend:

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        ...
        'django_cognito_jwt.JSONWebTokenAuthentication',
        ...
    ],
    ...
 }

Be sure you are passing the ID Token JWT from Cognito as the authentication header. Using the Access Token will work for authentication only but we’re unable to use the get_or_create_for_cognito method with the Access Token.

(Optional) If you want to use a different user model then the default DJANGO_USER_MODEL you can use the COGNITO_USER_MODEL setting.

COGNITO_USER_MODEL = "myproject.AppUser"

Release files for django-cognito-jwt 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-cognito-jwt 0.0.4
File Size Uploaded
django-cognito-jwt-0.0.4.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-cognito-jwt 0.0.4
File Interpreter ABI Platform
django_cognito_jwt-0.0.4-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 10.1 kB

Release files / django-cognito-jwt-0.0.4.tar.gz

Download URL django-cognito-jwt-0.0.4.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
567418f170dc15f690a66cf3a7a934aed4f08f22bbb3090c99e15c6966198552
BLAKE2b-256 checksum
How to use checksums
176de4c22fa8dfba68d303b47271013ad51bbe4558fd6093d3ea2cf1421fbc74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / django_cognito_jwt-0.0.4-py2.py3-none-any.whl

Download URL django_cognito_jwt-0.0.4-py2.py3-none-any.whl
Size 5.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ea5fa964c34b3f76a82920f7e26b68d9287f7359d11a397c810d515122d2bc82
BLAKE2b-256 checksum
How to use checksums
0dc0e59a85d4a16da9c099c58c4c23466da31287aa839a8730a2c92dd81a3ec2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page