Skip to content

Multi-tenant Phase F — user chip, scoped state copy, admin impersonation #98

Closed

Description

@thomas-stegemann

Phase F of the multi-tenant rollout — the UI affordances that turn "multi-user works under the hood" into "users feel it" (#28).

Why

Phases A–E (#28) give Bowire the auth foundation, per-user state, and the SCIM/migration plumbing. From the workbench UI today nothing changes when you log in: no name, no avatar, no "you're acting as X" indicator. That's a credibility cliff — an operator demoing to a Compliance team can't even point at the screen and say "yes, that's me, and these recordings are private to me".

Cruise ship can't leave preview without this layer.

Proposal — three integrated affordances

1. User chip in the topbar

Right cluster, between the AI drawer toggle and the About button:

[●  api.…] [env ▾] [⟲] [☼] [✨3] [👤 Alice ▾] [?] [⚙]
  • Avatar (Gravatar / OIDC picture claim / generated initials fallback).
  • Hover or click → popover with:
    • Full name + email.
    • Role (admin / user from SCIM Groups).
    • "Sign out" link.
    • "Switch user" link (visible only to admin role).
  • In single-user / standalone-CLI mode, the chip is hidden — there's nobody to identify.

2. Per-user-scoped state visibility

Recordings, environments, collections, favorites all live under the calling user's slot already (Phase B). What's missing is a visible "this is yours" cue:

  • Recording list header reads "Your recordings (N)" instead of "Recordings (N)" in multi-tenant mode.
  • Empty-state copy distinguishes "you have no recordings yet" from "this server has no recordings yet".
  • A footer line on every per-user-state surface: "Stored under your slot · admin@example.com" — links to Settings → My account.

3. Admin → user impersonation ("Switch user")

For support / debugging. Admin clicks "Switch user" → modal with a SCIM-backed user picker → confirmation ("You'll see Alice's recordings, environments, collections. Actions you take will be logged as 'admin acting as Alice'.") → workbench reloads in impersonation mode.

Impersonation banner: yellow row above the topbar — "Acting as Alice (alice@example.com) · End session" with the end-session click reverting to the admin's own slot.

Every action under impersonation writes to ~/.bowire/.audit.jsonl with acting_as set. Surfaces in the SCIM Phase C audit log.

Sub-decisions

  • Avatar source priority: OIDC picture claim → Gravatar → generated initials. Configurable per-tenant via SCIM urn:ietf:params:scim:schemas:extension:bowire:2.0:User:avatarSource.
  • Sign-out in the chip popover defers to the configured IBowireAuthProvider.SignOutUrl — single-sign-out via the IdP works the same way for everyone.
  • Switch-user UX intentionally requires explicit modal confirmation: every "act as X" path in real systems gets misused; making it a conscious action with a banner reduces both error and audit ambiguity.
  • Mobile: chip collapses to avatar-only at narrow widths; popover stays full.

Acceptance

  • Multi-tenant mode renders the user chip in the topbar right cluster.
  • Single-user / standalone-CLI mode hides the chip (no nobody to identify).
  • Chip popover shows name, email, role, sign-out; admin role sees an extra "Switch user" link.
  • Recording / env / collection list headers + empty states surface "yours" wording in multi-tenant mode.
  • Admin impersonation banner is yellow, unmissable, with a one-click end-session.
  • Every action while impersonating writes an audit-log entry with both the admin's and the target user's ids.
  • Switch-user picker uses the SCIM Users list with type-ahead + role-filter.

Refs #28 (Phase F — UI affordances)

Activity

  1. moved this to Backlog in Bowireon Jun 15, 2026
  2. thomas-stegemann commented on Aug 29, 2026

    @thomas-stegemann
    MemberAuthor

    First half shipped in 0da37b0 — identity

    Split deliberately. The chip and the role are visible plumbing with no security surface; switch-user is a mechanism for one person to see another person's work, and that belongs in its own commit with its own review rather than riding along with an avatar.

    The seam

    IBowireUserDirectory in Core, because the answer comes from two places. A token carries a name and an e-mail address; whether somebody administers the install comes from the directory that provisions them, which lives in a package Core does not reference. ClaimsUserDirectory answers from the token alone; ScimUserDirectory (in Kuestenlogik.Bowire.Scim) replaces it and reads group membership against Bowire:Scim:AdminGroup.

    That also makes #96's Groups surface something that is actually read, rather than stored and ignored.

    A role claim in the token confers nothing, on purpose. It is only as good as the mapping that produced it, and Bowire cannot check that mapping; group membership in the provisioned directory is something the operator configured deliberately and can audit. Without a directory that knows about roles, nobody is an administrator — rather than everybody. There is a test for exactly that.

    GET /api/me

    Mapped unconditionally. A workbench that has to know the deployment shape before it can ask who it is serving asks the question wrong: a single-user install answers multiTenant: false, and the chip stays away.

    The chip

    Its own fragment, appended to the topbar through a typeof guard, so a single-user install carries the code and shows no control — no placeholder, no empty circle. Three details are load-bearing:

    • The raw subject is the last resort for a name, never the first. For most providers it is a GUID. Initials fall back name → local part of the address → subject, and only a subject with nothing alphanumeric in it yields ?.
    • Sign out appears only when there is somewhere to send them. IBowireAuthProvider.SignOutUrl is a new default-implemented member returning null; a scheme with no sign-out (an API key, a proxy terminating auth upstream) has nothing the workbench can do about it, and a link that clears nothing teaches people to believe they have signed out when they have not.
    • The popover says the work is stored separately, because that is the question somebody actually opens it to answer.

    Verification

    15 node tests over the fragment, 16 over ClaimsUserDirectory and the initials fallback, 13 over ScimUserDirectory (role, name precedence, the picker's backing search). Full CI green — all seven workflows.

    Acceptance

    • Multi-tenant mode renders the user chip in the topbar right cluster.
    • Single-user / standalone-CLI mode hides the chip.
    • Popover — name, email, role and sign-out are in. The "Switch user" link is not: it would be a control that does nothing until the second half lands, which is the kind of facade worth avoiding.
    • "Yours" wording on recording / environment / collection headers and empty states. Not started. It is a small change per surface but touches several fragments, and it reads better as one pass than as a line smuggled into this commit.
    • Impersonation banner — second half.
    • Audit entries naming both identities — second half.
    • Switch-user picker — the backing is shipped and tested (IBowireUserDirectory.Search, SCIM-backed, excludes deprovisioned identities because acting as one would show an empty workbench and look like data loss). The picker itself is second half.

    The second half, and one thing worth deciding first

    The transport for "I am acting as X" is the decision that matters, so recording the intent here before building it:

    A cookie the server re-checks on every request, rather than a signed token. The workbench has ~70 direct fetch call sites and no central wrapper, so a header would mean touching all of them or monkey-patching global fetch — and Bowire's own purpose is sending requests to other people's services, which makes a global header patch exactly the wrong instinct.

    A cookie rides along automatically, and the authority never comes from it: on every request the server re-derives the real caller from the token and re-asks the directory whether they are an administrator. A forged cookie therefore buys nothing unless you already are one. That is a stronger property than a signed token, which is only as good as the key and the moment it was minted.

    BowireTenancy.Enter already nests, which is what impersonation needs — the scope was written with this in mind.

  3. moved this from Backlog to In progress in Bowireon Aug 29, 2026
  4. thomas-stegemann commented on Aug 29, 2026

    @thomas-stegemann
    MemberAuthor

    Second half shipped in 5a2707f — impersonation

    The claim the design rests on

    The cookie says whose slot to open. It never says who may open it. Who may is re-derived from the caller's own token on every request and re-checked against the directory. So:

    • A stolen or forged cookie buys nothing unless you already administer the install — there is a test that hands the exact cookie to a third party and asserts they are served their own slot.
    • An administrator who is demoted stops impersonating on their next request, with nothing having to expire.
    • A caller who is not an administrator has the cookie taken away rather than ignored, so the workbench stops showing a banner for something that is not happening.

    That is a stronger property than a signed token, which is only as good as its key and as the moment it was minted.

    A cookie rather than a header because the workbench has ~70 direct fetch call sites and no central wrapper. Patching global fetch in a tool whose purpose is sending requests to other people's services is the wrong instinct; a cookie rides along on same-origin requests and needed no client change at all.

    Not __Host- prefixed, deliberately: that prefix requires Secure, and an embedded host on plain HTTP inside a network would then fail to set the cookie silently, with impersonation appearing to do nothing. The prefix would only stop a sibling host writing a value that is re-authorised anyway.

    Every check reads the real caller

    While impersonating, the tenancy scope names the target. A check written against it would decide that an administrator acting as an ordinary user is an ordinary user — and they could not even end their own session. Ending one is not admin-gated at all, for the same reason: somebody who lost the role mid-session must still be able to get back.

    The record

    audit/actions.jsonl, naming both identities on every line: the start, the end, and every request that changed something. Reads are not recorded — burying the handful of lines that matter under a day of navigation is how an audit trail stops being readable. The DELETE that ends a session is skipped too, because it is already written as end; recording both put one event in the log twice in two vocabularies (that was a real bug, caught by the test that counts the lines).

    audit joins users and scim as install state excluded from the #97 migration and reserved as a BOWIRE_INSTANCE name.

    The surfaces

    The banner is the first child of the flex shell, so it takes its own row and pushes the workbench down rather than covering the topbar — this is a state of the whole session, not a notice about the content below it. Its exit is explicitly exempt from the overflow rules: somebody stuck in a session with the way out clipped is the one failure this cannot have.

    No second hop is offered from inside a session. Two levels of "acting as" is how somebody loses track of whose workbench they are looking at; getting out is the banner's job.

    Verification

    27 node tests over the fragment and 18 through a TestServer over the authorisation itself — including the stolen-cookie case, the demoted-administrator case, and that a read is not written to the log. Full CI green.

    Acceptance

    • Multi-tenant mode renders the user chip in the topbar right cluster.
    • Single-user / standalone-CLI mode hides the chip.
    • Chip popover shows name, email, role, sign-out; admin role sees an extra "Switch user" link.
    • "Yours" wording on recording / environment / collection headers and empty states. Still not started — a small change per surface, but it touches several fragments and reads better as one pass.
    • Admin impersonation banner is yellow, unmissable, with a one-click end-session.
    • Every action while impersonating writes an audit entry with both ids — with one deliberate narrowing: reads are excluded. "Every action" taken literally means every navigation, and the result is a log nobody reads.
    • Switch-user picker — SCIM-backed with type-ahead, and each row shows whether that person is an administrator. The role filter is not built.

    One thing I decided not to build, and why

    The role filter. A directory where two people are administrators and ninety are members gives you a control that filters nothing on one setting and hides everything on the other — a control added to satisfy a line rather than to do a job. The role is shown on every row, which is what somebody scanning the list actually needs.

    If you want it anyway it is a toggle and one filter call in renderUserPickerRows, with no server change. Say the word.

  5. moved this from In progress to Done in Bowireon Aug 29, 2026
  6. thomas-stegemann commented on Aug 29, 2026

    @thomas-stegemann
    MemberAuthor

    Closed by 0cbb3ae

    The last piece: on a multi-tenant instance the workspace sections now read "Your recordings (12)" and, when empty, "You have no recordings yet" — the difference between an empty account and an empty server, which is the first thing a new person on a shared install wonders. Single-user installs are untouched, and the wording stays neutral until /api/me has answered, because a label flashing "Your" into a single-user workbench would be a claim about the deployment nobody checked.

    Two helpers in the identity slice rather than the phrasing repeated at three call sites, so the surfaces cannot drift apart. 31 node tests over the fragment now; CI green.

    Two things this issue asked for that were deliberately not built

    Closing with them stated plainly rather than quietly, so the next reader is not surprised:

    The per-surface footer — "Stored under your slot · someone@example.com" on every per-user-state surface. The account chip now sits in the topbar and the section label itself says "Your". A third statement of the same fact on every list is repetition rather than reassurance.

    The role filter in the switch-user picker. In a directory where two people are administrators and ninety are members, one setting filters nothing and the other hides everything — a control that satisfies a line rather than doing a job. The role is shown on every row instead, which is what somebody scanning the list needs. If you want it anyway: a toggle and one filter call in renderUserPickerRows, no server change.

    Both are one small commit each if you disagree — say so and I will add them.

    Phase F, end to end

    • Identity (0da37b0) — IBowireUserDirectory, GET /api/me, the chip. A role claim in a token confers nothing; group membership in the provisioned directory does, which is what made Multi-tenant Phase C — SCIM 2.0 provisioning endpoints #96's Groups surface something that is actually read.
    • Impersonation (5a2707f) — cookie as parameter, authority re-derived per request, both identities in audit/actions.jsonl, a banner whose exit cannot be clipped away.
    • Ownership wording (0cbb3ae) — this commit.

    With #96 and #97 already in, the only part of #28 still open is per-identity plugin installs (#284), which is a privilege decision rather than a storage one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions