Skip to content

Commit

Permalink
Add catch for missing groups in claim
Browse files Browse the repository at this point in the history
  • Loading branch information
sambles committed Sep 18, 2024
1 parent b565d3b commit 8a0b1cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/server/oasisapi/oidc/keycloak_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ def update_groups(self, user, claims):
"""
Persist Keycloak groups as local Django groups.
"""
keycloak_groups = claims.get('groups', [])
keycloak_groups = claims.get('groups', None)
if keycloak_groups is None:
msg = 'No group found in claim / user_info'
raise SuspiciousOperation(msg)

for i, keycloak_group in enumerate(keycloak_groups):
if keycloak_group.startswith('/'):
keycloak_groups[i] = keycloak_group[1:]
Expand Down

0 comments on commit 8a0b1cb

Please sign in to comment.