Skip to content

Commit fa83853

Browse files
authored
fix: fall back to RBAC when API key auth lacks Keycloak token (#6091)
Signed-off-by: haonanan <89837754+haonanan@users.noreply.github.com>
1 parent 8e988e0 commit fa83853

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

ee/identitymanager/identity_managers/keycloak/keycloak_authverifier.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ def _authorize(self, authenticated_entity: AuthenticatedEntity) -> None:
346346
if self.keycloak_multi_org:
347347
return super()._authorize(authenticated_entity)
348348

349+
# API key auth does not carry a Keycloak token; fall back to RBAC
350+
if not getattr(authenticated_entity, "token", None):
351+
return super()._authorize(authenticated_entity)
352+
349353
# for single tenant Keycloaks, use Keycloak's UMA to authorize
350354
try:
351355
permission = UMAPermission(
@@ -369,6 +373,10 @@ def _authorize(self, authenticated_entity: AuthenticatedEntity) -> None:
369373
def authorize_resource(
370374
self, resource_type, resource_id, authenticated_entity: AuthenticatedEntity
371375
) -> None:
376+
# API key auth does not carry a Keycloak token; skip per-resource UMA check
377+
if not getattr(authenticated_entity, "token", None):
378+
return
379+
372380
# use Keycloak's UMA to authorize
373381
try:
374382
permission = UMAPermission(

0 commit comments

Comments
 (0)