chat: the operator is a Mattermost system admin — the reconciler runs mmctl --local roles system-admin <user> for operators and roles member on revoke (sign-in already OIDC; Team Edition has no claim-to-role mapping) #1543

Closed
opened 2026-09-16 18:55:14 +00:00 by ben · 3 comments
Owner

Spec

#1535 — Ben's ruling (2026-09-16): adding a member in the control panel grants them access to every member service the control panel deployed; adding a member as an operator gives them admin access to all services. One community sign-in, every door, no second login, no hidden per-app credential.

internal/clan/chat.go:308-309 grants system_admin to the SERVICE identity only. Team Edition's OIDC (GitLab-shaped) carries no admin role mapping, so the mapping is the reconciler's, over the local-mode socket the port already uses (chat.go:71).

Build

  • Port ReconcileRole: mmctl --local roles system-admin <username> for operators, mmctl --local roles member <username> on revoke; the username is the person id (the OIDC username claim the port links). A person who has never signed in has no Mattermost account yet — record "applies at first sign-in" and re-run from the first-login observer (authgate.go:68 FirstLoginObserver) or the next reconcile.
  • Members: default role, no change.

Acceptance

  • Reconcile test over a fake mmctl; operator sees the System Console; revoke removes it.

Security invariant (every header-trusting port, #1167): a port that trusts X-Idss-Identity lands header_up -X-Idss-Identity on its client-protocol exempt paths in the SAME commit (the gated handle overwrites the header from the gate's answer; the exempt handle has no such vouch — internal/clan/frontdoor.go:684 is the strip, renderProxy(..., exempt=true)). A port that speaks real OIDC needs no strip but MUST keep its claim/scope maps on the pattern files.go:822-946 sets: audience idm_all_persons (every person signs in), the admin bit keyed to ONE kanidm group via a collision-proof claim.

Also

Declare the port's posture and implement its ReconcileRole from the reconciler ticket #1537; the P6-S7/P4-S5 card line reads from it.

## Spec #1535 — Ben's ruling (2026-09-16): **adding a member in the control panel grants them access to every member service the control panel deployed; adding a member as an operator gives them admin access to all services.** One community sign-in, every door, no second login, no hidden per-app credential. `internal/clan/chat.go:308-309` grants `system_admin` to the SERVICE identity only. Team Edition's OIDC (GitLab-shaped) carries no admin role mapping, so the mapping is the reconciler's, over the local-mode socket the port already uses (`chat.go:71`). ## Build - Port `ReconcileRole`: `mmctl --local roles system-admin <username>` for operators, `mmctl --local roles member <username>` on revoke; the username is the person id (the OIDC username claim the port links). A person who has never signed in has no Mattermost account yet — record "applies at first sign-in" and re-run from the first-login observer (`authgate.go:68 FirstLoginObserver`) or the next reconcile. - Members: default role, no change. ## Acceptance - Reconcile test over a fake mmctl; operator sees the System Console; revoke removes it. **Security invariant (every header-trusting port, #1167):** a port that trusts `X-Idss-Identity` lands `header_up -X-Idss-Identity` on its client-protocol exempt paths in the SAME commit (the gated handle overwrites the header from the gate's answer; the exempt handle has no such vouch — `internal/clan/frontdoor.go:684` is the strip, `renderProxy(..., exempt=true)`). A port that speaks real OIDC needs no strip but MUST keep its claim/scope maps on the pattern `files.go:822-946` sets: audience `idm_all_persons` (every person signs in), the admin bit keyed to ONE kanidm group via a collision-proof claim. ## Also Declare the port's posture and implement its `ReconcileRole` from the reconciler ticket #1537; the P6-S7/P4-S5 card line reads from it.

swarm-claim host=bens-mac-04 run=25422
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=bens-mac-04 run=25422 (automated multi-host claim — lowest live claim id works this ticket)

Ruled by agent under ADR 0174 — veto anytime.

The ticket specifies mmctl --local roles system-admin <user> "over the local-mode socket the port already uses (chat.go:71)". The chat port (internal/chatsvc) does NOT use that socket — it is a control-plane REST client authenticated as the admin service identity; chatLocalSocket (chat.go:71) belongs to the clan render's on-node oneshots, which the control plane cannot reach. So mmctl --local is not implementable from the port.

Ruling: implement ReconcileRole over the Mattermost REST roles endpoint — PUT /api/v4/users/{id}/roles with system_user system_admin (operator) / system_user (member) — which is exactly the call mmctl roles system-admin makes under the hood, authenticated as the admin identity (itself system_admin → holds manage_roles). Reads current roles first and only PUTs on divergence (idempotent); a never-signed-in person (no auto-provisioned account yet) is a truthful no-op, the role applying at first sign-in.

Why two-way: revertible by a later commit (e.g. to shell mmctl from an on-node oneshot instead), and proved by the reconcile test (TestPort_ReconcileRolePromotesOperatorAndRevokes: grant→system_admin, revoke→system_user, idempotent, never-signed-in no-op) — not on the one-way-door list (no personal credential, no security-posture widening, no member-facing trust accept, no data destruction, no spend).

Also ruled (scope): the port declares the komiti construct team (ADR 0076 "Chat: team") but ApplyRoleMapping stays a truthful no-op — Team Edition carries no group-to-team membership sync. Tracked as follow-up #1550; this ticket ships only the operator→system_admin role reconciler it asks for.

**Ruled by agent under ADR 0174 — veto anytime.** The ticket specifies `mmctl --local roles system-admin <user>` "over the local-mode socket the port already uses (chat.go:71)". The chat **port** (`internal/chatsvc`) does NOT use that socket — it is a control-plane REST client authenticated as the admin service identity; `chatLocalSocket` (`chat.go:71`) belongs to the clan render's on-node oneshots, which the control plane cannot reach. So `mmctl --local` is not implementable from the port. **Ruling:** implement `ReconcileRole` over the Mattermost REST roles endpoint — `PUT /api/v4/users/{id}/roles` with `system_user system_admin` (operator) / `system_user` (member) — which is **exactly** the call `mmctl roles system-admin` makes under the hood, authenticated as the admin identity (itself system_admin → holds `manage_roles`). Reads current roles first and only PUTs on divergence (idempotent); a never-signed-in person (no auto-provisioned account yet) is a truthful no-op, the role applying at first sign-in. **Why two-way:** revertible by a later commit (e.g. to shell mmctl from an on-node oneshot instead), and proved by the reconcile test (`TestPort_ReconcileRolePromotesOperatorAndRevokes`: grant→system_admin, revoke→system_user, idempotent, never-signed-in no-op) — not on the one-way-door list (no personal credential, no security-posture widening, no member-facing trust accept, no data destruction, no spend). **Also ruled (scope):** the port declares the komiti construct `team` (ADR 0076 "Chat: team") but `ApplyRoleMapping` stays a truthful no-op — Team Edition carries no group-to-team membership sync. Tracked as follow-up **#1550**; this ticket ships only the operator→system_admin role reconciler it asks for.

close-report for #1543 — status success

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

envelope
{
  "issue": 1543,
  "status": "success",
  "commits": [
    "2c0a18afc72c919706555b04f2d46cf8de989f38"
  ],
  "changed_files": [
    "STATUS.md",
    "internal/chatsvc/chatsvc.go",
    "internal/chatsvc/chatsvc_test.go"
  ],
  "tests": [
    {
      "command": "go build ./...",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/chatsvc/",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/chatsvc/ ./internal/member/... ./internal/memberorbit/... ./internal/monitor/...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Reconcile test over a fake mmctl; operator sees the System Console; revoke removes it": "internal/chatsvc/chatsvc_test.go TestPort_ReconcileRolePromotesOperatorAndRevokes — grant PUTs system_user system_admin (f.systemAdmin(ana) true = System Console), revoke PUTs system_user (systemAdmin false); idempotent both sides; TestPort_ReconcileRoleNoAccountIsNoOp covers never-signed-in. ReconcileRole in internal/chatsvc/chatsvc.go over PUT /api/v4/users/{id}/roles (the REST call mmctl roles system-admin makes)",
    "Members: default role, no change": "ReconcileRole with operator=false sets memberRoles (system_user); RoleMapping MemberRole = member",
    "Declare the port's posture (P6-S7/P4-S5 card line reads from it)": "chatsvc.Port.RoleMapping() returns MappingReconciler, Construct team, SignIn oidc, OperatorRole system_admin, MemberRole member — TestPort_RoleMappingReconcilerOperatorIsSystemAdmin",
    "Security invariant (#1167): a real-OIDC port keeps its posture, no header strip needed": "chat speaks real OIDC (SignInOIDC); no X-Idss-Identity trust in chatsvc, so no exempt-path strip is owed; the operator admin bit is keyed to the roles reconciler, not a header"
  },
  "summary": "The chat port declares reconciler-mapped posture and reconciles an operator to a Mattermost system_admin (member to default) over the admin REST roles endpoint.",
  "blockers": []
}
**close-report** for #1543 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1543, "status": "success", "commits": [ "2c0a18afc72c919706555b04f2d46cf8de989f38" ], "changed_files": [ "STATUS.md", "internal/chatsvc/chatsvc.go", "internal/chatsvc/chatsvc_test.go" ], "tests": [ { "command": "go build ./...", "exit_code": 0 }, { "command": "go vet ./internal/chatsvc/", "exit_code": 0 }, { "command": "go test ./internal/chatsvc/ ./internal/member/... ./internal/memberorbit/... ./internal/monitor/...", "exit_code": 0 } ], "criteria": { "Reconcile test over a fake mmctl; operator sees the System Console; revoke removes it": "internal/chatsvc/chatsvc_test.go TestPort_ReconcileRolePromotesOperatorAndRevokes — grant PUTs system_user system_admin (f.systemAdmin(ana) true = System Console), revoke PUTs system_user (systemAdmin false); idempotent both sides; TestPort_ReconcileRoleNoAccountIsNoOp covers never-signed-in. ReconcileRole in internal/chatsvc/chatsvc.go over PUT /api/v4/users/{id}/roles (the REST call mmctl roles system-admin makes)", "Members: default role, no change": "ReconcileRole with operator=false sets memberRoles (system_user); RoleMapping MemberRole = member", "Declare the port's posture (P6-S7/P4-S5 card line reads from it)": "chatsvc.Port.RoleMapping() returns MappingReconciler, Construct team, SignIn oidc, OperatorRole system_admin, MemberRole member — TestPort_RoleMappingReconcilerOperatorIsSystemAdmin", "Security invariant (#1167): a real-OIDC port keeps its posture, no header strip needed": "chat speaks real OIDC (SignInOIDC); no X-Idss-Identity trust in chatsvc, so no exempt-path strip is owed; the operator admin bit is keyed to the roles reconciler, not a header" }, "summary": "The chat port declares reconciler-mapped posture and reconciles an operator to a Mattermost system_admin (member to default) over the admin REST roles endpoint.", "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.

Reference
Matou/idss#1543
No description provided.