User accounts Phase 1: Steam + Discord auth, profiles, run ownership#350
Open
ptrlrd wants to merge 10 commits into
Open
User accounts Phase 1: Steam + Discord auth, profiles, run ownership#350ptrlrd wants to merge 10 commits into
ptrlrd wants to merge 10 commits into
Conversation
Backend: - users collection in Mongo (steam_id, discord_id, unique username, email, rate-limited name changes) - JWT sessions via httpOnly cookie (7-day expiry, HS256) - Steam auth upgraded to create user doc + issue JWT on poll success - Discord OAuth2 flow (identify + email scopes, redirect-based) - Shared auth endpoints: /me, /logout, username/email updates, my runs (paginated), run soft-delete, .run file upload + auto-claim - Run ownership via user_id field + index on runs collection - Soft delete (deleted_at timestamp, share links stay alive) Frontend: - AuthContext: fetches /me on mount, Steam popup flow, Discord redirect - ToastProvider: success/error/info notifications, auto-dismiss, stacked - Navbar user menu: compact icon button (fits mobile right cluster), sign-in dropdown (Steam/Discord), account dropdown when logged in - Profile page: my runs list with pagination, drag-and-drop .run upload with per-file results, inline delete with confirmation - Settings page: display name (availability check, rate limit display), email, connected accounts (Steam/Discord with connect buttons) Sad paths handled throughout: auth failures, expired sessions, duplicate usernames, invalid files, rate limits, ownership checks on delete, network errors with user-visible messages via toast system. Requires env vars: JWT_SECRET, DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET
Staging: - docker-compose.staging.yml with staging image tags and auth env vars - CI builds staging images on push to staging branch - Staging site at staging.spire-codex.com (DNS + nginx config needed) Auth fixes from local testing: - Steam redirect endpoint (GET /redirect) for mobile browsers - Callback redirects to frontend with token in URL (FRONTEND_URL env) - Bearer token fallback in Authorization header (cross-origin dev) - /api/auth/set-cookie endpoint for token-to-cookie exchange - CORS_ORIGINS env var for credentialed cross-origin requests - Expired session redirects to frontend instead of showing error page
Add JWT_SECRET, DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET to .env.tpl as op:// references (vault: Spire Codex, items: Auth + Discord OAuth). Staging compose reads from the shared .env rendered by sync-secrets.yml. Add staging_compose_file to inventory vars.
Uses resolver 127.0.0.11 + variable proxy_pass so nginx resolves staging container hostnames at request time, not startup. Staging containers being down won't prevent nginx from starting or affect prod/beta.
Fixes Discord OAuth redirect_uri using http:// instead of https://. The backend container sees nginx's HTTP connection, not Cloudflare's HTTPS. The env var forces the correct public URL for OAuth callbacks.
Discord callback now checks for an existing JWT. If the user is already signed in via Steam, clicking "Connect Discord" links the Discord ID to their existing account instead of creating a new one. Also makes the entire connected accounts row clickable.
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.
Summary
usersdoc in Mongo. No passwords.user_idfield on run docs, new Mongo indexSad paths handled
Env vars needed
JWT_SECRET(required, 32+ char random string)DISCORD_CLIENT_IDDISCORD_CLIENT_SECRETFiles changed