Connect Django Rest Framework with MSAL and JWT
Project description
This package allows user to authenticate using Microsoft Account in Django REST Framework.
This library rely on Django REST Framework and Django Rest Framework JWT to works properly. Please make sure you setup these packages successfully before using this package.
Documentation
The full documentation is at https://drf-msal-jwt.readthedocs.io.
Quickstart
Install Django Rest Framework MSAL + JWT:
pip install drf-msal-jwt
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'drf_msal_jwt',
...
)
Add Django Rest Framework MSAL + JWT’s URL patterns:
from drf_msal_jwt import urls as drf_msal_jwt_urls
urlpatterns = [
...
url(r'^', include(drf_msal_jwt_urls)),
...
]
Config the settings.py
DEFAULTS = {
'MSAL_CLIENT_ID': "{AZURE_AD_CLIENT_ID}",
'MSAL_CLIENT_SECRET': "{AZURE_AD_CLIENT_SECRET}",
'MSAL_AUTHORITY_URL': 'https://login.microsoftonline.com/common/',
'MSAL_REDIRECT_URL': "{AZURE_AD_REDIRECT_URL}",
'MSAL_SCOPES': ["User.ReadBasic.All"],
'MSAL_USER_HANDLER': 'django.contrib.auth.models.User',
'MSAL_ALLOW_DOMAINS': ['*']
}
Features
[API] for generating Microsoft Login URL
[API] for logging/creating user based on Authorization Code, and generate JWT token
Running Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
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
File details
Details for the file drf-msal-jwt-0.3.0.tar.gz
.
File metadata
- Download URL: drf-msal-jwt-0.3.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec7713864ce0635fabc3f754c2256789fb1e480a494db1920bd4e2842c92ead4 |
|
MD5 | c1f9c8e3adcd1f10e8fa0a0dac00cb11 |
|
BLAKE2b-256 | 5ff2a0dcfd3568ba6d79bf85230eeca821c8570c0c41081c2bc7c1661c54746d |
File details
Details for the file drf_msal_jwt-0.3.0-py2.py3-none-any.whl
.
File metadata
- Download URL: drf_msal_jwt-0.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e00d6bbeb6599b28d454850258ec5386c879190ecc77198757e0da5b52562f76 |
|
MD5 | 8232b5c81ce1af8ef2146a15004479f3 |
|
BLAKE2b-256 | d83d9af155c09ffb4b75630cb9058756f51f1b75b17d4ce23c45cd538a2f6dbb |