Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
- improve comments
- improve error logging

Co-authored-by: Michał Krassowski <[email protected]>
  • Loading branch information
aktech and krassowski authored May 27, 2024
1 parent c04fc89 commit 6e1cdd9
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _get_scope_from_role(self, role):
"""Return scopes from role if the component is jupyterhub"""
role_scopes = role.get("attributes", {}).get("scopes", [])
component = role.get("attributes", {}).get("component")
# Attributes as returned as array
# Attributes are returned as a single-element array, unless `##` delimiter is used in Keycloak
# See this: https://stackoverflow.com/questions/68954733/keycloak-client-role-attribute-array
if component == ["jupyterhub"] and role_scopes:
return self.validate_scopes(role_scopes[0].split(","))
Expand All @@ -164,8 +164,8 @@ def validate_scopes(self, role_scopes):
# as a invalid scopes could cause hub pod to fail
scopes._check_scopes_exist(role_scopes)
return role_scopes
except scopes.ScopeNotFound:
self.log.error(f"Invalid scopes, skipping: {role_scopes}")
except scopes.ScopeNotFound as e:
self.log.error(f"Invalid scopes, skipping: {role_scopes} ({e})")
return []

async def _get_roles_with_attributes(self, roles: dict, client_id: str, token: str):
Expand Down

0 comments on commit 6e1cdd9

Please sign in to comment.