feat(server): login page + session cookie auth #13
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/login-cookie-auth"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Replace the HTTP Basic dialog on the web UI with a login page + session cookie:
GET/POST /login(inline form,?e=1error, open-redirect-guarded?next=) andGET/POST /logout(internal/server/login.go)mediacast_session): 30-day TTL, HttpOnly, SameSite=Lax, Secure on TLS, sliding refresh under 15 days remaining (internal/server/session.go)MEDIACAST_PASSWORD, so changing the password invalidates every outstanding session — no newMEDIACAST_*env varServeHTTP:/login,/logout,/style.cssallowlisted; web surface redirects 303 to the login page (noWWW-Authenticatechallenge); feed/audio/artwork catcher unchanged (401 + Basic whenMEDIACAST_FEED_AUTH=auth) so podcast clients anduser:pass@host/feed.xmlsubscriptions keep workingWhy
Basic auth's browser dialog can't be styled, has no logout, and phone password managers interact with it poorly. A cookie session keeps the user logged in ~30 days with a proper password-manager-friendly form, using the same static credentials.
Tests
New
login_test.go: form render, bad/good creds, cookie-only access, tampered/expired cookie rejection, sliding refresh,next=guard, logout. Existing*RequiresAuthtests updated 401 → 303-to-login for web surfaces; Basic-fallback and feed-catcher (TestFeedAuthFlag) tests unchanged and passing.mise run check+mise run testgreen.