-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat(auth): add per-IP rate limiting to signup, signin, and password reset #4527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,6 +181,19 @@ export const auth = betterAuth({ | |
| provider: 'pg', | ||
| schema, | ||
| }), | ||
| rateLimit: { | ||
| enabled: true, | ||
| customRules: { | ||
| '/sign-up/email': { window: 600, max: 3 }, | ||
| '/sign-in/email': { window: 60, max: 10 }, | ||
| '/forget-password': { window: 600, max: 3 }, | ||
| }, | ||
| }, | ||
| advanced: { | ||
| ipAddress: { | ||
| ipAddressHeaders: ['cf-connecting-ip', 'x-forwarded-for'], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Including |
||
| }, | ||
| }, | ||
| session: { | ||
| cookieCache: { | ||
| enabled: true, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rate limiter defaults to in-memory storage, so each ECS task maintains its own counters. With N tasks running, any IP effectively gets
max * Nattempts before being blocked — e.g., 3 signups × 5 tasks = 15 signups unchecked cluster-wide. The PR description already flags this as a known follow-up, but it is worth noting explicitly: against a coordinated signup bot that distributes requests across tasks, the limit provides weaker-than-stated protection untilstorage: 'database'(or Redis) is added.