Skip to main content

Easily add Microsoft Authentication to your Django Projects

Project description

Django Microsoft SSO

Easily integrate Microsoft Authentication into your Django projects

PyPI Build PyPI - Python Version PyPI - Django Version

Welcome to Django Microsoft SSO

This library aims to simplify the process of authenticating users with Microsoft 365 in Django Admin pages, inspired by libraries like django_microsoft_auth and django-admin-sso


Documentation


Install

$ pip install django-microsoft-sso

Compatibility

  • Python 3.11, 3.12, 3.13, 3.14
  • Django 5.0, 5.1, 5.2, 6.0

Older python/django versions are not supported.

Configure

  1. Add the following to your settings.py INSTALLED_APPS:
# settings.py

INSTALLED_APPS = [
    # other django apps
    "django.contrib.messages",  # Need for Auth messages
    "django_microsoft_sso",  # Add django_microsoft_sso
]
  1. In Microsoft Entra Administration Center create a multi-tenant app registration and at Application Register, retrieve your Application ID. Navigate to Certificate & secrets link, and get the Client Secret Value. Add both in your settings.py:
# settings.py

MICROSOFT_SSO_APPLICATION_ID = "your Application ID here"
MICROSOFT_SSO_CLIENT_SECRET = "your Client Secret Value here"
MICROSOFT_SSO_SCOPES = ["User.Read.All"]
  1. Add the callback uri http://localhost:8000/microsoft_sso/callback/ in your Microsoft Console, on the "Authorized Redirect URL".

  2. Let Django Microsoft SSO auto create users for allowable domains:

# settings.py

MICROSOFT_SSO_ALLOWABLE_DOMAINS = ["contoso.com"]
  1. In urls.py please add the Django-Microsoft-SSO views:
# urls.py

from django.urls import include, path

urlpatterns = [
    # other urlpatterns...
    path(
        "microsoft_sso/", include("django_microsoft_sso.urls", namespace="django_microsoft_sso")
    ),
]
  1. And run migrations:
$ python manage.py migrate

That's it. Start django on port 8000 and open your browser in http://localhost:8000/admin/login and you should see the Microsoft SSO button.


Example project

A minimal Django project using this library is included in this repository under example_microsoft_app/.

  • Read the step-by-step instructions in example_microsoft_app/README.md
  • Use it as a reference to configure your own project settings and URLs

License

This project is licensed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_microsoft_sso-7.0.1.tar.gz (526.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_microsoft_sso-7.0.1-py3-none-any.whl (36.7 kB view details)

Uploaded Python 3

File details

Details for the file django_microsoft_sso-7.0.1.tar.gz.

File metadata

  • Download URL: django_microsoft_sso-7.0.1.tar.gz
  • Upload date:
  • Size: 526.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_microsoft_sso-7.0.1.tar.gz
Algorithm Hash digest
SHA256 c3be0c7b7229f7fe4c44642cf660f867cca1b3a04a428c84dc21c4ba9117d45e
MD5 35b7060e307bdb7ed508573feb34a25b
BLAKE2b-256 abad70cc4072500990b0a11fd6d39ed321ad586ad1d2d7af0a2e91646bae4c4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_microsoft_sso-7.0.1.tar.gz:

Publisher: publish.yml on megalus/django-microsoft-sso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_microsoft_sso-7.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_microsoft_sso-7.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 619210cfef81907ef5d96d3d8d0077bb0b55299e80b105f99524395c7ece2c14
MD5 c2707bb162446b4cd2c4e73278dd6767
BLAKE2b-256 1dded063dc648a8f10268a73e9bf2c6783af1a8dfbdf95e61ac0fc01af3fdc9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_microsoft_sso-7.0.1-py3-none-any.whl:

Publisher: publish.yml on megalus/django-microsoft-sso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page