From fcd81a8d2f02e6284b9d03e29dbe6c48d16f9529 Mon Sep 17 00:00:00 2001
From: Joel Lee
Date: Wed, 10 Jul 2024 16:45:38 +0200
Subject: [PATCH] feat: add rate limit otp (#27402)
* feat: add rate limit otp
* Update apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx
Co-authored-by: Joel Lee
* Update apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx
Co-authored-by: Joel Lee
* fix: update rate limit otps
* Change the p to FormDescription element.
---------
Co-authored-by: Kang Ming
Co-authored-by: Ivan Vasilov
---
.../interfaces/Auth/RateLimits/RateLimits.tsx | 42 +++++++++++++++++++
1 file changed, 42 insertions(+)
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>({
@@ -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 = () => {
/>
+
+ Number of sign up and sign-in requests that can be made per hour per IP
+ address (excludes anonymous users).
+
+ }
+ >
+ Rate limit for sign ups and sign ins
+
+ }
+ >
+
+ (
+
+
+
+
+ {field.value > 0 && (
+
+ This is equivalent to {field.value * 12} requests per hour
+
+ )}
+
+ )}
+ />
+
+