Repository navigation
Conversation
… CORS, auth throttle (#315) - JWTs carry a type; verifyToken accepts access tokens only, so a refresh token is good only at /admin/refresh. HS256 pinned on verify. - users.token_version, embedded as the tv claim; bumped on password change, admin-status change and logout. requireAuth and requireOwner share one verification path (authenticateSession). - No JWT from the query string. - Session cookies set through one helper; Secure when the request arrived over HTTPS. - CORS: no cross-origin access to the cookie-authenticated API unless listed in CORS_ALLOWED_ORIGINS; /rest/* answers any origin, never credentialed. - Failed-password throttle shared by /admin/login and Subsonic auth, keyed on request.ip; TRUST_PROXY sets Fastify trustProxy. Invite limiter moved onto the same primitives. - Login decrypts a decoy for unknown usernames. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M98ML9i5X7crjKVomscTNt
…falls (#315) Also passes TRUST_PROXY and CORS_ALLOWED_ORIGINS through docker-compose.yml, documents them in example.env, and makes reset-password.sh bump token_version so a recovery reset revokes existing sessions. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M98ML9i5X7crjKVomscTNt
benders
marked this pull request as ready for review
November 13, 2026 02:11
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.
Closes #315. SECURITY.md H2, H5, M3 (items 1, 2, 4), H1 (cookie part).
Changes
Tokens
type.verifyTokenacceptsaccessonly,verifyRefreshTokenacceptsrefreshonly; HS256 pinned on verify.users.token_version(new column, additive migration), embedded astv. A mismatch is rejected on every request and on refresh. Bumped on password change, admin-status change, logout, and byreset-password.sh.requireAuthandrequireOwnernow share one verification path,authenticateSession.token=query-string source is gone (nothing used it).Cookies
issueSession.Secureis set when the request arrived over HTTPS (X-Forwarded-Protofrom the proxy).CORS
CORS_ALLOWED_ORIGINS./rest/*:*, never credentialed — keeps browser-based Subsonic clients working; no cookie is read there.Throttling
AuthThrottle, shared by/admin/loginand Subsonicu+p/u+t+s: 10 failures per (client address, username) and 100 per address, per 10 minutes. Failures only; a success clears the pair; blocked attempts are not counted.429; Subsonic JSON envelope error 0; Subsonic binary429. All withRetry-After.TRUST_PROXY→ FastifytrustProxy. Limits key onrequest.iponly. A one-time warning is logged when a forwarding header shows up withTRUST_PROXYunset.Behaviour changes to know about
typeand are rejected once; the SPA recovers with a silent refresh. Refresh tokens stay valid.TRUST_PROXY(e.g.loopback,uniquelocal). Unset, all clients share one throttle bucket: 10 bad passwords for a username lock that username for everyone for up to 10 minutes.Deliberately not done
Testing
hub/test/session-hardening.test.ts(31 tests): refresh token rejected as bearer and cookie, access token rejected at refresh, untyped token rejected, no query-string JWT, revocation on password change / admin change / logout, self password change, cookie flags, lockout and its scoping, shared budget across login and Subsonic,TRUST_PROXYon and off, CORS default and allowlist, config parsing, column migration.pnpm verifylocally: typecheck, lint (zero output), hub unit 1064/1064, frontend 193/193, integration 19 passed. The 3dlna-ssdpintegration tests fail locally only — the dev Mac cannot send UDP multicast (EHOSTUNREACH); they run in CI.pnpm test:federationnot run locally (two live hubs share a 2 GB Docker VM — the OOM pitfall); relying on the CIfederationjob.reset-password.shchange is syntax-checked only.🤖 Generated with Claude Code
https://claude.ai/code/session_01M98ML9i5X7crjKVomscTNt