mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-04 15:06:37 +08:00
feat(auth): implement decoupled sliding-window rate limiting for login and oauth
This commit is contained in:
+10
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user