fix: require a groups claim on token exchange when group management is on (#33846)

Token exchange now refuses the sign-in with a 403 when group management is on, the user is in at least one group and no groups claim can be read from the provider response or the token, the same way the roles check on that path already does.
This commit is contained in:
Classic298 2026-11-07 03:32:47 +01:00 • committed by GitHub
parent b31ae40d2e
commit 184eada9ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1753,6 +1753,9 @@ class OAuthManager:
user_oauth_groups = []
user_current_groups: list[GroupModel] = await Groups.get_groups_by_member_id(user.id, db=db)
if oauth_claim and claim_data is None and token_claims is not None and user_current_groups:
log.warning('Token exchange denied: no readable groups claim in userinfo or the token')
raise HTTPException(status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.ACCESS_PROHIBITED)
all_available_groups: list[GroupModel] = await Groups.get_all_groups(db=db)
# Create groups if they don't exist and creation is enabled