summaryrefslogtreecommitdiff
path: root/middleware
diff options
context:
space:
mode:
Diffstat (limited to 'middleware')
-rw-r--r--middleware/ratelimit.go17
1 files changed, 3 insertions, 14 deletions
diff --git a/middleware/ratelimit.go b/middleware/ratelimit.go
index 944f863..7ccdf17 100644
--- a/middleware/ratelimit.go
+++ b/middleware/ratelimit.go
@@ -1,29 +1,18 @@
package middleware
import (
+ "auth-proxy/config"
"auth-proxy/types"
"net"
"net/http"
- "os"
- "strconv"
"time"
)
func NewRateLimiter() *types.RateLimiter {
- maxRequests, err := strconv.Atoi(os.Getenv("USER_CREATION_RATE_LIMIT_MAX_REQUESTS"))
- if err != nil || maxRequests <= 0 {
- maxRequests = 5 // Default value
- }
-
- windowSeconds, err := strconv.Atoi(os.Getenv("USER_CREATION_RATE_LIMIT_WINDOW_SECONDS"))
- if err != nil || windowSeconds <= 0 {
- windowSeconds = 3600 // Default value (1 hour)
- }
-
return &types.RateLimiter{
Requests: make(map[string][]int64),
- Max: maxRequests,
- Window: time.Duration(windowSeconds) * time.Second,
+ Max: config.Paths.RateLimitMaxRequests,
+ Window: time.Duration(config.Paths.RateLimitWindowSeconds) * time.Second,
}
}