Skip to content

Commit a207b6f

Browse files
committed
fix(auth): add rh-identity support to authorization middleware
The authorization middleware was missing a case for the rh-identity authentication module. When using rh-identity auth with access_rules, the match statement fell through to the default case which raised an InternalServerError (HTTP 500) on every protected endpoint. This adds proper handling for AUTH_MOD_RH_IDENTITY that: - Uses NoopRolesResolver (all authenticated users get the "*" role) - Applies GenericAccessResolver with configured access_rules - Falls back to NoopAccessResolver if no access_rules are configured Without this fix, rh-identity authentication works but authorization fails silently with 500 errors. Signed-off-by: Major Hayden <major@redhat.com>
1 parent 2adb747 commit a207b6f

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/authorization/middleware.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ def get_authorization_resolvers() -> Tuple[RolesResolver, AccessResolver]:
6464
GenericAccessResolver(authorization_cfg.access_rules),
6565
)
6666

67+
case constants.AUTH_MOD_RH_IDENTITY:
68+
# rh-identity uses access rules for authorization, but doesn't extract
69+
# roles from the identity header - all authenticated users get the "*" role
70+
if len(authorization_cfg.access_rules) == 0:
71+
return NoopRolesResolver(), NoopAccessResolver()
72+
73+
return (
74+
NoopRolesResolver(),
75+
GenericAccessResolver(authorization_cfg.access_rules),
76+
)
77+
6778
case _:
6879
response = InternalServerErrorResponse.generic()
6980
raise HTTPException(**response.model_dump())

0 commit comments

Comments
 (0)