summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/SigninApiService.ts
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2025-12-16 19:56:44 +0900
committersyuilo <4439005+syuilo@users.noreply.github.com>2025-12-16 19:56:44 +0900
commitd35ddc77d285879a4f5dd8a40497bf58930cb30e (patch)
tree163b0a6f77c7481d33c29eb9c0e80dd5428193e8 /packages/backend/src/server/api/SigninApiService.ts
parentUpdate CHANGELOG.md (diff)
downloadmisskey-d35ddc77d285879a4f5dd8a40497bf58930cb30e.tar.gz
misskey-d35ddc77d285879a4f5dd8a40497bf58930cb30e.tar.bz2
misskey-d35ddc77d285879a4f5dd8a40497bf58930cb30e.zip
enhance(backend): request ip が localhost だった場合、レートリミットをスキップ & 警告を出すように
Diffstat (limited to 'packages/backend/src/server/api/SigninApiService.ts')
-rw-r--r--packages/backend/src/server/api/SigninApiService.ts24
1 files changed, 14 insertions, 10 deletions
diff --git a/packages/backend/src/server/api/SigninApiService.ts b/packages/backend/src/server/api/SigninApiService.ts
index 3e889372d8..14726f8411 100644
--- a/packages/backend/src/server/api/SigninApiService.ts
+++ b/packages/backend/src/server/api/SigninApiService.ts
@@ -89,17 +89,21 @@ export class SigninApiService {
return { error };
}
+ if (request.ip === '::1' || request.ip === '127.0.0.1') {
+ console.warn('request ip is localhost, maybe caused by misconfiguration of trustProxy or reverse proxy');
+ } else {
// not more than 1 attempt per second and not more than 10 attempts per hour
- const rateLimit = await this.rateLimiterService.limit({ key: 'signin', duration: 60 * 60 * 1000, max: 10, minInterval: 1000 }, getIpHash(request.ip));
- if (rateLimit != null) {
- reply.code(429);
- return {
- error: {
- message: 'Too many failed attempts to sign in. Try again later.',
- code: 'TOO_MANY_AUTHENTICATION_FAILURES',
- id: '22d05606-fbcf-421a-a2db-b32610dcfd1b',
- },
- };
+ const rateLimit = await this.rateLimiterService.limit({ key: 'signin', duration: 60 * 60 * 1000, max: 10, minInterval: 1000 }, getIpHash(request.ip));
+ if (rateLimit != null) {
+ reply.code(429);
+ return {
+ error: {
+ message: 'Too many failed attempts to sign in. Try again later.',
+ code: 'TOO_MANY_AUTHENTICATION_FAILURES',
+ id: '22d05606-fbcf-421a-a2db-b32610dcfd1b',
+ },
+ };
+ }
}
if (typeof username !== 'string') {