Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
1da23d6b
authored
Aug 06, 2026
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(rate-limit): add user critical rate limit middleware for access token and aff transfer routes
parent
b941253a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
middleware/rate-limit.go
+11
-0
router/api-router.go
+2
-2
No files found.
middleware/rate-limit.go
View file @
1da23d6b
...
@@ -178,6 +178,17 @@ func CriticalRateLimit() func(c *gin.Context) {
...
@@ -178,6 +178,17 @@ func CriticalRateLimit() func(c *gin.Context) {
return
defNext
return
defNext
}
}
func
UserCriticalRateLimit
(
scope
string
)
func
(
c
*
gin
.
Context
)
{
if
!
common
.
CriticalRateLimitEnable
{
return
defNext
}
return
userRateLimitFactory
(
common
.
CriticalRateLimitNum
,
common
.
CriticalRateLimitDuration
,
"UC:"
+
scope
,
)
}
func
DownloadRateLimit
()
func
(
c
*
gin
.
Context
)
{
func
DownloadRateLimit
()
func
(
c
*
gin
.
Context
)
{
return
rateLimitFactory
(
common
.
DownloadRateLimitNum
,
common
.
DownloadRateLimitDuration
,
"DW"
)
return
rateLimitFactory
(
common
.
DownloadRateLimitNum
,
common
.
DownloadRateLimitDuration
,
"DW"
)
}
}
...
...
router/api-router.go
View file @
1da23d6b
...
@@ -90,7 +90,7 @@ func SetApiRouter(router *gin.Engine) {
...
@@ -90,7 +90,7 @@ func SetApiRouter(router *gin.Engine) {
selfRoute
.
GET
(
"/models"
,
controller
.
GetUserModels
)
selfRoute
.
GET
(
"/models"
,
controller
.
GetUserModels
)
selfRoute
.
PUT
(
"/self"
,
middleware
.
CriticalRateLimit
(),
middleware
.
DisableCache
(),
controller
.
UpdateSelf
)
selfRoute
.
PUT
(
"/self"
,
middleware
.
CriticalRateLimit
(),
middleware
.
DisableCache
(),
controller
.
UpdateSelf
)
selfRoute
.
DELETE
(
"/self"
,
controller
.
DeleteSelf
)
selfRoute
.
DELETE
(
"/self"
,
controller
.
DeleteSelf
)
selfRoute
.
GET
(
"/token"
,
middleware
.
CriticalRateLimit
(),
middleware
.
DisableCache
(),
controller
.
GenerateAccessToken
)
selfRoute
.
GET
(
"/token"
,
middleware
.
CriticalRateLimit
(),
middleware
.
UserCriticalRateLimit
(
"access-token"
),
middleware
.
DisableCache
(),
controller
.
GenerateAccessToken
)
selfRoute
.
GET
(
"/passkey"
,
controller
.
PasskeyStatus
)
selfRoute
.
GET
(
"/passkey"
,
controller
.
PasskeyStatus
)
selfRoute
.
POST
(
"/passkey/register/begin"
,
middleware
.
DisableCache
(),
controller
.
PasskeyRegisterBegin
)
selfRoute
.
POST
(
"/passkey/register/begin"
,
middleware
.
DisableCache
(),
controller
.
PasskeyRegisterBegin
)
selfRoute
.
POST
(
"/passkey/register/finish"
,
middleware
.
DisableCache
(),
controller
.
PasskeyRegisterFinish
)
selfRoute
.
POST
(
"/passkey/register/finish"
,
middleware
.
DisableCache
(),
controller
.
PasskeyRegisterFinish
)
...
@@ -110,7 +110,7 @@ func SetApiRouter(router *gin.Engine) {
...
@@ -110,7 +110,7 @@ func SetApiRouter(router *gin.Engine) {
selfRoute
.
POST
(
"/waffo/pay"
,
middleware
.
CriticalRateLimit
(),
controller
.
RequestWaffoPay
)
selfRoute
.
POST
(
"/waffo/pay"
,
middleware
.
CriticalRateLimit
(),
controller
.
RequestWaffoPay
)
selfRoute
.
POST
(
"/waffo-pancake/amount"
,
controller
.
RequestWaffoPancakeAmount
)
selfRoute
.
POST
(
"/waffo-pancake/amount"
,
controller
.
RequestWaffoPancakeAmount
)
selfRoute
.
POST
(
"/waffo-pancake/pay"
,
middleware
.
CriticalRateLimit
(),
controller
.
RequestWaffoPancakePay
)
selfRoute
.
POST
(
"/waffo-pancake/pay"
,
middleware
.
CriticalRateLimit
(),
controller
.
RequestWaffoPancakePay
)
selfRoute
.
POST
(
"/aff_transfer"
,
controller
.
TransferAffQuota
)
selfRoute
.
POST
(
"/aff_transfer"
,
middleware
.
UserCriticalRateLimit
(
"aff-transfer"
),
controller
.
TransferAffQuota
)
selfRoute
.
PUT
(
"/setting"
,
controller
.
UpdateUserSetting
)
selfRoute
.
PUT
(
"/setting"
,
controller
.
UpdateUserSetting
)
// 2FA routes
// 2FA routes
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment