Skip to content

epic(auth): unify AutoBot + SLM into ONE user store with role-based access (SLM = role-gated view, not a separate userbase) #10193

Open
1 of 6 issues completed

Description

@mrveiss

Intent (product architecture)

AutoBot is one framework with one userbase. The SLM (Service Lifecycle Manager) is a separated UI surface for service management — split out so it doesn't overwhelm ordinary users — but it is the same AutoBot, backed by the same single user store. Access to the SLM/service-management surface is governed by role-based access control, not by a second identity system.

Current state (diverges from intent — verified on a live install)

Today there are two independent user stores + two auth systems:

User app (autobot-backend) SLM (autobot-slm-backend)
User DB autobot_users (AUTOBOT_USERS_DATABASE_URL) slm_users (SLM_USERS_DATABASE_URL)
Code autobot-backend/user_management autobot-slm-backend/user_management (duplicate package)
Auth db_session_context() → autobot_users; single_user falls back to a synthetic-admin bypass (#6838, AUTOBOT_DEV_AUTH_BYPASS) get_slm_session() → slm_users, validated vs SLM_ADMIN_PASSWORD
Proof wrong password → 200 (bypass) wrong password → 401 (real check)

So a user created in one is invisible to the other; credentials, roles, and sessions don't carry across. RBAC scaffolding (Role, Permission, is_platform_admin) already exists in autobot-backend/user_management but the SLM doesn't use it.

Goal

  1. One user store is canonical for all of AutoBot (app + SLM).
  2. RBAC gates the SLM surface: e.g. an operator/admin (service-management) permission unlocks the SLM UI/API; ordinary users authenticate against the same store but lack that permission and see only the app.
  3. One auth/session domain (a token issued by one surface is honored by the other, subject to RBAC).
  4. single_user mode = one real seeded admin in the one store (retire the synthetic-admin bypass divergence).

Open design decisions (need sign-off before build — PRD)

  • Canonical store: adopt autobot_users + autobot-backend/user_management (richer: Role/Permission/MFA) as the single source; SLM authenticates against it. Confirm.
  • How the SLM reaches the shared store: point the SLM's user_management at autobot_users, OR have the SLM delegate auth to a shared identity/auth service exposed by the backend. (Control-plane vs data-plane security isolation tradeoff — see [[architecture_two_backends]].)
  • RBAC model: which role/permission gates SLM access (ADMIN_SYSTEM? a new service_management permission?), and the default role for new/ordinary users.
  • Migration: consolidate existing slm_users accounts into autobot_users (or declare slm_users deprecated); session/token format reconciliation.
  • single_user: seed one admin in autobot_users; both surfaces honor it; remove/disable the #6838 synthetic-admin bypass once real single-user auth works.

Scope (high level — to be decomposed after design sign-off)

  • Collapse the duplicate user_management package to one shared implementation.
  • SLM auth → shared store + RBAC permission gate on SLM routers/UI.
  • DB: one users DB; migration/retirement of slm_users.
  • single_user: real seeded admin; retire synthetic bypass.
  • Tests for cross-surface auth + role gating.

Risks

  • Control-plane/data-plane isolation: the SLM intentionally runs as a separate backend; sharing the user store must not couple them in a way that breaks that boundary or the single_user gating.
  • Live divergence already exists (separate slm_users accounts) — needs a migration story.

Relates to RBAC bootstrap (#9920 track) and the two-backend architecture. No code until the design decisions above are signed off (PRD-first).

Acceptance criteria

  • One identity spans both backends by construction: one token issuer, or the main backend verifying SLM tokens through a published key (JWKS). Equal HS256 secrets maintained by deploy tooling do not count.
  • The SLM's main-backend client stops surfacing a 401 as an error and logs out like every other SLM call: client.setKeepSessionOn401(true) in createAutobotBackendClient() (autobot-slm-frontend/src/composables/useAutobotApi.ts) is removed, along with its test "surfaces a main-backend 401 instead of logging out until epic(auth): unify AutoBot + SLM into ONE user store with role-based access (SLM = role-gated view, not a separate userbase) #10193". The "Test connection" probe keeps its own per-request keepSessionOn401.

Activity

  1. mrveiss commented on Jun 15, 2026

    @mrveiss
    OwnerAuthor

    Added constraint: must work DISTRIBUTED (SLM and user frontend on different machines, still one identity)

    The single userbase cannot assume co-location. The SLM and the user app/frontend must be deployable on separate machines and still behave as one AutoBot with one identity + RBAC. This rules out "both processes just open the same local Postgres" as the only design.

    Design implications (added to the open decisions):

    • Shared identity must be network-reachable from both machines. Two viable patterns:
      • (A) Shared user DB endpoint — one autobot_users Postgres both backends connect to over the network, plus a shared JWT signing key + shared/!distributed session store (Redis) so a token minted on either surface validates on the other. Simpler, but couples both machines to one DB and spreads DB credentials.
      • (B) Shared auth/identity service — the backend exposes auth + RBAC over HTTP; the SLM delegates authentication/authorization to it (validates tokens, checks the service-management permission). Cleaner control-plane/data-plane boundary; the SLM gains a runtime dependency on the auth service being reachable. This extends the existing SLM↔backend service-auth channel (SLM_AUTH_TOKEN, service-JWT/WebSocket from fix(compose): backend→SLM WebSocket 401 — SLM_AUTH_TOKEN missing (node event stream) #9852/fix(config): SLM_AUTH_TOKEN unset causes perpetual WebSocket 403 errors (4400+/day) #7689) rather than inventing a new one.
    • Token validity across machines: whichever pattern, JWTs must be mutually verifiable — single signing key (or JWKS) shared across surfaces; sessions in a shared store, not per-process memory.
    • Must still support co-located single-box AND single_user (the common case) — design has to degrade cleanly to one machine + one seeded admin.
    • Network partition behavior: if the user app's machine can't reach the identity source, define the failure mode (read-only? cached token validation? deny?).

    Recommendation leans toward (B) shared auth service because it preserves the deliberate two-backend control/data-plane split (see [[architecture_two_backends]]) and reuses the service-auth channel that already exists between SLM and backend — but this is exactly the decision to confirm before any build.

  2. mrveiss commented on Jun 15, 2026

    @mrveiss
    OwnerAuthor

    PRD — Unified AutoBot Userbase + RBAC (distributed-capable)

    Status: DRAFT for review. No implementation until sign-off. Author: SecurityEngineer (Opus 4.8).

    1. Problem & intent

    AutoBot is one framework with one userbase. The SLM (Service Lifecycle Manager) is a separated UI surface for service management — carved out so ordinary users aren't overwhelmed — but it is the same AutoBot, over the same identity, with RBAC deciding who sees the service-management surface. The SLM and the user frontend must be deployable on different machines yet behave as one identity (tokens valid on both).

    2. Current state (the gap)

    User app (autobot-backend) SLM (autobot-slm-backend)
    User DB autobot_users slm_users (separate DB)
    Code autobot-backend/user_management duplicate autobot-slm-backend/user_management
    Auth db_session_context(); single_user → synthetic-admin bypass (#6838) get_slm_session() vs SLM_ADMIN_PASSWORD
    RBAC Role/Permission/is_platform_admin exist, used not used
    Two stores, two logins, no shared identity. RBAC primitives already exist app-side.

    3. Goals / non-goals

    Goals: (1) one canonical user store for all of AutoBot; (2) RBAC gates the SLM surface; (3) one auth/session domain valid across machines; (4) single_user = one real seeded admin (retire #6838 bypass); (5) works co-located AND distributed.
    Non-goals (this epic): external IdP/OIDC federation (future), multi-tenant org redesign, MFA changes beyond carrying it into the shared store.

    4. Requirements

    • R1 Single canonical identity store. R2 A user authenticates once; RBAC determines app vs SLM access. R3 A token minted on one surface is honored on the other. R4 SLM access requires a service_management permission; ordinary users lack it. R5 Distributed: SLM and frontend on separate hosts. R6 Co-located + single_user still work (one seeded admin). R7 Defined network-partition behavior. R8 Preserve the control/data-plane boundary between the two backends.

    5. Recommended architecture — Pattern B: shared auth/identity service

    The backend (autobot-backend/user_management, the richer impl) becomes the identity authority, exposing auth + token-validation + RBAC over HTTP. The SLM delegates: it validates incoming tokens and checks the service_management permission via the authority, reusing the existing SLM↔backend service-auth channel (SLM_AUTH_TOKEN, service-JWT/WebSocket from #9852/#7689) rather than a new one.

    Machine A: SLM ──(validate token / check perm, signed service call)──▶ Machine B: backend = identity authority ──▶ autobot_users
    shared JWT signing key (or JWKS) → tokens mutually verifiable; sessions in shared Redis
    

    Why B over A (shared DB endpoint): keeps the deliberate two-backend control/data-plane split; no DB credentials spread to the SLM host; reuses an existing trust channel. Cost: SLM needs the authority reachable at runtime → see partition handling (R7).

    6. Canonical store

    Adopt autobot_users + autobot-backend/user_management as the single source (it has Role/Permission/MFA). Collapse the duplicate SLM user_management to a thin client of the authority. slm_users is migrated then deprecated.

    7. RBAC model

    • New permission service_management (and/or reuse ADMIN_SYSTEM); role operator/admin carries it. Default new users: ordinary user (no SLM access).
    • SLM routers/UI gated by require_permission(service_management). App-only users authenticate fine but are denied SLM routes (403) and the SLM nav is hidden.

    8. Token / session design

    • One signing key (or JWKS endpoint on the authority) so both surfaces verify the same JWTs. Sessions in shared Redis, not per-process memory. Token carries roles/permissions claims; SLM authorizes from claims, revalidates against the authority on a TTL.

    9. single_user

    One real admin seeded in autobot_users at provision; both surfaces honor it; retire the #6838 synthetic-admin bypass once real single-user auth works (or keep it strictly dev-gated). Co-located deploy points the SLM authority at localhost.

    10. Migration

    • Reconcile/import existing slm_users accounts into autobot_users (dedupe by email/username); map SLM admin → service_management role. Provide a one-time migration; mark slm_users read-only then drop after cutover. Session format reconciliation (re-login acceptable).

    11. Network-partition behavior (R7)

    If the SLM can't reach the authority: validate already-issued tokens from cached JWKS/claims up to a short TTL (read-mostly), deny new logins, surface a clear degraded-auth banner. Define TTL + whether destructive SLM actions are blocked while degraded.

    12. Security

    Single signing key custody; authority is now a higher-value target (rate-limit, audit); ensure SLM delegation can't be spoofed (mutual service auth); least-privilege default role; the bypass removal closes the passwordless-admin hole.

    13. Task breakdown (post-approval → child issues)

    1. Extract/confirm the auth-authority API (login, validate, introspect perms) on the backend. 2. service_management permission + role wiring + SLM router/UI gating. 3. SLM user_management → thin delegating client; remove slm_users auth path. 4. Shared signing key/JWKS + shared Redis sessions; cross-surface token validity. 5. single_user seeded admin + retire security(auth): /api/auth/login accepts ANY password for admin user #6838 bypass. 6. slm_users→autobot_users migration + deprecation. 7. Partition/degraded-auth handling. 8. Tests: cross-machine auth, role gating (app-only denied SLM), single_user, partition. 9. Two-machine verification (CI can't cover — needs a real 2-host run).

    14. Risks / open questions


    Requesting review of: Pattern B vs A (§5), canonical store (§6), RBAC permission choice (§7), and partition policy (§11). On approval I'll decompose §13 into child issues under this epic.

  3. mrveiss commented on Jun 15, 2026

    @mrveiss
    OwnerAuthor

    Decision log

    • §6 Canonical store: DECIDED → autobot_users + autobot-backend/user_management is the single canonical source of truth. slm_users + the duplicate autobot-slm-backend/user_management are deprecated and migrated into it. (Canonical-source discipline: one store wins, the other defers.)

    Still open for sign-off: §5 Pattern B (shared auth service) vs A (shared DB endpoint); §7 RBAC permission name; §11 partition policy.

  4. mrveiss commented on Jun 15, 2026

    @mrveiss
    OwnerAuthor

    Decision log (cont.)

    • §5 Identity transport: DECIDED → Pattern B (shared auth service). Chosen as the cleanest + safest: backend is the single identity authority; SLM delegates auth/RBAC over the existing service-auth channel; no DB credentials on the SLM host; preserves the control/data-plane boundary; clean two-machine story.
    • single_user mode: ELIMINATED. There is no more single_user mode. A single-user deployment simply uses a real default admin account seeded in the canonical autobot_users store. This supersedes §9 and removes the security(auth): /api/auth/login accepts ANY password for admin user #6838 synthetic-admin bypass entirely (not just gating it).

    Ripple effects of eliminating single_user (important)

    1. Postgres becomes mandatory for every install (including a single-user box) — provisioning must always stand up autobot_users and seed the default admin. (Aligns with the RBAC-bootstrap direction; AUTOBOT_USER_MODE=single_user is retired.)
    2. The single_user 503-gates become dead code — the Postgres-gating added for single_user (@requires_postgres/postgres_required, telemetry/LLC/thinking-prefs 503 paths: Consolidate + gate Postgres-dependent startup paths for single_user (no WARNING/traceback) #9765, chore(lifespan): extract @requires_postgres decorator — _llc_postgres_available() gate now duplicated across 8 startup steps #9913, telemetry consent modal cannot save in single_user mode — POST /api/settings/telemetry 503 (user management disabled) #10000, LLC + thinking-preferences endpoints 500 in single_user — need API-layer Postgres gate returning clean 503 (#9765 class) #10010) no longer trigger, since Postgres is always present. They can stay as harmless guards initially, then be removed in a follow-on cleanup. No behavior regression.
    3. AUTOBOT_DEV_AUTH_BYPASS (security(auth): /api/auth/login accepts ANY password for admin user #6838) is removed — the passwordless-admin hole closes.

    Open safety nuance — default-admin credential policy (need a choice)

    "Safest" and "default admin account" pull in different directions. Options for the seeded admin's initial credential:

    • (rec) Generated strong password, surfaced once at install (printed by the installer / shown in the wizard), with forced change on first login. Safest; no shipped default password.
    • Fixed admin / installer-set password from a provisioning secret (operator chooses at install).
    • Literal admin/admin only as an explicit dev/test opt-in flag (not the default).
      Recommend the first. Confirm and I'll bake it into the task breakdown.

    Revised single_user task (replaces §13.5)

  5. mrveiss commented on Jun 15, 2026

    @mrveiss
    OwnerAuthor

    Decision log (final)

    • Default-admin credential policy: DECIDED → installer-set password (no shipped default), + a login-time SAFETY CHECK that complains when the password is unsafe (weak/common/too-short/equals a known default). Behavior: allow login but surface a clear warning nudging a change (soft complaint, not a hard block). The operator sets the admin password at install via a provisioning input/secret.

    All design decisions are now made (Pattern B; canonical autobot_users; single_user eliminated → seeded default admin; installer-set creds + unsafe-password login warning). Carried defaults for detail items: §7 a new service_management permission gates the SLM surface; §11 partition = cached token validation with a short TTL. Proceeding to decompose into child issues.

  6. mrveiss commented on Jun 15, 2026

    @mrveiss
    OwnerAuthor

    Decision refinement

    • The admin password is set by the operator during SLM deployment (setup wizard / provisioning input) — that value seeds the canonical default admin in autobot_users at install. No shipped default; login still complains if the chosen password is unsafe.
  7. mrveiss commented on Jun 15, 2026

    @mrveiss
    OwnerAuthor

    Task tree (decomposition) — build order + dependencies

    Phase 1 — foundation (parallel):

    Phase 2 — wire the SLM in (after Phase 1):

    Phase 3 — single-user/provisioning + migration:

    Phase 4 — resilience + cleanup + verification:

    Decisions locked: Pattern B (shared auth service) · canonical autobot_users · single_user eliminated → seeded default admin (password set at SLM deploy, unsafe-password login warning) · service_management RBAC gate · partition = cached-TTL validation.

    Suggested start: #10195 + #10196 (foundation), since everything else depends on them. Build in increments, one PR per child, respecting the PR-queue limit.

  8. mrveiss commented on Jun 15, 2026

    @mrveiss
    OwnerAuthor

    Note: admin-password collection already exists (install.sh)

    install.sh already collects a user-set admin password (wizard/flag/env) with a strong random fallback and no shipped default (preserved on reinstall). The unified-userbase work reuses this — #10199 just re-points the already-collected password at the canonical autobot_users admin and removes single_user. Confirmed by mrveiss.

  9. mrveiss commented on Jun 15, 2026

    @mrveiss
    OwnerAuthor

    Decision log (Phase 1 crypto)

  10. mrveiss commented on Jun 15, 2026

    @mrveiss
    OwnerAuthor

    Progress: Phase 1 — #10196 DONE

    PR #10205 merged (23cd8847e). RS256+JWKS authority foundation is live on Dev_new_gui. Next: #10195 (authority validate/introspect + RBAC-list API).

  11. mrveiss commented on Jun 16, 2026

    @mrveiss
    OwnerAuthor

    Progress: Phase 1 COMPLETE ✅

    The backend is now the full identity authority: RS256-signed tokens, public JWKS, token-validation with revocation, RBAC metadata. Next: Phase 2 — #10197 (SLM verifies via JWKS + delegates revocation/RBAC) and #10198 (service_management permission gates the SLM surface).

  12. 25 remaining items

  13. mrveiss commented on Oct 27, 2026

    @mrveiss
    OwnerAuthor

    Maintainer decision (2026-10-27): unify the two frontends into one app. The SLM views become a role-gated back-office section of the main frontend, shown to admins and to granted advanced users, with one login and one session on the one user store this epic delivers. The two backends stay. A frontend-unification epic is being filed and will depend on this one.

  14. mrveiss commented on Oct 27, 2026

    @mrveiss
    OwnerAuthor

    Today the SLM's main-backend 401 does not log out. This epic flips it.

    This comes from the code review on PR #19819 (#12363 step 2). The maintainer decision recorded above (one identity, so a 401 from either backend logs out) is the target. On current main it cannot be enforced safely, because the main backend accepts an SLM token only by coincidence of configuration:

    • SLM tokens: HS256, signed with SLM_SECRET_KEY (autobot-slm-backend/config.py:288-289, services/auth.py:98-102), with no iss/aud.
    • Main backend: verifies HS256 with AUTOBOT_JWT_SECRET, then SECRET_KEY, then the config file, then a generated value (autobot-backend/auth_middleware.py:86-120, :440-444). It has no SLM key, no token exchange and no introspection.
    • Why it works today: Ansible sets AUTOBOT_JWT_SECRET equal to SLM_SECRET_KEY (bug(service-auth): backend→SLM WebSocket fails (403 handshake + 4001 token); JWT secret not distributed #10400: roles/backend/templates/backend.env.j2:50-51, roles/backend/tasks/main.yml:140-159, playbooks/update-all-nodes.yml). A bare or dev install gets a generated secret instead, so every SLM call to the main backend returns 401, and a logout-on-401 client would log the user out on every page.

    So #19819 sets keepSessionOn401 on the whole main-backend client: a main-backend 401 shows an error and never ends the session. The one-identity work has to remove the coincidence (one issuer, or JWKS) and then flip that setting. Both are now acceptance criteria on this epic.

  15. added
    needs-structureMissing goal milestone, matching phase label or native parent (#19522)
    on Oct 28, 2026
  16. github-actions commented on Oct 28, 2026

    @github-actions
    Contributor

    needs-structure cleared: goal milestone, matching phase label and native parent (or sub-issues) are all present (#19522).

  17. mrveiss commented on Nov 1, 2026

    @mrveiss
    OwnerAuthor

    Maintainer decision (2026-11-02), replacing this epic's single user store and the one-app plan in #19829: the SLM stays separate and is installed first. The SLM owns the first login and has its own users from the first install. Once the main app is installed it links to those users, so a person has one identity and SLM access is a grant. SLM login keeps working while the main app is down. The goal section above is superseded; the link's design is with the maintainer and will be recorded here.

  18. mrveiss commented on Nov 1, 2026

    @mrveiss
    OwnerAuthor

    Maintainer decision (2026-11-02), the link's design: the main app becomes the record for a person once it's installed, and SLM login from the copy has no time limit.

    • Before the main app is installed: the SLM is the record and creates the first admin.
    • At install: a person-to-person link table is added. Existing ids stay, so memberships and reviewers aren't rewritten. The first SLM admin gets a main-app user and company membership, otherwise they can't inherit anything.
    • After the link: the main app is the record for password and active state. The SLM keeps a copy of the password hash and active state for people with an SLM grant. Nobody without a grant is stored in the SLM.
    • SLM access is a grant on the person.
    • While the main app is down: SLM login works from the copy, and password changes are refused.
    • Tokens stay signed and verified across the two.
    • Existing installs: people already in both stores are matched by a proposal an admin approves, with an audit trail, never automatically (Umbrella: SLM Data hygiene page — detect and safely clean up orphaned data across services #17038).

    Not verified, for the build:

    #10200's copy from the SLM into the main app no longer fits as written and needs rescoping to this design. #19829's dependency on it needs re-planning too.

  19. added
    phase:M1.6Docker: secure defaults, honest startup and three modes
    on Nov 1, 2026
  20. removed
    needs-structureMissing goal milestone, matching phase label or native parent (#19522)
    on Nov 1, 2026
  21. mrveiss commented on Nov 8, 2026

    @mrveiss
    OwnerAuthor

    Follow-up for this work: the SLM File Browser message tools.admin.fileBrowserTool.downloadUnauthorized (en.json, added in #21087) currently tells the user to "Sign in there and try again", which cannot help while SLM-issued tokens are rejected by the main backend admin check. Reword it as part of this change once the shared identity lands, then verify a real SLM download and close #21029.

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

    advancedarea: auth-rbacWave 2 · cluster E — Auth, identity & RBAC canonbackendfrontendphase:M1.6Docker: secure defaults, honest startup and three modessecuritytestingumbrellaEpic/umbrella tracking issue grouping member issues

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions