feat(auth): implement decoupled sliding-window rate limiting for login and oauth

This commit is contained in:
ryan
2026-09-02 22:15:21 +08:00
parent 39f02b5d7a
commit 9632604958
23 changed files with 927 additions and 50 deletions
+16 -3
View File
@@ -5702,7 +5702,7 @@ const docTemplate = `{
},
"/api/v1/user/login": {
"post": {
"description": "使用用户名和密码登录,登录成功后建立 Session。若管理员已关闭密码登录功能则返回错误。",
"description": "使用用户名和密码登录系统,验证通过后建立 Session 并返回用户信息。",
"consumes": [
"application/json"
],
@@ -5712,7 +5712,7 @@ const docTemplate = `{
"tags": [
"user"
],
"summary": "用户密码登录",
"summary": "用户登录",
"parameters": [
{
"description": "登录请求参数",
@@ -5737,6 +5737,12 @@ const docTemplate = `{
"$ref": "#/definitions/response.Any"
}
},
"429": {
"description": "登录尝试过于频繁",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"500": {
"description": "服务内部错误",
"schema": {
@@ -5872,6 +5878,12 @@ const docTemplate = `{
"$ref": "#/definitions/response.Any"
}
},
"429": {
"description": "注册尝试过于频繁",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"500": {
"description": "服务内部错误",
"schema": {
@@ -6081,7 +6093,8 @@ const docTemplate = `{
"type": "string"
},
"id": {
"type": "integer"
"type": "string",
"example": "0"
},
"is_admin": {
"type": "boolean"
+16 -3
View File
@@ -5695,7 +5695,7 @@
},
"/api/v1/user/login": {
"post": {
"description": "使用用户名和密码登录,登录成功后建立 Session。若管理员已关闭密码登录功能则返回错误。",
"description": "使用用户名和密码登录系统,验证通过后建立 Session 并返回用户信息。",
"consumes": [
"application/json"
],
@@ -5705,7 +5705,7 @@
"tags": [
"user"
],
"summary": "用户密码登录",
"summary": "用户登录",
"parameters": [
{
"description": "登录请求参数",
@@ -5730,6 +5730,12 @@
"$ref": "#/definitions/response.Any"
}
},
"429": {
"description": "登录尝试过于频繁",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"500": {
"description": "服务内部错误",
"schema": {
@@ -5865,6 +5871,12 @@
"$ref": "#/definitions/response.Any"
}
},
"429": {
"description": "注册尝试过于频繁",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"500": {
"description": "服务内部错误",
"schema": {
@@ -6074,7 +6086,8 @@
"type": "string"
},
"id": {
"type": "integer"
"type": "string",
"example": "0"
},
"is_admin": {
"type": "boolean"
+12 -3
View File
@@ -28,7 +28,8 @@ definitions:
gender:
type: string
id:
type: integer
example: "0"
type: string
is_admin:
type: boolean
location:
@@ -4810,7 +4811,7 @@ paths:
post:
consumes:
- application/json
description: 使用用户名和密码登录,登录成功后建立 Session。若管理员已关闭密码登录功能则返回错误。
description: 使用用户名和密码登录系统,验证通过后建立 Session 并返回用户信息。
parameters:
- description: 登录请求参数
in: body
@@ -4829,11 +4830,15 @@ paths:
description: 用户名或密码错误
schema:
$ref: '#/definitions/response.Any'
"429":
description: 登录尝试过于频繁
schema:
$ref: '#/definitions/response.Any'
"500":
description: 服务内部错误
schema:
$ref: '#/definitions/response.Any'
summary: 用户密码登录
summary: 用户登录
tags:
- user
/api/v1/user/logout:
@@ -4913,6 +4918,10 @@ paths:
description: 参数错误、用户名已存在或注册已关闭
schema:
$ref: '#/definitions/response.Any'
"429":
description: 注册尝试过于频繁
schema:
$ref: '#/definitions/response.Any'
"500":
description: 服务内部错误
schema: