The member mail claim at /mail is unreachable — the apex route strips the identity header the mail routes trust, so every member gets 401 #1344

Closed
opened 2026-09-09 04:17:24 +00:00 by ben · 3 comments
Owner

Symptom

A signed-in member opening https://<apex>/mail (MAIL-M1/M2/M2x, DDR 0117, #318) never sees a screen: every /api/mail call answers 401.

Cause

WithMemberMail(c.mailPortal, nil) (control-plane/cmd/control-plane/main.go ~1486) falls back to the header identity resolver, but the apex route is ungated and deliberately strips X-Idss-Identity (internal/clan/frontdoor.go renderPortalRoute, #1094) — so the header is never present and the resolver fails closed. The community session cookie the member DOES hold (idss_session, minted by /authz/callback, Domain=<apex>) is never consulted.

Found by the Portal map's session-substrate research (#1337, docs/research/2026-09-08-portal-session-substrate.md §5 on research/portal-session-substrate).

Fix shape

Pass the gate session resolver (the same gateResolver the IDIP steward routes use via stewardSessionResolver) instead of nil, so /api/mail authenticates on the cookie like every other apex-served member route. Note the IDIP tier stays wrong even after this (<AID>@<apex> address; Claim gated through the resting kanidm orchestrator) — that half belongs to the Portal map (#1336 ticket #1342), not this fix.

Proof

The mail integration test (internal/controlapi/mail_integration_test.go) driven through a cookie-bearing request with no identity header must reach MAIL-M1; a public-path drive leg that opens /mail after sign-in.

## Symptom A signed-in member opening `https://<apex>/mail` (MAIL-M1/M2/M2x, DDR 0117, #318) never sees a screen: every `/api/mail` call answers 401. ## Cause `WithMemberMail(c.mailPortal, nil)` (`control-plane/cmd/control-plane/main.go` ~1486) falls back to the header identity resolver, but the apex route is ungated and deliberately strips `X-Idss-Identity` (`internal/clan/frontdoor.go` `renderPortalRoute`, #1094) — so the header is never present and the resolver fails closed. The community session cookie the member DOES hold (`idss_session`, minted by `/authz/callback`, `Domain=<apex>`) is never consulted. Found by the Portal map's session-substrate research (#1337, `docs/research/2026-09-08-portal-session-substrate.md` §5 on `research/portal-session-substrate`). ## Fix shape Pass the gate session resolver (the same `gateResolver` the IDIP steward routes use via `stewardSessionResolver`) instead of `nil`, so `/api/mail` authenticates on the cookie like every other apex-served member route. Note the IDIP tier stays wrong even after this (`<AID>@<apex>` address; `Claim` gated through the resting kanidm orchestrator) — that half belongs to the Portal map (#1336 ticket #1342), not this fix. ## Proof The mail integration test (`internal/controlapi/mail_integration_test.go`) driven through a cookie-bearing request with no identity header must reach MAIL-M1; a public-path drive leg that opens `/mail` after sign-in.

This was generated by AI during triage.

Agent Brief

Category: bug
Summary: The apex-served member mail claim at /mail returns 401 on every /api/mail call — it's wired with a nil session resolver, so it falls back to the header identity that the ungated apex route deliberately strips.

Verification (confirmed against the tree): The composition root wires the member-mail surface with a nil resolver (WithMemberMail(c.mailPortal, nil)), which falls back to the header identity resolver. The apex portal route (renderPortalRoute) is ungated and strips the identity header on purpose (header_up -X-Idss-Identity, #1094 — nothing upstream vouches for it), so the header is never present and the resolver fails closed → 401. The member DOES hold the community session cookie (idss_session, Domain=<apex>) minted by /authz/callback, but the mail surface never consults it. A concrete resolver already exists to pass: gateResolver (a CookieSessionResolver), the same one the IDIP steward routes use via stewardSessionResolver. internal/controlapi/mail_integration_test.go exists as the proof harness.

Current behavior:
A signed-in member opening https://<apex>/mail (MAIL-M1/M2/M2x, DDR 0117, #318) never reaches a screen — every /api/mail call answers 401, because the mail surface authenticates on a header identity the apex route strips.

Desired behavior:
/api/mail authenticates on the community SSO session cookie (idss_session) the member already holds, exactly like the other apex-served member routes behind the gate resolver. A cookie-bearing request with no identity header reaches MAIL-M1.

Key interfaces:

  • The member-mail wiring (WithMemberMail(service, resolver)) — must be passed the gate session resolver (the SessionResolver the auth gate and IDIP steward routes already use) instead of nil.
  • gateResolver / the CookieSessionResolver — the existing resolver that reads the idss_session cookie; this is the value to thread into the mail wiring.
  • No change to the apex route's header-stripping (#1094) — that stays; the mail surface must stop depending on the stripped header.

Acceptance criteria:

  • internal/controlapi/mail_integration_test.go drives a cookie-bearing request with no identity header through /api/mail and reaches MAIL-M1 (not 401).
  • The member-mail surface is wired with the gate session resolver, not nil, in the composition root.
  • Requests with neither a valid cookie nor a trusted identity still fail closed (401).
  • go build ./..., go vet, and go test ./internal/controlapi/... are green.

Out of scope:

  • The IDIP tier, which stays wrong even after this fix: the <AID>@<apex> address and the Claim gated through the resting kanidm orchestrator. That half belongs to the Portal map (#1336, ticket #1342), not this ticket.
  • Any change to the apex route's identity-header stripping (#1094).
> *This was generated by AI during triage.* ## Agent Brief **Category:** bug **Summary:** The apex-served member mail claim at `/mail` returns 401 on every `/api/mail` call — it's wired with a `nil` session resolver, so it falls back to the header identity that the ungated apex route deliberately strips. **Verification (confirmed against the tree):** The composition root wires the member-mail surface with a `nil` resolver (`WithMemberMail(c.mailPortal, nil)`), which falls back to the header identity resolver. The apex portal route (`renderPortalRoute`) is ungated and strips the identity header on purpose (`header_up -X-Idss-Identity`, #1094 — nothing upstream vouches for it), so the header is never present and the resolver fails closed → 401. The member DOES hold the community session cookie (`idss_session`, `Domain=<apex>`) minted by `/authz/callback`, but the mail surface never consults it. A concrete resolver already exists to pass: `gateResolver` (a `CookieSessionResolver`), the same one the IDIP steward routes use via `stewardSessionResolver`. `internal/controlapi/mail_integration_test.go` exists as the proof harness. **Current behavior:** A signed-in member opening `https://<apex>/mail` (MAIL-M1/M2/M2x, DDR 0117, #318) never reaches a screen — every `/api/mail` call answers 401, because the mail surface authenticates on a header identity the apex route strips. **Desired behavior:** `/api/mail` authenticates on the community SSO session cookie (`idss_session`) the member already holds, exactly like the other apex-served member routes behind the gate resolver. A cookie-bearing request with **no** identity header reaches MAIL-M1. **Key interfaces:** - The member-mail wiring (`WithMemberMail(service, resolver)`) — must be passed the gate session resolver (the `SessionResolver` the auth gate and IDIP steward routes already use) instead of `nil`. - `gateResolver` / the `CookieSessionResolver` — the existing resolver that reads the `idss_session` cookie; this is the value to thread into the mail wiring. - No change to the apex route's header-stripping (#1094) — that stays; the mail surface must stop depending on the stripped header. **Acceptance criteria:** - [ ] `internal/controlapi/mail_integration_test.go` drives a cookie-bearing request with **no** identity header through `/api/mail` and reaches MAIL-M1 (not 401). - [ ] The member-mail surface is wired with the gate session resolver, not `nil`, in the composition root. - [ ] Requests with neither a valid cookie nor a trusted identity still fail closed (401). - [ ] `go build ./...`, `go vet`, and `go test ./internal/controlapi/...` are green. **Out of scope:** - The IDIP tier, which stays wrong even after this fix: the `<AID>@<apex>` address and the `Claim` gated through the resting kanidm orchestrator. That half belongs to the Portal map (#1336, ticket #1342), not this ticket. - Any change to the apex route's identity-header stripping (#1094).

swarm-claim host=matou-dev-server-01 run=20420
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=20420 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #1344 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1344,
  "status": "success",
  "commits": [
    "84858d50"
  ],
  "changed_files": [
    "control-plane/cmd/control-plane/main.go",
    "internal/controlapi/mail_integration_test.go",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "go build ./...",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/controlapi/... ./control-plane/...",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/controlapi/...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "mail_integration_test.go drives a cookie-bearing request with no identity header through /api/mail and reaches MAIL-M1 (not 401)": "internal/controlapi/mail_integration_test.go TestMailHandler_CookieSessionReachesM1WithoutHeader — adds idss_session cookie only (no X-Idss-Identity), GET /api/v1/mail/status returns 200 with status=no-mailbox-yet address=mere@awa.example.nz; PASS in go test run",
    "The member-mail surface is wired with the gate session resolver, not nil, in the composition root": "control-plane/cmd/control-plane/main.go:~1501 WithMemberMail(c.mailPortal, gateResolver) (was nil)",
    "Requests with neither a valid cookie nor a trusted identity still fail closed (401)": "TestMailHandler_CookieSessionReachesM1WithoutHeader no-session leg asserts 401; existing TestMailHandler_NoSessionIsUnauthenticated still green",
    "go build ./..., go vet, and go test ./internal/controlapi/... are green": "all three run green in nix develop .#go-ci (see tests[])"
  },
  "summary": "Wired the member-mail surface with the gate's cookie session resolver so /api/mail authenticates on the idss_session cookie instead of the apex-route-stripped identity header.",
  "blockers": []
}
**close-report** for #1344 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1344, "status": "success", "commits": [ "84858d50" ], "changed_files": [ "control-plane/cmd/control-plane/main.go", "internal/controlapi/mail_integration_test.go", "STATUS.md" ], "tests": [ { "command": "go build ./...", "exit_code": 0 }, { "command": "go vet ./internal/controlapi/... ./control-plane/...", "exit_code": 0 }, { "command": "go test ./internal/controlapi/...", "exit_code": 0 } ], "criteria": { "mail_integration_test.go drives a cookie-bearing request with no identity header through /api/mail and reaches MAIL-M1 (not 401)": "internal/controlapi/mail_integration_test.go TestMailHandler_CookieSessionReachesM1WithoutHeader — adds idss_session cookie only (no X-Idss-Identity), GET /api/v1/mail/status returns 200 with status=no-mailbox-yet address=mere@awa.example.nz; PASS in go test run", "The member-mail surface is wired with the gate session resolver, not nil, in the composition root": "control-plane/cmd/control-plane/main.go:~1501 WithMemberMail(c.mailPortal, gateResolver) (was nil)", "Requests with neither a valid cookie nor a trusted identity still fail closed (401)": "TestMailHandler_CookieSessionReachesM1WithoutHeader no-session leg asserts 401; existing TestMailHandler_NoSessionIsUnauthenticated still green", "go build ./..., go vet, and go test ./internal/controlapi/... are green": "all three run green in nix develop .#go-ci (see tests[])" }, "summary": "Wired the member-mail surface with the gate's cookie session resolver so /api/mail authenticates on the idss_session cookie instead of the apex-route-stripped identity header.", "blockers": [] } ``` </details>
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.

Dependencies

No dependencies set.

Reference
Matou/idss#1344
No description provided.