feat: OBS-backed login system - #1
Open
AgustinChiarenza wants to merge 1 commit into
Open
Conversation
Credentials are read from an OBS object (Auth/users.json) in the same bucket as the ops data, so no secrets live in source. The backend issues HMAC-SHA256 signed tokens (stdlib only) and middleware gates every /api/* route except health and the auth endpoints. The frontend gates routes behind an AuthProvider, attaches the bearer token via an axios interceptor, auto-redirects to /login on 401, and exposes sign-out from the header. Backend: - app/auth.py: OBS credential loader (TTL cached) + token sign/verify - app/routers/auth.py: /login, /me, /logout - app/main.py: auth middleware + router registration - app/config.py: AUTH_ENABLED, AUTH_USERS_PATH, AUTH_SECRET, AUTH_TOKEN_TTL_SECONDS Frontend: - auth/AuthContext + useAuth: session state, /me validation on boot - pages/LoginPage: designed split-panel login - api/client: bearer + 401 interceptors - layout/Header: user menu + sign out Ops: - scripts/seed_auth_users.py: idempotent seeder (reads passwords from env, no hardcoded secrets) - .env.example: document auth vars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a login system that reads credentials from an OBS object (
Auth/users.json) in the same bucket as the ops data — no secrets in source.Backend
app/auth.py: loads the user table from OBS (60s TTL cache), HMAC-SHA256 token sign/verify (stdlib only). Acceptspasswordorpassword_sha256.app/routers/auth.py:POST /api/auth/login,GET /api/auth/me,POST /api/auth/logout.app/main.py: middleware gating all/api/*except/api/health,/api/auth/login,/api/auth/logout.app/config.py:AUTH_ENABLED,AUTH_USERS_PATH,AUTH_SECRET,AUTH_TOKEN_TTL_SECONDS.Frontend
auth/AuthContext+useAuth: session state, validates cached token via/auth/meon boot.pages/LoginPage: split-panel login matching the brand palette.api/client: axios interceptor attachesBearerand redirects to/loginon 401.layout/Header: user avatar, role, and sign-out menu.App.tsx/main.tsx: routes gated behindAuthProvider.Ops
scripts/seed_auth_users.py: idempotent seeder — reads passwords from env vars (ADMIN_PASSWORD,VIEWER_PASSWORD), no hardcoded secrets..env.example: documents the new auth vars.Verified
/api/healthpublic ✓/api/auth/mewith token → user ✓Test plan
docker exec -e ADMIN_PASSWORD=... cloud-ops-backend python /app/scripts/seed_auth_users.py:8082→ redirects to/login/loginAUTH_ENABLED=false→ dashboard open as before🤖 Generated with Claude Code