Skip to content

#789: an owner of a service client cannot approve or reject what it filed (identity.clientOwners) - #801

Open
ephico2real2 wants to merge 2 commits into
mainfrom
fix/789-client-owners
Open

ephico2real2 wants to merge 2 commits into
mainfrom
fix/789-client-owners

Conversation

@ephico2real2

Copy link
Copy Markdown
Owner

Closes #789
Closes #798
Part of #18

What this does

docs/01, "Approval of record": the approver is "not an owner of the svc client that asked". ApprovalLedger had the check, and RequestRepo.ledger gave it no owners because cmapi had no record of them. Built to the owner's decision on #789 (2026-12-01):

  • identity.clientOwners in instance.yaml: {<clientId>: [usernames or groups]}. An entry starting with / is a Keycloak group by full path (as the groups claim carries it); anything else is a username (Keycloak's default user profile refuses / in a username). A bad value stops the start (core/identity/owners.py, core/config.py).
  • Resolved when the client sends the request, stored with it. Usernames are resolved to sub through the existing DirectoryProvider (view-users; no new Keycloak privilege) and stored in the request's requester record as clientOwners beside submittedBySub; never in a response (public_record). A later change of the setting does not move who may decide a request already filed, as with the requirement and the group path. No migration (JSONB).
  • :approve and :reject refuse an owner (by sub, or by a group of the decider's token) with 409 self-approval and write nothing, unless the rule has selfApproval: true (RequestRepo.ledger, ApprovalLedger._eligible).
  • An unknown username is never dropped: the client's request is refused with 500 internal-error and the log line client_owner_unknown (OWASP SCP: "Access controls should fail securely"). Usernames with no directory stop the start. The API's start looks each username up once and logs client_owner_unknown first.
  • A client without an entry keeps today's behaviour, and is named in client_without_owners: at the start for the clients cmapi can know of (approval-rules.yaml requester.clients, and clients that filed for another person before), otherwise the first time it sends onBehalfOf (once per process).
  • A requester lookup with Keycloak unreachable answers 500 internal-error, not 503 idp-unavailable #798 (sev:low, found while building): a requester or owner lookup with Keycloak unreachable and the name not cached answered 500 internal-error (unhandled DirectoryUnavailable); it now answers 503 idp-unavailable with retryAfter 30, like GET /directory/users. Fixed here because it is in the lines this change edits (Pipeline.requester_for).

Decisions, options not taken and sources (fetched 2026-12-01): docs/reviews/2026-12-01-issue-789/design.md.

Tests

Service test_client_owners_789.py: before (the two defect sites as on main) 6 failed, 6 passed: the owners kim (username) and bob (group) got 200 on :approve and :reject, and the directory-down case 500; after, 12 passed. Core test_client_owners_789.py: before (main's ledger) 1 failed; after, 15 passed. Existing files re-run one at a time, all passed: test_reject_decision_779_780 8, test_review_c_authz 13, test_operations_review_774 20, test_idempotency_caller_592 18, test_openapi_render_337 8, test_api_standard 177, test_config_twice_keys_781 84; core test_approvals 40, test_identity_metadata 21. Full suites: CI. Output: docs/reviews/2026-12-01-issue-789/tests-before-after.md.

No migration: the owners live in the requester JSONB. Not tested: a real Keycloak (the directory is InMemoryDirectory), CRC and kind.

Docs

docs/14 (step 5 and the problem table; the "What is not built" row for #789 removed), docs/18 (the new key), docs/16 (the requester record), docs/GLOSSARY (client owner). docs/01 unchanged: it is the design. Citations: scripts/doc-citations.py --check 0 problems.

Who wrote what

Every commit of this pull request was written by Opus 5.5 at high (the implementer). One model family so far: the adversarial review (security: both reviewers) is the coordinator's next step.

…em on :approve and :reject

instance.yaml identity.clientOwners maps a client ID to usernames and Keycloak group paths (the owner's decision on #789,
2026-12-01). A username is resolved to its sub through the directory when the client sends a request, and stored with the
request beside submittedBySub (clientOwners, never in a response); a group is compared with the decider's token.
RequestRepo.ledger passes both to ApprovalLedger, so an owner gets 409 self-approval and nothing is written, unless the
rule has selfApproval: true.

A username the directory does not know refuses the request (500 internal-error, log client_owner_unknown); usernames with
no directory stop the start. A client that sends onBehalfOf with no entry keeps the rule from before and is named in
client_without_owners: at the start for the clients cmapi knows of, otherwise on its first onBehalfOf. A directory that
cannot be reached during a requester's or an owner's lookup answers 503 idp-unavailable instead of escaping as 500.
…design record and the tests before and after

The proof test runs :approve and :reject as separate cases, so each shows its own 200 before the fix. docs/16's requester row
names clientOwners. docs/reviews/2026-12-01-issue-789/ holds the decisions with their sources (fetched 2026-12-01) and the
output of the service and core files before and after.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant