#1098 steward gate locks the founder out: the SSO session carries preferred_username, but the operator check keys on the AID #1101

Closed
opened 2026-09-01 05:31:24 +00:00 by matou-build-agent · 1 comment

The failure

Drive 20260901T051005Z (commit 953c9280) reds at leg create-credential — 25 green, 1 red, no skips (artifacts/verdict.json, artifacts/legs.json:118-124):

[data-field="credentials-panel"] is absent because the control API REFUSED: GET /api/v1/idip/stewards/rotation → 403 ({"code":"not_operator","message":"only a steward can do this — ask one of your community's stewards"}). The surface has shipped; this is not a ledger skip (#1094).

The refusal watch is telling the truth and the leg is right to red. The founder — the community's only steward, signed in at their own front door one leg earlier — is being refused every steward act by the #1098 authorization gate.

Evidence

The caller is authenticated: leg operator-session is green, and establishOperatorSession (app/tests/e2e/fixtures/idip.ts:575-580) asserts the idss_session cookie exists before returning. A missing session would be 401 (internal/controlapi/logstream.go:148-151); this is 403, i.e. the authorizeSteward branch (internal/controlapi/idip_authz.go:134-137), reached only after the identity resolved.

The caller is genuinely a steward on the roster. logs/droplet-journal.txt:699:

idip roster: founder registered aid=EPxkx5Y3pejlqt9maxKQO9Ks913Sm3tKS6LHRlZTi_dC role=operator said=EKFX1SgMUjW3vadqrTs2VmaOsxdSaZOyC-3zeGo95ze8

RosterAdapter.Register anchors the issuance and confirms the receipt in the same act when SAID is set (internal/keria/adapter.go:196-201), and the drive's own page snapshot confirms the settled row: "role: operator · recorded on the roster (operator, active)" (artifacts/journey.idip-.../error-context.md, S7x carrier row). active ⇒ Credential.issued() (internal/keria/standing.go:70-80). So IsOperator("EPxkx5Y3…") would answer true.

The identity handed to the check is not that AID. The gate's OIDC client prefers preferred_username and falls back to sub only when it is empty:

// internal/controlapi/oidcprovider.go:210-213
identity := info.PreferredUsername
if identity == "" {
    identity = info.Sub
}

On the IDIP path the bridge emits both: sub = AID and preferred_username = the handle (internal/idp/storage.go:528-533, ADR 0196). The founder's handle is the e-mail local-part — usernameFromOperator (app/src/components/founding/FoundingStandup.vue:815-819) — and this drive's operator e-mail is drive@example.nz (state/founding-state.json → /draft/details/operator/email), so the session's sub claim is the string "drive".

The steward gate then asks the roster for that string:

  • StewardResolver.Authorize → s.Operators.IsOperator(ctx, identity) (internal/controlapi/idip_authz.go:103-115)
  • RegistryOperators.IsOperator → o.reg.Member(aid) (internal/keria/operators.go:56)
  • Registry.Member looks up by AID only — indexOfAID(st.Members, aid) (internal/keria/registry.go:534-544)

No row for "drive" → false → ErrNotOperator → 403.

The assumption is stated explicitly in two places and is simply not true of what the gate hands over:

  • internal/controlapi/idip_authz.go:79-81 — "it resolves the community SSO session (the identity IS the member's AID — the bridge sets sub = AID, ADR 0196)"
  • control-plane/cmd/control-plane/main.go:1062-1065 — "the gate's own session cookie identifies the caller (sub = AID, ADR 0196)"

Why the seam did not catch it

Every #1098 test seeds the session with an AID-shaped identity by hand and never crosses the OIDC exchange: internal/controlapi/idip_steward_session_test.go:141-145,158-160 and control-plane/cmd/control-plane/idip_steward_resolver_test.go:18-22,38 both use fakeOperators{operators: map[string]bool{"Etama": true}} against a cookie minted for "Etama". The username/AID mismatch is invisible on that seam — it lives in discoveryOIDC.Exchange, which no steward test exercises.

Blast radius (all one defect, no separate fault)

Every route family wired with stewardResolver refuses the founder identically — credentials (#1078), steward rotations (#1085), standing/suspend (#1082), removal (#1083) (control-plane/cmd/control-plane/main.go:1095-1122) — plus the logs surface, which routes through the same operatorAuthed → authorizeSteward path (internal/controlapi/logstream.go:146-158). The remaining ten credentials-tail legs cannot arm until this is plugged.

Suspected layer

Control plane, IDIP identity path. The defect is the boundary between internal/controlapi/oidcprovider.go (what claim becomes the SSO session's sub) and internal/keria/operators.go (what key the roster is asked for).

What plugging it needs — and the ruling it is blocked on

Two fixes are available and they are not interchangeable. This needs a ruling on which claim is the IDIP path's session identity before code is written:

  1. Make the bridge-path gate session carry sub (the AID). Give discoveryOIDC a preferSubject flag set by NewBridgeOIDC (internal/controlapi/oidcprovider.go:81-92), leaving kanidm on preferred_username. Small and it matches every comment already in the tree — including internal/keria/standing.go:84-88, which describes the deny projection as "keyed by AID (the bridge's OIDC subject)". But the same identity feeds /authz/gate → member.Orchestrator.GateDecision (control-plane/cmd/control-plane/main.go:926; internal/member/komiti.go:567-588), which every service route on the gateway front door sits behind via forward_auth (internal/clan/frontdoor.go:429). Flipping it changes what Denied() and isOperator() see for files.<apex>, chat, code — legs door, branded-login, oidc-admin, files-healthy and member-sign-in are currently green with the username, and this drive stands up a paid droplet to find out.
  2. Resolve the identity to a roster row inside the steward gate, leaving the session identity untouched: look up by AID, fall back to RosterEntry.Username. Contained to the steward surfaces — but nothing enforces username uniqueness on the roster (Registry.Join is idempotent on the AID alone, internal/keria/adapter.go:186-193), so this keys authorization on a non-unique field. That is not a change to make quietly.

Whichever wins, the fix must land with a test that crosses the exchange — one that feeds a userinfo body carrying both sub (AID) and preferred_username (handle) and pins which one reaches IsOperator. That is the pin the current seam is missing, and its absence is why #1098 shipped green.

Recommend recording the ruling as an amendment to ADR 0074/0212 (which claim the community SSO session's sub carries, per identity path) rather than fixing it in one file and leaving the two comments quoted above still asserting the other thing.

Note for the healer loop: this signature (c1881a2de870) already absorbed one self-heal — a0f8350f (create-credential waited for the S1i card on the S7i screen). That fix was correct and the leg advanced past it; this is the next, deeper fault at the same leg, not a regression of that one.

drive 20260901T051005Z red at create-credential: reachability probe failed: [data-field="credentials-panel"] is absent because the control API REFUSED: GET /api/v1/idip/stewards/rotation → 403 ({"code":"not_operator","message":"only a steward can
evidence: /home/dev/swarm/Matou/idss/test-results/drive-idip/20260901T051005Z on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured

## The failure Drive `20260901T051005Z` (commit `953c9280`) reds at leg `create-credential` — 25 green, 1 red, no skips (`artifacts/verdict.json`, `artifacts/legs.json:118-124`): > `[data-field="credentials-panel"]` is absent because the control API REFUSED: `GET /api/v1/idip/stewards/rotation` → 403 (`{"code":"not_operator","message":"only a steward can do this — ask one of your community's stewards"}`). The surface has shipped; this is not a ledger skip (#1094). The refusal watch is telling the truth and the leg is right to red. The founder — the community's *only* steward, signed in at their own front door one leg earlier — is being refused every steward act by the #1098 authorization gate. ## Evidence The caller is authenticated: leg `operator-session` is green, and `establishOperatorSession` (`app/tests/e2e/fixtures/idip.ts:575-580`) asserts the `idss_session` cookie exists before returning. A missing session would be 401 (`internal/controlapi/logstream.go:148-151`); this is 403, i.e. the `authorizeSteward` branch (`internal/controlapi/idip_authz.go:134-137`), reached only *after* the identity resolved. The caller is genuinely a steward on the roster. `logs/droplet-journal.txt:699`: ``` idip roster: founder registered aid=EPxkx5Y3pejlqt9maxKQO9Ks913Sm3tKS6LHRlZTi_dC role=operator said=EKFX1SgMUjW3vadqrTs2VmaOsxdSaZOyC-3zeGo95ze8 ``` `RosterAdapter.Register` anchors the issuance and confirms the receipt in the same act when `SAID` is set (`internal/keria/adapter.go:196-201`), and the drive's own page snapshot confirms the settled row: *"role: operator · recorded on the roster (operator, active)"* (`artifacts/journey.idip-.../error-context.md`, S7x carrier row). `active` ⇒ `Credential.issued()` (`internal/keria/standing.go:70-80`). So `IsOperator("EPxkx5Y3…")` would answer **true**. **The identity handed to the check is not that AID.** The gate's OIDC client prefers `preferred_username` and falls back to `sub` only when it is empty: ```go // internal/controlapi/oidcprovider.go:210-213 identity := info.PreferredUsername if identity == "" { identity = info.Sub } ``` On the IDIP path the bridge emits **both**: `sub` = AID and `preferred_username` = the handle (`internal/idp/storage.go:528-533`, ADR 0196). The founder's handle is the e-mail local-part — `usernameFromOperator` (`app/src/components/founding/FoundingStandup.vue:815-819`) — and this drive's operator e-mail is `drive@example.nz` (`state/founding-state.json` → `/draft/details/operator/email`), so the session's `sub` claim is the string `"drive"`. The steward gate then asks the roster for that string: - `StewardResolver.Authorize` → `s.Operators.IsOperator(ctx, identity)` (`internal/controlapi/idip_authz.go:103-115`) - `RegistryOperators.IsOperator` → `o.reg.Member(aid)` (`internal/keria/operators.go:56`) - `Registry.Member` looks up by **AID only** — `indexOfAID(st.Members, aid)` (`internal/keria/registry.go:534-544`) No row for `"drive"` → `false` → `ErrNotOperator` → 403. The assumption is stated explicitly in two places and is simply not true of what the gate hands over: - `internal/controlapi/idip_authz.go:79-81` — *"it resolves the community SSO session (the identity IS the member's AID — the bridge sets sub = AID, ADR 0196)"* - `control-plane/cmd/control-plane/main.go:1062-1065` — *"the gate's own session cookie identifies the caller (sub = AID, ADR 0196)"* ## Why the seam did not catch it Every #1098 test seeds the session with an AID-shaped identity by hand and never crosses the OIDC exchange: `internal/controlapi/idip_steward_session_test.go:141-145,158-160` and `control-plane/cmd/control-plane/idip_steward_resolver_test.go:18-22,38` both use `fakeOperators{operators: map[string]bool{"Etama": true}}` against a cookie minted for `"Etama"`. The username/AID mismatch is invisible on that seam — it lives in `discoveryOIDC.Exchange`, which no steward test exercises. ## Blast radius (all one defect, no separate fault) Every route family wired with `stewardResolver` refuses the founder identically — credentials (#1078), steward rotations (#1085), standing/suspend (#1082), removal (#1083) (`control-plane/cmd/control-plane/main.go:1095-1122`) — plus the logs surface, which routes through the same `operatorAuthed` → `authorizeSteward` path (`internal/controlapi/logstream.go:146-158`). The remaining ten credentials-tail legs cannot arm until this is plugged. ## Suspected layer Control plane, IDIP identity path. The defect is the boundary between `internal/controlapi/oidcprovider.go` (what claim becomes the SSO session's `sub`) and `internal/keria/operators.go` (what key the roster is asked for). ## What plugging it needs — and the ruling it is blocked on Two fixes are available and they are **not** interchangeable. This needs a ruling on which claim is the IDIP path's session identity before code is written: 1. **Make the bridge-path gate session carry `sub` (the AID).** Give `discoveryOIDC` a `preferSubject` flag set by `NewBridgeOIDC` (`internal/controlapi/oidcprovider.go:81-92`), leaving kanidm on `preferred_username`. Small and it matches every comment already in the tree — including `internal/keria/standing.go:84-88`, which describes the deny projection as *"keyed by AID (the bridge's OIDC subject)"*. **But** the same identity feeds `/authz/gate` → `member.Orchestrator.GateDecision` (`control-plane/cmd/control-plane/main.go:926`; `internal/member/komiti.go:567-588`), which every service route on the gateway front door sits behind via `forward_auth` (`internal/clan/frontdoor.go:429`). Flipping it changes what `Denied()` and `isOperator()` see for `files.<apex>`, `chat`, `code` — legs `door`, `branded-login`, `oidc-admin`, `files-healthy` and `member-sign-in` are currently green *with the username*, and this drive stands up a paid droplet to find out. 2. **Resolve the identity to a roster row inside the steward gate**, leaving the session identity untouched: look up by AID, fall back to `RosterEntry.Username`. Contained to the steward surfaces — **but** nothing enforces username uniqueness on the roster (`Registry.Join` is idempotent on the AID alone, `internal/keria/adapter.go:186-193`), so this keys *authorization* on a non-unique field. That is not a change to make quietly. Whichever wins, the fix must land with a test that crosses the exchange — one that feeds a userinfo body carrying **both** `sub` (AID) and `preferred_username` (handle) and pins which one reaches `IsOperator`. That is the pin the current seam is missing, and its absence is why #1098 shipped green. Recommend recording the ruling as an amendment to ADR 0074/0212 (which claim the community SSO session's `sub` carries, per identity path) rather than fixing it in one file and leaving the two comments quoted above still asserting the other thing. **Note for the healer loop:** this signature (`c1881a2de870`) already absorbed one self-heal — `a0f8350f` (`create-credential` waited for the S1i card on the S7i screen). That fix was correct and the leg advanced past it; this is the next, deeper fault at the same leg, not a regression of that one. drive `20260901T051005Z` red at `create-credential`: `reachability probe failed: [data-field="credentials-panel"] is absent because the control API REFUSED: GET /api/v1/idip/stewards/rotation → 403 ({"code":"not_operator","message":"only a steward can ` evidence: `/home/dev/swarm/Matou/idss/test-results/drive-idip/20260901T051005Z` on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured <!-- rehearsal-sig: c1881a2de870 -->
Owner

Fixed — 2c7ece8e. Your diagnosis was exact.

The gate's OIDC client took userinfo's preferred_username as the session identity (internal/controlapi/oidcprovider.go:210). Correct for kanidm, whose ledger is keyed by username; wrong for IDIP, whose roster's stable key is the AID — the subject the bridge publishes as sub (internal/idp/storage.go:524, "openid → sub = AID"). So the founder's session resolved to a handle no roster lookup could find, and #1098's gate refused the community's only steward.

NewBridgeOIDC now takes the identity from sub; the kanidm shape keeps preferred_username. The split is per-IdP exactly as formEncodeCredentials already is, and each still falls back to the other claim rather than failing a sign-in outright.

TestBridgeOIDC_IdentityIsTheAID drives both shapes off ONE userinfo carrying both claims, and is proven red against the pre-fix source (it returned "tama").

Two things worth recording rather than smoothing over:

  1. The #1098 close overclaimed. It said the founder was "verified not locked out". That check covered the two ends — founder registration (Role: RoleOperator, receipt-confirmed) and the bridge's userinfo (sub = AID) — but never the gate client's extraction between them, which is exactly where the mismatch lived. The claim was stronger than the evidence behind it.
  2. This is why the probe-honesty fix earned its keep. The previous probe would have recorded credentials-panel has not shipped, which reads as swarm backlog — and, being a skip rather than a red, would have left the drive GREEN with the whole credentials tail unrun. Instead the leg red in one run carrying the door's own words, which is how this was found and diagnosed the same hour.
**Fixed — `2c7ece8e`.** Your diagnosis was exact. The gate's OIDC client took userinfo's `preferred_username` as the session identity (`internal/controlapi/oidcprovider.go:210`). Correct for kanidm, whose ledger is keyed by username; wrong for IDIP, whose roster's stable key is the AID — the subject the bridge publishes as `sub` (`internal/idp/storage.go:524`, "openid → sub = AID"). So the founder's session resolved to a handle no roster lookup could find, and #1098's gate refused the community's only steward. `NewBridgeOIDC` now takes the identity from `sub`; the kanidm shape keeps `preferred_username`. The split is per-IdP exactly as `formEncodeCredentials` already is, and each still falls back to the other claim rather than failing a sign-in outright. `TestBridgeOIDC_IdentityIsTheAID` drives both shapes off ONE userinfo carrying both claims, and is proven red against the pre-fix source (it returned `"tama"`). Two things worth recording rather than smoothing over: 1. **The #1098 close overclaimed.** It said the founder was "verified not locked out". That check covered the two ends — founder registration (`Role: RoleOperator`, receipt-confirmed) and the bridge's userinfo (`sub = AID`) — but never the gate client's extraction *between* them, which is exactly where the mismatch lived. The claim was stronger than the evidence behind it. 2. **This is why the probe-honesty fix earned its keep.** The previous probe would have recorded `credentials-panel has not shipped`, which reads as swarm backlog — and, being a skip rather than a red, would have left the drive GREEN with the whole credentials tail unrun. Instead the leg red in one run carrying the door's own words, which is how this was found and diagnosed the same hour.
ben closed this issue 2026-09-01 05:35:12 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#1101
No description provided.