Files
ocis/services/proxy/pkg
Roman PerekhodandClaude Opus 5.5 4680d9d905 fix(proxy): [OCISDEV-1464] fix the role assignment of multi-instance guests (#13250)
* fix(proxy): [OCISDEV-1464] fail on an unknown multi-instance guest role

The OIDC role assigner did not check that OCIS_MULTI_INSTANCE_GUEST_ROLE
exists. When the guest role name is wrong, the role name has no role id.
The proxy then sent AssignRoleToUser with an empty RoleId on each request.

The role assigner now returns an "unknown role" error and does not change
the role assignment. A test covers a guest that no guest role mapping
matches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(proxy): [OCISDEV-1464] check the guest role mapping more strictly

GuestRoleMapping now trims the spaces around the claim value and the
role name. The env var parser trims list elements, but the yaml parser
does not. Before this change, the yaml entry "spaceadmin: user-light-vault"
gave the role name " user-light-vault", and each matching guest login
failed with "unknown role".

GuestRoleMapping now also rejects a mapping when
OCIS_MULTI_INSTANCE_GUEST_ROLE is empty. The role assigner applies the
mapping only to users that get the guest role. Without a guest role, the
proxy ignored the mapping and gave guests a member role.

gofmt also fixes the indent of a TODO comment in the same file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(proxy): [OCISDEV-1464] log why the guest role mapping does not apply

mapGuestRole dropped the extractRoles error without a log line. When
PROXY_ROLE_ASSIGNMENT_OIDC_CLAIM had a wrong claim name, each guest kept
the guest role, and the admin could not find the cause.

mapGuestRole now writes a debug log line with the claim name and the
error. A guest without a roles claim is valid, and the role assigner runs
on each request, so the log level is debug and not warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(proxy): [OCISDEV-1464] tell that guest claim values are regexes

The guest role mapping uses the same claim matcher as the role mapping.
A claim value is an exact string or a regular expression that must match
the full claim value. The description of
OCIS_MULTI_INSTANCE_GUEST_ROLE_MAPPING did not tell this. An admin who
writes 'school.admin' also matches the claim 'schoolXadmin', and that
guest can get a role with more permissions.

The description now tells that claim values are regexes. It also tells
the admin to escape regex metacharacters in an exact string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(proxy): [OCISDEV-1464] read the roles again for an unknown guest role

The OIDC role assigner checks the guest role and the mapped guest role
against a role cache with a 5 minute TTL. A role that an admin created
after the last cache read was unknown. For up to 5 minutes, each request
of a matching guest failed with "unknown role" and HTTP 500.

The new function guestRoleName reads the roles again one time when the
role is unknown. It reads the roles again only when the cache is older
than 30 seconds. Thus a role that does not exist causes a maximum of one
ListRoles request in 30 seconds, and not one request for each guest
request. The check for an unknown guest role moves into guestRoleName.

roleNamesToRoleIDs now has a maxAge parameter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: [OCISDEV-1464] add the changelog for the guest role mapping fixes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 09:44:32 +01:00
..
2024-10-01 10:41:24 +02:00
2026-06-19 10:43:41 +02:00