mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 05:53:43 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user