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.3.1.tar.gz
(5.5 kB
view hashes)
Built Distribution
Close
Hashes for dj_jwt_auth-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2204038767b057ea776a2648bc05aa614c7655fe84837ba4cad575b888b4a68f |
|
MD5 | 320d0e8d0d65ee6e345a147adb6cf0e8 |
|
BLAKE2b-256 | 8e8a19e32040db1f14d71d8ff43b196bf4ba5e44dcbf49a0a4a23e242877a4c9 |