Skip to content

fix(auth): stop refresh 429 bouncing users to login; restore badge text color#249

Merged
bihius merged 1 commit into
mainfrom
fix/refresh-rate-limit-badge-color
Jun 15, 2026
Merged

fix(auth): stop refresh 429 bouncing users to login; restore badge text color#249
bihius merged 1 commit into
mainfrom
fix/refresh-rate-limit-badge-color

Conversation

@bihius

@bihius bihius commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #247, which fixed the refresh cookie path but did not fully fix session survival on reload.

Session refresh (the real cause)

POST /auth/refresh shared login's strict brute-force limit (AUTH_RATE_LIMIT = 5/minute). But refresh carries no user credentials — only a signed HttpOnly cookie — and the frontend calls it automatically on every page load (twice under React StrictMode in dev). A few reloads exhausted the limit, returning 429, which restoreSession() treats as "no session" → user bounced to the login screen.

  • Add a dedicated REFRESH_RATE_LIMIT = 60/minute in rate_limit.py.
  • /auth/refresh now uses it instead of AUTH_RATE_LIMIT.
  • Replace the test that encoded the buggy 5/minute refresh limit with: one proving 10 rapid reloads are not throttled, and one confirming refresh is still bounded at the higher ceiling.

Note: the "canceled" requests seen in DevTools are React StrictMode's double-mount in the dev server (?v= HMR URLs, ...InDEV frames) and do not occur in a production build — no change made there.

Badge text color

Revert all six badge.tsx variants from text-foreground (white) back to their per-variant colors, so success/default badges render green again.

Validation

  • pnpm run type-check, pnpm run lint, pnpm test (79 passed)
  • uv run pytest --cov=app (396 passed), uv run mypy app/ (clean), uv run ruff check (clean on changed files)

Fixes #245

…xt color

The /auth/refresh endpoint shared login's strict 5/minute brute-force limit,
but it carries no user credentials (only a signed HttpOnly refresh cookie) and
the frontend calls it automatically on every page load (twice under React
StrictMode in dev). A few reloads exhausted the limit, returning 429 and
bouncing authenticated users to the login page.

Add a separate REFRESH_RATE_LIMIT (60/minute) for the refresh endpoint so
normal reloads survive while still bounding abuse of the rotating-token
endpoint. Update tests accordingly.

Also revert badge variant text from text-foreground (white) back to the
per-variant colors so success/default badges render green again.
@bihius bihius merged commit e21d58f into main Jun 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Page reload on any authenticated route redirects the user back to the login screen

1 participant