Skip to content

auth: the backend spells one admin gate three ways (two require_admin copies beside auth_rbac.require_role) — consolidate #16333

Closed
1 of 2 issues completed

Description

@mrveiss

Found while reviewing #16259. This doesn't block it.

Where the helpers are

  • autobot-backend/auth_rbac.py:244: require_role(*roles), the canonical role guard.
  • autobot-backend/api/feature_flags.py:54: a local async def require_admin(...).
  • autobot-backend/transcriber/deps.py:73: a new def require_admin(request), added by security(auth): authenticate every transcriber route, and stop anonymous callers owning every recording (#15758) #16259. It wraps caller_is_admin, which reads request.state.user.is_admin. The router-level authenticate sets that value from autobot_shared.auth.permissions.is_admin_role.
  • autobot-slm-backend/services/auth.py:312: require_admin, in the SLM's own auth. That's a separate service.

So the backend makes one admin decision but spells it three ways. Nothing stops a fourth copy.

Proposal

  • Route every backend admin gate through auth_rbac.require_role, or through one require_admin defined next to it.
  • Make feature_flags.py and transcriber/deps.py call it, fail-closed: 403 when there's no identity, or when the identity isn't an admin.
  • Decide the SLM's copy explicitly. Keep it separate with the reason recorded, or merge it if the two services share the auth path.

Acceptance criteria

  • autobot-backend has one admin-gate definition, and both call sites use it.
  • Both routes keep their 403 behaviour, both for no identity and for a non-admin identity. Their existing tests pass unchanged.
  • A guard fails any new local def require_admin in autobot-backend.
  • The SLM copy's status is decided and recorded here.

Activity

  1. modified the milestones: Backlog, v0.14.0 on Sep 12, 2026
  2. added
    needs-structureMissing goal milestone, matching phase label or native parent (#19522)
    on Oct 31, 2026
  3. github-actions commented on Oct 31, 2026

    @github-actions
    Contributor

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

  4. removed
    needs-structureMissing goal milestone, matching phase label or native parent (#19522)
    on Nov 3, 2026
  5. mrveiss commented on Nov 3, 2026

    @mrveiss
    OwnerAuthor

    Measurement: which internal callers reach which admin gate

    Method: static analysis of current main. Each client call that sends the internal service key is resolved to its backend route and that route's gate. No host logs were read, so this is what the code can call, not what was observed calling. Anything gated outside dependency injection or the handler body would read as none or get_current_user-only. The none rows and a sample of the rest were spot-read.

    Callers:

    1. The SLM frontend, through the SLM's backend proxy. The proxy checks for an SLM admin session, adds the key, and also forwards the user's own token.
    2. The SLM backend's own proxies.
    3. The SLM node agent.
    4. Deployment roles.
    5. An enterprise-enable script.
    6. Backend self-calls.

    193 calls by gate:

    Gate Calls Admits the key alone?
    check_admin_permission 108 yes
    get_current_user only (auth_middleware) 30 yes (returns a synthetic admin)
    no gate found 14 n/a
    service principal (/api/v2/secrets/system) 8 yes, as a scoped service principal (separate mechanism)
    agent visibility 5 no (403)
    tenant context (user management) 4 no (401)
    require_role("admin","superadmin") 4 no
    require_settings_admin (wraps check_admin_permission) 2 yes
    check_file_permissions 2 no
    unresolved 16 11 have no backend route; 5 target the SLM, not the backend

    What this means for the ruling:

    • 156 of the 193 calls come from the SLM frontend through the proxy. Those carry the human admin's own token as well, so under option (b) a human admin keeps access through the role check.
    • The 4 require_role routes (orphan storage, the orphan list and repair, the shared-links admin list) already work only through that human token, never through the key.
    • Under (b) the change is the 108 + 30 routes that accept the key with no human token at all.
    • The key-only callers found are:
      • the system-vault secrets routes, which use the service-principal mechanism and are unaffected;
      • the enterprise-enable script's /api/enterprise/* calls, which would need the explicit service opt-in.
    • The SLM backend's personality and voice proxies forward any path. Only the paths the SLM frontend uses were enumerated.
  6. 13 remaining items

  7. mrveiss commented on Nov 4, 2026

    @mrveiss
    OwnerAuthor

    Owed follow-up, so it isn't lost: the SLM require_admin docstring in autobot-slm-backend/services/auth.py still says "legacy binary check … retained for backward compatibility". It should match the decision recorded above: it is the SLM's own admin check, separate by #20628 and ruling (b), and no route uses it. services/auth.py is in the open #20648, so this one-line change follows once #20648 lands. It does not go into #20648.

  8. added
    needs-ac-evidenceClosed by a merge keyword; awaits an AC evidence table comment (#19520)
    on Nov 4, 2026
  9. github-actions commented on Nov 4, 2026

    @github-actions
    Contributor

    Landed via the merge train (#20797, merge 92572eba98)

  10. added a commit that references this issue on Nov 6, 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

    area: auth-rbacWave 2 · cluster E — Auth, identity & RBAC canonbackendneeds-ac-evidenceClosed by a merge keyword; awaits an AC evidence table comment (#19520)phase:M4.9One definition per conceptpriority: lowtech-debt

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions