Skip to content

Commit 89a2a5f

Browse files
committed
[IMP] auth_oidc: clearer data_endpoint access
1 parent 58f2c8d commit 89a2a5f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

auth_oidc/models/res_users.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,20 @@ def auth_oauth(self, provider, params):
6464
if not id_token:
6565
_logger.error("No id_token in response.")
6666
raise AccessDenied()
67+
68+
# Parse the ID token
6769
validation = oauth_provider._parse_id_token(id_token, access_token)
70+
71+
# Use the access_token to fetch the data_endpoint (userinfo)
6872
if oauth_provider.data_endpoint:
69-
data = requests.get(
73+
response = requests.get(
7074
oauth_provider.data_endpoint,
7175
headers={"Authorization": "Bearer %s" % access_token},
7276
timeout=10,
73-
).json()
74-
validation.update(data)
77+
)
78+
if response.ok: # nb: could be a successful failure
79+
validation.update(response.json())
80+
7581
# required check
7682
if "sub" in validation and "user_id" not in validation:
7783
# set user_id for auth_oauth, user_id is not an OpenID Connect standard

0 commit comments

Comments
 (0)