fix: enforce rate limit for sign-ups and sign-ins (fixes #2333)#2421
fix: enforce rate limit for sign-ups and sign-ins (fixes #2333)#2421nancysangani wants to merge 1 commit intosupabase:masterfrom
Conversation
|
/cc @staaldraad |
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #2333 where the configured rate limit for sign-ups and sign-ins was never enforced. Three bugs are addressed: a missing config field, incorrect limiter wiring for signups, and sign-ins using the wrong limiter.
Changes:
- Add missing
RateLimitSignInSignUpsfield toGlobalConfigurationso the env/config value is actually read. - Wire
Signupsand newSignInslimiters toRateLimitSignInSignUpsinstead ofRateLimitOtp. - Use the
SignInslimiter for password grant in the/tokenendpoint, keeping the token refresh limiter for other grant types.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/conf/configuration.go | Add RateLimitSignInSignUps field to config struct |
| internal/api/options.go | Add SignIns limiter and wire both Signups/SignIns to the correct rate limit |
| internal/api/token.go | Default /token to SignIns limiter; keep Token limiter for non-password grants |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| o.SignIns = newLimiterPer5mOver1h(gc.RateLimitSignInSignUps) | ||
| o.OAuthClientRegister = newLimiterPer5mOver1h(gc.RateLimitOAuthDynamicClientRegister) |
There was a problem hiding this comment.
Lines 111 and 112 use spaces for indentation instead of tabs, which is inconsistent with the rest of the file. Please use tabs to match the surrounding code.
| o.SignIns = newLimiterPer5mOver1h(gc.RateLimitSignInSignUps) | |
| o.OAuthClientRegister = newLimiterPer5mOver1h(gc.RateLimitOAuthDynamicClientRegister) | |
| o.SignIns = newLimiterPer5mOver1h(gc.RateLimitSignInSignUps) | |
| o.OAuthClientRegister = newLimiterPer5mOver1h(gc.RateLimitOAuthDynamicClientRegister) |
|
/cc @cemalkilic |
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
The rate limit for sign-ups and sign-ins configured via the dashboard or
config.toml (sign_in_sign_ups) is never enforced. Requests only get blocked
after ~30-50 attempts due to a different unrelated limit firing instead.
Fixes #2333
What is the new behavior?
Sign-up and sign-in requests are correctly blocked once the configured
limit is reached. The /token password grant (sign-in) is also now covered
by this limit, which it previously wasn't at all.
Additional context
Three issues were found:
the configured value was always silently ignored.
the sign-in/sign-up limit.
limiter (default 150/5min) instead of the sign-in limit.