A Django app is used to manage django auth using a token from a external source.
Project description
External JWT Token Shared Security
This django app is used to manage django auth using a token from a external source. Like a auth microservice
Quick start
-
Add "shared_security" to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ... 'shared_security', ]
-
Add on your django projects settings a var named JWT_SECRET_KEY with the secret key of your external jwt generator source. We recommend using a environment variable instead of writing to code directly on settings.py for security reasons
-
Include the shared_security URLconf in your project urls.py like this:
path('token/', include('shared_security.api.urls')),
-
Start the django development server.
-
To use the authentication on your API
-
Add the authentication class on REST_FRAMEWORK variable on django rest framework settings as:
REST_FRAMEWORK = { ... 'DEFAULT_AUTHENTICATION_CLASSES': [ "shared_security.authentication.ExternalTokenAuthentication", ], ... }
-
Add to specific django rest view as:
from shared_security.authentication import ExternalTokenAuthentication class YourView(viewsets.ViewSet): """ A awesome view """ authentication_classes = [ExternalTokenAuthentication,] ...
-
-
Visit http://127.0.0.1:8000/security/user passing on header Authentication Bearer <external_jwt_token> to get user info using decode data from token.
Configuration Vars
SECURITY_USE_PERSISTENT_USERS: Boolean var to specify if you want to use your auth with the creation and update of users on the database. Important to use the django admin application the vars need to be set to true.
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
Built Distribution
Hashes for django-external-jwttoken-shared-security-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b83316501537b958891d2efa5b55193d096ebe50f60d77381a5e0a37f933ae22 |
|
MD5 | 73930ccc61d7210c40b8e8fec4fd7205 |
|
BLAKE2b-256 | 372ae783ef85d3da8ea4494c456a2c969ab3530012d11c82e3b4dba9ba068dd8 |
Hashes for django_external_jwttoken_shared_security-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c511a6921b3f58d6a086c9200399916d7dde846c992c31955c4af7709277d5f |
|
MD5 | 5f7c785cea5c269c21c6c013c3312087 |
|
BLAKE2b-256 | 7398013d38f652b850801423d8c83f751b6e88636f6a472fc0e4d4968da4185c |