Skip to content

Commit dad2cd0

Browse files
committed
[IMP] auth_oidc: fetch the OIDC validation_endpoint
1 parent 3a86f33 commit dad2cd0

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

auth_oidc/models/res_users.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,30 @@ 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 OIDC validation_endpoint
72+
if oauth_provider.validation_endpoint:
73+
response = requests.get(
74+
oauth_provider.validation_endpoint,
75+
headers={"Authorization": f"Bearer {access_token}"},
76+
timeout=10,
77+
)
78+
if response.ok: # nb: could be a successful failure
79+
validation.update(response.json())
80+
81+
# Use the access_token to fetch the OAuth2 data_endpoint
6882
if oauth_provider.data_endpoint:
69-
data = requests.get(
83+
response = requests.get(
7084
oauth_provider.data_endpoint,
7185
headers={"Authorization": f"Bearer {access_token}"},
7286
timeout=10,
73-
).json()
74-
validation.update(data)
87+
)
88+
if response.ok: # nb: could be a successful failure
89+
validation.update(response.json())
90+
7591
# required check
7692
if "sub" in validation and "user_id" not in validation:
7793
# set user_id for auth_oauth, user_id is not an OpenID Connect standard

0 commit comments

Comments
 (0)