A Django package for JSON Web Token validation and verification. Using PyJWT.
Project description
===== Django-JWT
This is a package to verify and validate JSON Web Tokens (JWT) in Django.
Installation
-
Install the package using pip.
-
Add "django_jwt" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
...
'django_jwt',
]
- Add "django_jwt.middleware.JWTAuthMiddleware" to your MIDDLEWARE setting like this::
MIDDLEWARE = [
...
'django_jwt.middleware.JWTAuthMiddleware',
]
Configuration:
Required variables:
- JWT_CERTS_URL - certificate endpoint, like
https://keyCloak/realms/h/protocol/openid-connect/certs
Optional variables:
-
JWT_ALGORITHM - by default
ES256
-
JWT_AUDIENCE - by default ["account", "broker"]
-
JWT_USER_UID - User model' unique identifier, by default
kc_id
-
JWT_USER_MAPPING - mapping between JWT claims and user model fields, by default:
JWT_USER_MAPPING = {
'first_name': 'first_name',
'last_name': 'last_name',
'username': 'username',
}
- JWT_USER_DEFAULTS - default values for user model fields, by default:
JWT_USER_DEFAULTS = {
'is_active': True,
}
- JWT_USER_ON_CREATE and JWT_USER_ON_UPDATE - functions to be called on user creation and update, by default:
JWT_USER_ON_CREATE = None
JWT_USER_ON_UPDATE = None
These functions should accept two arguments: user and request.
Testing:
Run command python runtests.py
to run tests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dj-jwt-auth-0.2.0.tar.gz
(5.3 kB
view hashes)
Built Distribution
Close
Hashes for dj_jwt_auth-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aff1c8df86237bfcb6ea0399232248716e127f18d8f257e48f7d5399ef5bc4d7 |
|
MD5 | 99a3f51af35d1cf372c1faa19e344999 |
|
BLAKE2b-256 | d46b5b2e0c9342355b39d1a37dfa432636e15b9ce1b5ed1797d2f56278508b9c |