Repository navigation
fix(backend): mount only the auth endpoints the game uses - #346
Merged
Merged
Conversation
…ookie flags Two of these fail on main: /change-password leaves other sessions alive unless the client asks, and /is-username-available tells anyone which usernames exist.
better-auth's catch-all answered every endpoint it ships. Two of them weakened auth: change-password kept other sessions alive unless the client asked otherwise, and is-username-available told anyone which usernames exist. The routes now allowlist sign-up, both password sign-ins, sign-out and get-session; anything else is a 404. Password resets also revoke every session, for when a reset route is added.
arrzdev
marked this pull request as ready for review
November 16, 2026 22:18
arrzdev
commented
Nov 16, 2026
arrzdev
left a comment
Owner
Author
There was a problem hiding this comment.
Approve. The allowlist covers every endpoint the game client calls (sign-up/email, sign-in/username, sign-out, get-session) plus sign-in/email; everything else better-auth exposes is now 404, which closes both the change-password and username-probe gaps at the root. Rate-limit and origin middleware still run first. Tests pin the behaviour either way.
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.
What and why
Adds three auth tests and the backend fix for the two that failed on
main.Fix: better-auth's catch-all is replaced with an allowlist in
auth.routes.ts: sign-up/email, sign-in/email, sign-in/username, sign-out and get-session. Every other better-auth endpoint,/change-passwordand/is-username-availableincluded, is now a 404.revokeSessionsOnPasswordReset: trueis set for when a reset route is added. The route auth matrix test lists the new routes./change-password. It only revokes other sessions when the client sendsrevokeOtherSessions: true. The test signs in on two devices, changes the password from one, and expects the other token to be refused. Today it still gets 200. Two fixes satisfy the test: force revocation on the server, or switch the endpoint off (404), since the game has no change-password screen./is-username-availablereveals which usernames exist. It answers{"available":false}for a taken name without creating anything. The test expects the same status and body for a known and an unknown username.HttpOnlyandSameSite=Laxon the session cookie. It already passes.How to verify
pnpm --filter @repo/backend exec vitest run src/http/routes/auth.routes.test.ts. Onmain: 2 failed, 28 passed. On this branch: 30 passed. Full backend suite: 620 passed.UI quality gate
Not applicable: backend only.