2.5 KiB
2.5 KiB
DISABLE_AUTH env var — design
Purpose
Add a dev-only DISABLE_AUTH environment variable that bypasses authentication
and permission checks end-to-end (API + admin UI), so the app can be driven
by tooling (e.g. browser automation) without a login step. Insecure by design;
must default to off and be documented as such.
Backend
Config(src/config.rs) gainsdisable_auth: bool, read fromDISABLE_AUTH. Truthy values:1,true(case-insensitive). Default:false.src/auth/middleware.rsgainsauthenticate_or_bypass(state, req):- If
state.config.disable_auth, return a synthetic super-adminClaims(sub: "dev-bypass",permissions: u128::MAX.to_string(),exp: usize::MAX) without inspecting the request at all. - Otherwise, delegate to the existing
extract_bearer+authenticateflow.
- If
require_auth,require_super_admin,require_admin_query,require_admin_cache, andblacklist_layerswitch fromextract_bearer(...).ok_or(UNAUTHORIZED)?+authenticate(...)toauthenticate_or_bypass(...), so the bypass applies uniformly (including blacklistbypass_maskchecks, since the caller mask isu128::MAX).- New route
GET /auth/config(src/routes/auth.rs), unauthenticated, returns{"disable_auth": bool}so the frontend can detect the mode.
Frontend
ui/src/stores/auth.ts: on first access, fetchGET /auth/config. Ifdisable_authistrue, set anauthDisabledref and short-circuitisAuthenticated/isSuperAdmin/hasPermissionto always report a fully-privileged, logged-in user — no token needed.ui/src/router/index.ts:beforeEachawaits the auth store's boot check (memoized, runs once) before evaluatingrequiresAuth, so/admin/*routes never redirect to/loginwhile the flag is set.- No changes to
Login.vueitself; it simply becomes unreachable in this mode (redirect away from/loginwhen already "authenticated").
Docs / plumbing
.env.example: addDISABLE_AUTH=(commented, default off) with a warning.docker-compose.yml: addDISABLE_AUTH: ${DISABLE_AUTH:-false}under theapiservice environment.README.md: addDISABLE_AUTHto the Configuration table, marked dev-only / insecure — do not use in production.
Out of scope
- No change to
/auth/loginbehavior when the flag is off. - No new permission bits or config for partial bypass (all-or-nothing).
- No changes to how the FE issues investigation (separate task, done live with agent-browser after this lands).