Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: add rate limit otp (#27402)

Joel Leefcd81a8d2f02
diff --git a/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx b/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx
index d596e6243f0..ae09d21f0cc 100644
--- a/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx
+++ b/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx
@@ -22,6 +22,7 @@ import {
Alert_Shadcn_,
Button,
FormControl_Shadcn_,
+ FormDescription_Shadcn_,
FormField_Shadcn_,
FormItem_Shadcn_,
Form_Shadcn_,
@@ -76,6 +77,10 @@ const RateLimits = () => {
.number()
.min(0, 'Must be not be lower than 0')
.max(32767, 'Must not be more than 32,767 an hour'),
+ RATE_LIMIT_OTP: z.coerce
+ .number()
+ .min(0, 'Must be not be lower than 0')
+ .max(32767, 'Must not be more than 32,767 an hour'),
})
const form = useForm<z.infer<typeof FormSchema>>({
@@ -85,6 +90,7 @@ const RateLimits = () => {
RATE_LIMIT_VERIFY: 0,
RATE_LIMIT_EMAIL_SENT: 0,
RATE_LIMIT_SMS_SENT: 0,
+ RATE_LIMIT_OTP: 0,
},
})
@@ -98,6 +104,7 @@ const RateLimits = () => {
'RATE_LIMIT_EMAIL_SENT',
'RATE_LIMIT_SMS_SENT',
'RATE_LIMIT_ANONYMOUS_USERS',
+ 'RATE_LIMIT_OTP',
] as (keyof typeof payload)[]
params.forEach((param) => {
if (data[param] !== authConfig?.[param]) payload[param] = data[param]
@@ -114,6 +121,7 @@ const RateLimits = () => {
RATE_LIMIT_EMAIL_SENT: authConfig.RATE_LIMIT_EMAIL_SENT,
RATE_LIMIT_SMS_SENT: authConfig.RATE_LIMIT_SMS_SENT,
RATE_LIMIT_ANONYMOUS_USERS: authConfig.RATE_LIMIT_ANONYMOUS_USERS,
+ RATE_LIMIT_OTP: authConfig.RATE_LIMIT_OTP,
})
}
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -394,6 +402,40 @@ const RateLimits = () => {
/>
</FormSectionContent>
</FormSection>
+ <FormSection
+ id="otp"
+ header={
+ <FormSectionLabel
+ description={
+ <p className="text-foreground-light text-sm">
+ Number of sign up and sign-in requests that can be made per hour per IP
+ address (excludes anonymous users).
+ </p>
+ }
+ >
+ Rate limit for sign ups and sign ins
+ </FormSectionLabel>
+ }
+ >
+ <FormSectionContent loading={false}>
+ <FormField_Shadcn_
+ control={form.control}
+ name="RATE_LIMIT_OTP"
+ render={({ field }) => (
+ <FormItem_Shadcn_>
+ <FormControl_Shadcn_>
+ <Input_Shadcn_ type="number" {...field} disabled={!canUpdateConfig} />
+ </FormControl_Shadcn_>
+ {field.value > 0 && (
+ <FormDescription_Shadcn_ className="text-foreground-lighter">
+ This is equivalent to {field.value * 12} requests per hour
+ </FormDescription_Shadcn_>
+ )}
+ </FormItem_Shadcn_>
+ )}
+ />
+ </FormSectionContent>
+ </FormSection>
</FormPanel>
</form>
</Form_Shadcn_>