Skip to content

Multi-tenant data model + SCIM (Phase B) #28

Closed

Description

@thomas-stegemann

Builds on: #31, #32 — multi-tenant SCIM extends the auth foundation.


Once Bowire knows who's calling (Phase A: auth-provider SPI + OIDC plugin, both shipped), the next ceiling is "everyone shares one ~/.bowire/". For real multi-user installs each authenticated identity needs its own slice of state — recordings, environments, collections, flows, plugin installs.

Phases

Phase Status What ships
Phase A — Auth-provider SPI + OIDC plugin ✅ shipped IBowireAuthProvider, OIDC plugin, UseBowireAuth middleware, --auth-provider CLI flag.
Phase B (Phase 2 of this issue) — IBowireUserStore seam ✅ shipped on main IBowireUserStore + BowireUserContext static facade; EnvironmentStore, RecordingStore, CollectionStore, FlowStore, PluginManager, PluginUpdateCheckService, schema-hints all route through the seam. Standalone single-user mode keeps the flat ~/.bowire/ layout by binding to a synthetic "default" user.
Phase C - SCIM 2.0 endpoints shipped (#96) Kuestenlogik.Bowire.Scim serves /scim/v2/Users + /scim/v2/Groups with discovery, bearer auth, eq/pr/and/or filtering and 1-based paging, in a sibling package that mounts only when Bowire:Scim:Enabled says so. Deactivating an identity is enforced rather than recorded: the person is refused at the door and their slot is moved aside, reversibly, until PurgeAfter closes. PATCH handles both the Okta and the Entra dialects. A userName index makes provisioning linear rather than quadratic, and listing pages before it stamps locations. The live round-trips against a real Okta org and Entra tenant are #639, deferred to v2.7 — what remains there is evidence, not code.
Phase D — Per-user plugin installs shipped (#284) Two OS tiers: the machine-wide %ProgramData%\Bowire\plugins / /var/lib/bowire/plugins an admin manages, and the running account's overlay on top. Loader, workbench listing, update check and sidecar discovery all walk them through one precedence rule. Per-identity installs were deliberately not built: plugins load into the shared server process and share the host's own assemblies, so "your own plugins" would arrive together with "everyone else's code runs beside your data". The intent split into the two questions it actually contained — who may change the install (an administrator, #636; it had been open to every authenticated identity) and what an individual sees (hidden-protocols.json in their own slot, #638). The defect underneath both: disabled-plugins.json was written per identity while its effect was process-wide, and now lives at the storage root where that effect lands. For installs that genuinely need per-identity plugins the answer is a process per identity, documented in docs/setup/multi-user.md.
Phase E - Migration path shipped (#97) ScopedBowireUserStore plus BowireTenancy give each authenticated identity a slot under <storage root>/users/<slug>/ - the implementation Phase B named but never shipped, and without which there was nothing for a migration to migrate into. BowireUserMigrator then offers to copy a single-user install's state into that slot, once per identity, recorded in the slot itself. Copies rather than moves; excludes what is not a person's state rather than listing what is; stages beside the slot and moves it into place last. Reversible from Settings and from bowire users migrate <subject> --undo.
Phase F - UI affordances shipped (#98) An account chip that names who is signed in and whether they administer the install, read from the provisioned directory rather than from a role claim. Administrators can look at another identity's workbench: the cookie names whose slot, the authority is re-derived from the caller's own token on every request, and both identities land in audit/actions.jsonl. Lists on a shared instance say whose they are.

Downstream consumers of the IBowireUserStore seam (Phase B)

The seam already enables:

Anything new that wants user-scoped disk state goes through BowireUserContext.GetUserPath(filename) — no direct Path.Combine(home, ".bowire", ...) allowed.

Tracked in ROADMAP.md.

Activity

  1. added this to the milestone on Jun 1, 2026
  2. moved this to Next up in Bowireon Jun 1, 2026
  3. modified the milestones: , v1.8 on Jun 3, 2026
  4. thomas-stegemann commented on Jun 4, 2026

    @thomas-stegemann
    MemberAuthor

    Phase 1 landed (commit bdf662f).

    Shipped:

    • IBowireUserStore interface + DefaultBowireUserStore (legacy single-user layout).
    • BowireUserContext static facade -- stores call through it for path resolution.
    • EnvironmentStore pilot: still lands at ~/.bowire/environments.json in single-user mode (zero behaviour change for current installs); the path is now seam-resolved so the multi-tenant variant can swap in later.

    Open follow-ups for this issue:

    • Migrate RecordingStore, CollectionStore (collections), FlowStore, plugin install path through the same seam. Same one-line shape as EnvironmentStore; staged across follow-up commits.
    • AsyncLocal-backed request-aware IBowireUserStore -- pulls HttpContext.User.FindFirst(ClaimTypes.NameIdentifier) and routes to ~/.bowire-server/users/<sub>/.
    • SCIM 2.0 endpoints (/scim/v2/Users + /scim/v2/Groups) per RFC 7644.
    • Per-user plugin installs (system-wide tier + per-user overlay).
    • Migration path: single-user ~/.bowire/ -> calling user's slot in ~/.bowire-server/.

    Issue stays open.

  5. thomas-stegemann commented on Jun 5, 2026

    @thomas-stegemann
    MemberAuthor

    Phase 2 landed (commit 39b71d9).

    Migrated through the IBowireUserStore seam:

    • RecordingStore (~/.bowire/recordings.json)
    • DefaultUserSchemaHintsPath (~/.bowire/schema-hints.json)
    • PluginUpdateCheckService.CachePath (~/.bowire/state/update-check.json)

    All four user-state stores (Environment + Recording + Collection + the cache) plus the schema-hints path now route through BowireUserContext.GetUserPath. Single-user installs see unchanged paths; multi-tenant Phase C can drop in an AsyncLocal resolver without touching the stores again.

    Held for Phase C:

    • ~/.bowire/plugins/ -- 'Per-user plugin installs (system-wide tier + per-user overlay)' is its own checklist item; half-state migration would defeat the seam's purpose.
    • Proxy CA dir -- machine-scoped (OS trust store), not user-scoped.
    • AsyncLocal request-aware IBowireUserStore impl + SCIM 2.0 endpoints + migration path.
  6. 8 remaining items

  7. changed the issue type fromtoon Jun 7, 2026
  8. changed the issue type fromtoon Jun 7, 2026
  9. added a commit that references this issue on Jun 9, 2026
  10. thomas-stegemann commented on Jun 10, 2026

    @thomas-stegemann
    MemberAuthor

    Status nach Wide-Audit (10.06.2026)

    Phase A (Authentifizierungsbasis) + Phase B (Data-Model + Tenant-Isolation in IBowireUserStore) shipped. Open: Phase C (SCIM 2.0 endpoints — #96), Phase D (per-user plugins), Phase E (Single-User → Multi-Tenant Migration — #97), Phase F (User-Chip + Impersonation — #98).

  11. added this to the v2.6 milestone on Jun 24, 2026
  12. thomas-stegemann commented on Jun 24, 2026

    @thomas-stegemann
    MemberAuthor

    Audit-Sweep 2026-06-24 — Phase B geliefert; Epic bleibt offen.

    Phase A + B sind auf main geliefert:

    • src/Kuestenlogik.Bowire/Auth/IBowireUserStore.cs — IBowireUserStore + DefaultBowireUserStore + BowireUserContext (statische Fassade)
    • EnvironmentStore.cs:31 / RecordingStore.cs:33 / CollectionStore.cs:39 — alle über GetUserPath()
    • src/Kuestenlogik.Bowire.Ai/BowireAiUserConfigStore.cs — AI-Settings (AI Settings UI: pick provider + model from the workbench (#25 follow-up) #63) persistiert über die Seam

    Die verbleibenden Phasen sind als eigene Issues ausgelagert und laufen unter v2.6 weiter:

    Dieses Issue bleibt als Tracking-Epic offen, bis C–F geliefert sind.

  13. thomas-stegemann commented on Aug 28, 2026

    @thomas-stegemann
    MemberAuthor

    Phase D shipped on main, CI green on 31d628e2.

    BowireStorageScope.Machine already modelled the tier — the same scope #616 added after Kuestenlogik/Surgewave#157, where an admin installed a plugin, the tool confirmed it, and the broker never saw it because ~ meant two different profiles. So this phase was mostly about who reads it.

    Finding and loading (f7212662). BowirePluginRoot.EnumeratePackages() walks both tiers, user first, and yields each package id once. Four readers go through it — the loader, the workbench listing, the daily update check and sidecar discovery — so the overlay rule is stated once rather than re-decided in four places, which is how the readers in #549 came to disagree. On the loader the precedence lands for free: it already skipped a package id it had loaded, so the machine-tier twin arrives second and is skipped as AlreadyLoaded.

    The surface (d0e6e186). Uninstall used to look in one directory and report "not installed" about anything absent from it — for a machine-wide plugin the one thing it certainly is not, since it is loaded, listed and working. CLI and endpoint now recognise the case, refuse, and name the directory and the command that would work. The endpoint answers 403 rather than shelling out: reaching the CLI would either repeat that misleading message or, running elevated, remove the plugin for every account on the host from a button the user thought applied to themselves. In the workbench those rows read like bundled ones — dimmed, actions disabled, with a title saying why — and the Update tooltip names the way out that exists: install from the catalogue, and your copy takes precedence.

    Two decisions worth recording:

    • No --system flag. --plugin-dir already targets a directory, so an elevated bowire plugin install <id> --plugin-dir /var/lib/bowire/plugins is the administrator's path — and the same command the refusal prints. A second flag would have spelled one thing two ways.
    • An explicitly named directory stays alone. --plugin-dir /tmp/isolated is an operator saying which plugins are in play; adding a machine tier they did not ask for would make an isolated run stop being isolated. BowirePluginOptions carries IsExplicit so the loader can pass that along instead of trusting that some earlier call pushed the answer into Apply.

    17 tests across the two commits, including the case every existing fixture creates: BOWIRE_DATA_DIR collapses all scopes onto one directory, where a naive two-pass walk lists every package twice.

    Remaining in this issue: Phase C (SCIM endpoints) and Phase E (migration).

  14. thomas-stegemann commented on Sep 1, 2026

    @thomas-stegemann
    MemberAuthor

    Where the umbrella stands

    Five of six phases are closed. The table above is updated: Phase D is shipped (#284), with the part that changed rather than shipped written into the row rather than left implied.

    Phase
    A — auth-provider SPI + OIDC closed (#31, #32)
    B — IBowireUserStore seam on main
    C — SCIM 2.0 endpoints open (#96)
    D — plugin tiers closed (#284), with #636 and #638 out of it
    E — migration path closed (#97)
    F — UI affordances closed (#98)

    So this closes when #96 does, and #96 has three unchecked boxes. Only one of them actually needs something I cannot get to:

    • Okta + Azure AD provisioning round-trips green — needs credentials for a real tenant. Genuinely blocked on the operator.
    • Pagination + filtering at scale (10k users, ≤500 ms warm) — not blocked. It is a benchmark against the file-per-record store, and the answer may well be "no, not at that shape", which is worth knowing before a customer finds out. Nobody has run it.
    • IBowireUserStore provisioning side-effect — mostly built and unverified rather than missing. Deactivation archives the slot (Archive/Restore), purge deletes it, and every mutation appends to scim/events.jsonl. The one part that does not match the wording is creating a user: the slot is created lazily on first write rather than eagerly on provisioning. That is arguably better — no empty directory for every provisioned identity who never signs in — and the security property holds either way, because the deactivation gate reads the record and not the directory. But the box says "creating a SCIM user creates the disk slot", so either the code or the criterion should move, and that is a decision rather than an oversight.

    Two of the three are workable without a tenant. Leaving this open and pointing at #96.

  15. thomas-stegemann commented on Sep 1, 2026

    @thomas-stegemann
    MemberAuthor

    Six phases, and the two that turned out to be different questions

    All six are shipped. The table above is current.

    Phase
    A — auth-provider SPI + OIDC plugin #31, #32
    B — IBowireUserStore seam on main
    C — SCIM 2.0 endpoints #96
    D — plugin tiers #284, and #636 / #638 out of it
    E — migration path #97
    F — UI affordances #98

    Two of them did not ship what they were written to ship, and both are worth carrying forward as a lesson rather than a footnote.

    Phase D asked for per-identity plugin installs. It could not have them, and the reason is structural: plugins.Load() runs before the host is built, plugins contribute to the process-wide container and map endpoints at build time, and the load context shares the host's own assemblies with them by design. "Your own plugins" would have arrived together with "everyone else's code runs beside your data". The intent split into the two questions it actually contained — who may change the install (an administrator; it had been open to every authenticated identity, which made it a privilege-escalation path) and what an individual sees (a preference in their own slot, nowhere near an execution path). Installs that genuinely need per-identity plugins get a process per identity, documented rather than approximated.

    Phase C's last box asked for eager slot creation. The code creates the slot on first write, and that is better: 10 000 provisioned people would otherwise mean 10 000 empty directories. The criterion moved, with a test pinning the behaviour so the rewording is checked rather than asserted.

    Underneath both sat the same shape of defect, found by asking where state's effect lands rather than where its file sits: disabled-plugins.json was written per identity while unloading a plugin swapped the registry every session reads, so the last person to touch it decided for everybody.

    What is not claimed

    SCIM has not been driven by a live Okta org or Entra tenant — #639, v2.7. The surface is complete and tested against both dialects' fixtures; the evidence from a real directory is scheduled, not done.

    Closing.

  16. moved this from Next up to Done in Bowireon Sep 1, 2026
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