Skip to main content
https://badge.fury.io/py/drf-msal-jwt.svg https://travis-ci.org/narongdejsrn/drf-msal-jwt.svg?branch=master https://codecov.io/gh/narongdejsrn/drf-msal-jwt/branch/master/graph/badge.svg

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': ['*'],
    'MSAL_CHECK_STATE': True
}

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

Deployment

Bumb version & deploy

bumpversion <major/minor/patch>
python setup.py publish

Release files for drf-msal-jwt 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for drf-msal-jwt 0.4.0
File Size Uploaded
drf-msal-jwt-0.4.0.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for drf-msal-jwt 0.4.0
File Interpreter ABI Platform
drf_msal_jwt-0.4.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 17.5 kB

Release files / drf-msal-jwt-0.4.0.tar.gz

Download URL drf-msal-jwt-0.4.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e413e03d498ee03907bf5a82a9ac6aa31a2757edca0070f2c6fe7ba19a041daf
BLAKE2b-256 checksum
How to use checksums
87ec5df4506a7fc9561c285439b94813e6c2bb4437dbb74ba33f734e02ab49aa
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / drf_msal_jwt-0.4.0-py2.py3-none-any.whl

Download URL drf_msal_jwt-0.4.0-py2.py3-none-any.whl
Size 10.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
13155cf9b68d84f84c0596684ea1591f74cd7fbea595732f0b4edf075193034e
BLAKE2b-256 checksum
How to use checksums
4ccd79c36e96603d45fbded6b2ce18c2a5b8cfe98fdcf03fd8c5330da79c2aa9
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page