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 in Django Admin pages, inspired by libraries like django_microsoft_auth and django-admin-sso


Documentation


Install

$ pip install django-microsoft-sso

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.


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-5.0.0.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

django_microsoft_sso-5.0.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_microsoft_sso-5.0.0.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for django_microsoft_sso-5.0.0.tar.gz
Algorithm Hash digest
SHA256 ebcb562cbcb3386bb0b153840ebbee60ea9843c969437af1b7b8a1f81c8950bf
MD5 6310bb19f55efdb3fe716d5ea0c879e7
BLAKE2b-256 176877d9c1b12b41165690fb4d695f8c3a48a1d35be2c16391bdaea8f94a540b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_microsoft_sso-5.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7aa118b2a6a148d95cda93bb0b13421be5d4a03f969f7873f6abf7cdd1af8349
MD5 c2b178cd38d5d27065756e9c74fbf285
BLAKE2b-256 31e0abee589e6494756f7e791913134d92fe834678da0f41f944ae029ec9d6d0

See more details on using hashes here.

Supported by

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