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
+10
View File
@@ -8,6 +8,7 @@ import (
"Wavelet/core"
"Wavelet/core/contracts"
"Wavelet/pkg/cache/ram"
"Wavelet/pkg/limiter"
"Wavelet/pkg/util"
"context"
"encoding/json"
@@ -139,6 +140,15 @@ func (p *Plugin) Apply(ctx *core.Context) error {
}
core.Provide[contracts.CacheService](ctx, svc)
var limiterSvc contracts.LimiterService
if redisClient != nil {
limiterSvc = newRedisLimiter(redisClient, p.keyPrefix)
} else {
limiterSvc = limiter.NewMemoryLimiter()
}
core.Provide[contracts.LimiterService](ctx, limiterSvc)
return nil
}