Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

auth: Update AzureADAuthBackend to use the newer Microsoft API.

Mateusz Mandera2a1da859ea85
diff --git a/zproject/backends.py b/zproject/backends.py
index d7ae8c28ba1..ff27c2a497b 100644
--- a/zproject/backends.py
+++ b/zproject/backends.py
@@ -2229,6 +2229,15 @@ class GitHubAuthBackend(SocialAuthMixin, GithubOAuth2):
@external_auth_method
class AzureADAuthBackend(SocialAuthMixin, AzureADOAuth2):
+ # The upstream implementation uses the outdated /oauth2/authorize
+ # API (instead of the v2.0 API), which doesn't allow us to authenticate
+ # users with just a personal Microsoft account. v2.0 API is required.
+ # This requires us to override the default URLs to use it as well
+ # as adjust the requested scopes, to match this new API.
+ AUTHORIZATION_URL = "{base_url}/oauth2/v2.0/authorize"
+ ACCESS_TOKEN_URL = "{base_url}/oauth2/v2.0/token"
+ DEFAULT_SCOPE = ["User.Read profile openid email"]
+
sort_order = 50
name = "azuread-oauth2"
auth_backend_name = "AzureAD"