auth: Add support for Azure Active Directory authentication.

This takes advantage of all of our work on making the
python-social-auth integration reusable for other authentication
backends.
This commit is contained in:
seresheim
2018-10-05 14:32:02 +02:00
committed by Tim Abbott
parent 9d058f9193
commit 49dbd85a89
10 changed files with 72 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ from django.http import HttpResponse
from requests import HTTPError
from social_core.backends.github import GithubOAuth2, GithubOrganizationOAuth2, \
GithubTeamOAuth2
from social_core.backends.azuread import AzureADOAuth2
from social_core.backends.base import BaseAuth
from social_core.backends.oauth import BaseOAuth2
from social_core.utils import handle_http_errors
@@ -66,6 +67,9 @@ def google_auth_enabled(realm: Optional[Realm]=None) -> bool:
def github_auth_enabled(realm: Optional[Realm]=None) -> bool:
return auth_enabled_helper(['GitHub'], realm)
def azuread_auth_enabled(realm: Optional[Realm]=None) -> bool:
return auth_enabled_helper(['AzureAD'], realm)
def remote_auth_enabled(realm: Optional[Realm]=None) -> bool:
return auth_enabled_helper(['RemoteUser'], realm)
@@ -645,6 +649,9 @@ class GitHubAuthBackend(SocialAuthMixin, GithubOAuth2):
raise AssertionError("Invalid configuration")
class AzureADAuthBackend(SocialAuthMixin, AzureADOAuth2):
auth_backend_name = "AzureAD"
AUTH_BACKEND_NAME_MAP = {
'Dev': DevAuthBackend,
'Email': EmailAuthBackend,