安全加固:增加后台登录 IP 限流并记录验证结果
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
diff --git a/apps/backend/src/routes/admin/auth.ts b/apps/backend/src/routes/admin/auth.ts
|
||||
--- a/apps/backend/src/routes/admin/auth.ts
|
||||
+++ b/apps/backend/src/routes/admin/auth.ts
|
||||
@@
|
||||
const router = Router()
|
||||
+
|
||||
+const adminLoginIpRateLimit = createRateLimitMiddleware({
|
||||
+ scope: 'admin:login:ip',
|
||||
+ windowMs: 60_000,
|
||||
+ max: 20,
|
||||
+})
|
||||
+
|
||||
+const adminLoginAccountRateLimit = createRateLimitMiddleware({
|
||||
+ scope: 'admin:login:account',
|
||||
+ windowMs: 60_000,
|
||||
+ max: 10,
|
||||
+ key: getBodyFieldRateLimitKey('username'),
|
||||
+})
|
||||
|
||||
router.post(
|
||||
'/auth/login',
|
||||
- createRateLimitMiddleware({
|
||||
- scope: 'admin:login',
|
||||
- windowMs: 60_000,
|
||||
- max: 10,
|
||||
- key: getBodyFieldRateLimitKey('username'),
|
||||
- }),
|
||||
+ adminLoginIpRateLimit,
|
||||
+ adminLoginAccountRateLimit,
|
||||
Reference in New Issue
Block a user