X-Portal-User-Subject and X-Portal-User-Email named the acting person for any service client. This PR honours them only from the portal's service client.
Why
Any tenants.read client (werkmeister-svc, pruefwerk-svc, firmwerk-svc) could set the audit actor of a document download (downloadTenantDocument). Tenant scope still held, so this was wrong attribution, not data access.
On the team routes (teamActor) the gap was latent: only portal-svc-* holds tenants.write today. A future tenants.write client could have acted in a user's name.
projectActor and the trial extension (adminExtendTrial) used the same ungated pattern.
Change
portalUser(r) next to staffActor: the headers count only from a client that holds group users.act. The existing users grant satisfies it, and in stage and prod only portal-svc-* holds it, so no AUTHZ_RULES change.
A user token speaks for itself; the headers are ignored for it.
Without a principal (auth disabled, dev) the headers are taken as before.
Used by teamActor, projectActor/projectActorType, the download audit and the trial extension.
Tests
TestPortalUser_onlyFromThePortalClient covers the portal client, three other clients, a user token, no headers and no principal, through portalUser, projectActor, projectActorType and teamActor.
Mutation check: without the group check the test fails.
All existing tests pass unchanged.
Part of the R1 S0 work (docgen#1), decided by Sharang to go with S0. Stage only.
`X-Portal-User-Subject` and `X-Portal-User-Email` named the acting person for any service client. This PR honours them only from the portal's service client.
### Why
- Any `tenants.read` client (`werkmeister-svc`, `pruefwerk-svc`, `firmwerk-svc`) could set the audit actor of a document download (`downloadTenantDocument`). Tenant scope still held, so this was wrong attribution, not data access.
- On the team routes (`teamActor`) the gap was latent: only `portal-svc-*` holds `tenants.write` today. A future `tenants.write` client could have acted in a user's name.
- `projectActor` and the trial extension (`adminExtendTrial`) used the same ungated pattern.
### Change
- `portalUser(r)` next to `staffActor`: the headers count only from a client that holds group `users.act`. The existing `users` grant satisfies it, and in stage and prod only `portal-svc-*` holds it, so **no `AUTHZ_RULES` change**.
- A user token speaks for itself; the headers are ignored for it.
- Without a principal (auth disabled, dev) the headers are taken as before.
- Used by `teamActor`, `projectActor`/`projectActorType`, the download audit and the trial extension.
### Tests
- `TestPortalUser_onlyFromThePortalClient` covers the portal client, three other clients, a user token, no headers and no principal, through `portalUser`, `projectActor`, `projectActorType` and `teamActor`.
- Mutation check: without the group check the test fails.
- All existing tests pass unchanged.
Part of the R1 S0 work (docgen#1), decided by Sharang to go with S0. Stage only.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf
X-Portal-User-Subject and X-Portal-User-Email named the acting person for
any service client. Any tenants.read client (werkmeister-svc, pruefwerk-svc,
firmwerk-svc) could thereby set the audit actor of a document download, and
a future tenants.write client could act in a user's name on the team routes.
portalUser honours the headers only from a client that holds the users
group (group users.act, satisfied by the existing users grant: only the
portal's service client in stage and prod), as staffActor does for
X-Staff-*. A user token speaks for itself and the headers are ignored.
Used by teamActor, projectActor/projectActorType, the document download
audit and the trial extension. No AUTHZ_RULES change is needed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf
sharang
merged commit 9129e95538 into main2026-10-26 20:39:03 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
X-Portal-User-SubjectandX-Portal-User-Emailnamed the acting person for any service client. This PR honours them only from the portal's service client.Why
tenants.readclient (werkmeister-svc,pruefwerk-svc,firmwerk-svc) could set the audit actor of a document download (downloadTenantDocument). Tenant scope still held, so this was wrong attribution, not data access.teamActor) the gap was latent: onlyportal-svc-*holdstenants.writetoday. A futuretenants.writeclient could have acted in a user's name.projectActorand the trial extension (adminExtendTrial) used the same ungated pattern.Change
portalUser(r)next tostaffActor: the headers count only from a client that holds groupusers.act. The existingusersgrant satisfies it, and in stage and prod onlyportal-svc-*holds it, so noAUTHZ_RULESchange.teamActor,projectActor/projectActorType, the download audit and the trial extension.Tests
TestPortalUser_onlyFromThePortalClientcovers the portal client, three other clients, a user token, no headers and no principal, throughportalUser,projectActor,projectActorTypeandteamActor.Part of the R1 S0 work (docgen#1), decided by Sharang to go with S0. Stage only.
🤖 Generated with Claude Code
https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf