Skip to main content

Django backends for AWS Cognito JWT

Project description

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

Status

https://travis-ci.org/labd/django-cognito-jwt.svg?branch=master http://codecov.io/github/LabD/django-cognito-jwt/coverage.svg?branch=master https://img.shields.io/pypi/v/django-cognito-jwt.svg Documentation Status

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-cognito-jwt-0.0.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

django_cognito_jwt-0.0.2-py2.py3-none-any.whl (5.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-cognito-jwt-0.0.2.tar.gz.

File metadata

  • Download URL: django-cognito-jwt-0.0.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for django-cognito-jwt-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c90df2fdcef18376275b309b39766f65e18286d24f94836accab808762d0bca4
MD5 ff75bb9365783c77aece26c222b9133f
BLAKE2b-256 753163b06559a7b9579eb8546821db31cc22d4dd959ff3b52e662b45b3bd14eb

See more details on using hashes here.

File details

Details for the file django_cognito_jwt-0.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: django_cognito_jwt-0.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for django_cognito_jwt-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 baa6094ce1f2494fb703323bddec6ea3174ac301473a6509e41065f8d2ecd0b7
MD5 731a21ed0c055697166b0f0d433e77a4
BLAKE2b-256 39ed74b6147786a3eabeb4cf6adcc4caf6be42628c356920cece1c22267a13cb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page