Skip to content

Documentation for the Azure AD Authentication Backend

cwkang1998 edited this page Feb 28, 2018 · 6 revisions

Django Setup Guide

To use this, please add below to settings.py

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'rest_framework',
    'azureAD_auth',
]

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES':[
        'azureAD_auth.auth.AzureADSocialAuthentication',
    ]
}

Simply add the following:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('azuread-user/', include('azureAD_auth.urls')),
]

Api Guide

There will be only a endpoints for getting user data and updating user data:

/azuread-user/me/

This endpoint only accepts Get and Patch requests.

GET    /azuread-user/me/   Returns user information
Does not accept any query parameters.


PUT    /azuread-user/me/   Allows partial update for student_id and library_no
Accepts 4 parameters :
* student_id (strictly integer based strings)
* library_no (strictly integer based strings)
* year_of_study (accepts any strings)
* course (accepts any strings)
Any amount of field can be updated at a time; 
That is, you can choose to update all fields or just update a single field
(provided you do not give an empty field for student_id and library_no) with one request.

Usage of this authentication app

Any view that implements this authentication and permission class will now require a valid Microsoft Graph API Access token.

To authenticate simply use a Authorization Header with Bearer attached at the start of the token.

An Example of the Http authorization bearer token header

Clone this wiki locally