Simple app to enable Microsoft Account, Office 365 and Xbox Live authentcation as a Django authentcation backend.
Project description
Django Microsoft Authentication Backend
Simple app to enable Microsoft Account, Office 365 and Xbox Live authentcation as a Django authentcation backend.
Free software: MIT license
Documentation: https://django-microsoft-auth.readthedocs.io.
Quickstart
Install Django
- Install and configure the Sites framework
Make sure you update the domain of SITE_ID, this is important and used later. Easy way is to go /admin/sites/site/1/change/ if you have the admin site enabled.
- Create a Microsoft OAuth Application
write down your client ID
Generate an Application Secret, store this somewhere, you will need it for later
Add a Web Platform with Allow Implicit Flow and a valid Redirect URL (this will probably be https://<your-domain>/microsoft/auth-callback/), it must be HTTPS
Add User.Read under Delegated Permissions
Install package from PyPi:
pip install django_microsoft_auth
Add the following to your settings.py:
INSTALLED_APPS = [ # other apps... 'django.contrib.sites', 'microsoft_auth', ] TEMPLATES = [ { # other template settings... 'OPTIONS': { 'context_processors': [ # other context_processors... 'microsoft_auth.context_processors.microsoft', ], }, }, ] AUTHENTICATION_BACKENDS = [ 'microsoft_auth.backends.MicrosoftAuthenticationBackend', 'django.contrib.auth.backends.ModelBackend' # if you also want to use Django's authentication # I recommend keeping this with at least one database superuser in case of unable to use others ] # pick one MICROSOFT_AUTH_LOGIN_TYPE = 'ma' # Microsoft authentication # MICROSOFT_AUTH_LOGIN_TYPE = 'o365' # Enterprise Office 365 authentication # MICROSOFT_AUTH_LOGIN_TYPE = 'xbl' # Xbox Live authentication MICROSOFT_AUTH_CLIENT_ID = 'your-client-id-from-apps.dev.microsoft.com' MICROSOFT_AUTH_CLIENT_SECRET = 'your-client-secret-from-apps.dev.microsoft.com'
Add the following to your urls.py:
urlpatterns = [ # other urlpatterns... url(r'^microsoft/', include('microsoft_auth.urls', namespace='microsoft')), ]
Run migrations:
python manage.py migrate
Start site and goto /admin to and logout if you are logged in.
Login as Microsoft/Office 365/Xbox Live user. It will fail. This will automatically create your new user.
Login as a Password user with access to change user accounts.
Go to Admin -> Users and edit your Microsoft user to have any permissions you want as you normally.
See microsoft_auth/templates/microsoft/admin_login.html for details examples on making a Login form.
See official docs for more details on setup and configuration.
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
1.0.0 (2017-11-19)
First release on PyPI.
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
Hashes for django_microsoft_auth-1.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bd7a566f0069c0a68881053cf8c6231b29c75cff7048c7a496878a443f8d324 |
|
MD5 | dea11c8a7f2195be246cdb3c65425909 |
|
BLAKE2b-256 | 05e41eb6932d3028d05354858a6f9c2f13b03e3d2d3be1ad2197ce67184afedb |