Repository navigation
Description
Why
A workflow engine (Conquest at CERIT) is to send tasks to proTES with its own service token (client credentials grant: client_id = sub = aud = its client ID, typ at+jwt), and proTES relays them to the TES backends with its own per-backend client-credentials tokens, as for all tasks. proTES refuses service clients today: pro_tes/app.py calls FOCA's require_no_service_clients() on startup.
Sibling of #514 (opt-in service client role for production smoke tests): this issue is the core both need (service clients as owners of their tasks, the adapted startup refusal, the audience rule); #514 adds on top what smoke tests need (backend flag, forwarding the client's own token to flagged backends).
Proposal
Opt-in, off by default; nothing changes without service clients.
- Allow list: FOCA's
security.auth.service_clients, each with an explicitissuerandclient_id, mapped to the roleuser(only) insecurity.access_control.client_mapping. - A listed client's own service token may create tasks; the client owns them (
client:<client ID>, also inuser_id) and lists, reads and cancels its own tasks only; it sees no tasks of others and others don't see its tasks; no admin rights. - Tasks are relayed with proTES' own credentials; the client's token is never forwarded.
- Startup refusal adapted: refuse
on_behalf_of_headerand clients withon_behalf_of, clients withoutissuer, clients without the roleuseror with another role, and proTES' own client (PROTES_CLIENT_ID). Warn if a client's ID is no accepted audience. - Audience: identity providers may put only the client's own ID into
aud, so deployments add it tosecurity.auth.audience. That ID is accepted for that client's own service tokens only: other tokens whose only accepted audiences are service-client IDs (e.g., users' tokens obtained by the client, also by token exchange, after which the current identity provider keeps the exchanging client inaud) are rejected with401on all endpoints. - Leaves room for token exchange (feat: exchange user tokens per TES backend #501): an exchanged user token for proTES' audience is a user token and owned by the user; acting for users stays refused.
Acceptance criteria
- Default config: no change; tokens for a client's own audience are rejected.
- A listed client creates tasks and lists, reads and cancels its own; users, other clients and admins can't see or cancel them, and the client can't see theirs.
- The startup checks above, each with a test.
- Tokens for a service client's audience that aren't its own service tokens are rejected on the TES API, the plugin listing and the permissions API.
- Unit and API tests with the mock identity provider; the smoke test (fake identity provider and fake TES backend that requires proTES' token) covers a client's task end to end.
- Docs: access control (new section), configuration, operations, upgrading.
Activity
docs: add FOCA 0.23 and service clients to 0.7.0