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.1.tar.gz
(5.3 kB
view hashes)
Built Distribution
Close
Hashes for dj_jwt_auth-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cabb74fe6dc440f369d3757bd4d4582de9be8d54b3a8ee2862089fbffc08bf52 |
|
MD5 | ced26c4922faad74a490bcc7008a0450 |
|
BLAKE2b-256 | 1edb53e93c80515a5e8430bc2073388f826781ca1c39e6484d0c0147008b4ce7 |