Skip to content

Commit 16c2831

Browse files
authored
Improvements to GeoNode OpenID for Entra ID (#12873)
1 parent 9415e4d commit 16c2831

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

geonode/people/adapters.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,9 @@ def complete_login(self, request, app, token, response, **kwargs):
319319
extra_data.update(profile_data)
320320
except Exception:
321321
logger.exception(OAuth2Error("Invalid profile_url, falling back to id_token checks..."))
322-
if not extra_data and "id_token" in response:
322+
if "id_token" in response:
323323
try:
324-
extra_data = jwt.decode(
324+
extra_data_id_token = jwt.decode(
325325
response["id_token"],
326326
# Since the token was received by direct communication
327327
# protected by TLS between this library and Google, we
@@ -338,6 +338,7 @@ def complete_login(self, request, app, token, response, **kwargs):
338338
issuer=self.id_token_issuer,
339339
audience=app.client_id,
340340
)
341+
extra_data.update(extra_data_id_token)
341342
except jwt.PyJWTError as e:
342343
raise OAuth2Error("Invalid id_token") from e
343344
login = self.get_provider().sociallogin_from_response(request, extra_data)

geonode/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,11 +1991,12 @@ def get_geonode_catalogue_service():
19911991
"prompt": "select_account",
19921992
},
19931993
"COMMON_FIELDS": {"email": "mail", "last_name": "surname", "first_name": "givenName"},
1994-
"UID_FIELD": "unique_name",
1994+
"UID_FIELD": "sub",
19951995
"GROUP_ROLE_MAPPER_CLASS": SOCIALACCOUNT_GROUP_ROLE_MAPPER,
19961996
"ACCOUNT_CLASS": "allauth.socialaccount.providers.microsoft.provider.MicrosoftGraphAccount",
19971997
"ACCESS_TOKEN_URL": f"https://login.microsoftonline.com/{_AZURE_TENANT_ID}/oauth2/v2.0/token",
19981998
"AUTHORIZE_URL": f"https://login.microsoftonline.com/{_AZURE_TENANT_ID}/oauth2/v2.0/authorize",
1999+
"ID_TOKEN_ISSUER": f"https://login.microsoftonline.com/{_AZURE_TENANT_ID}/v2.0",
19992000
"PROFILE_URL": "https://graph.microsoft.com/v1.0/me",
20002001
}
20012002

0 commit comments

Comments
 (0)