mirror of
https://github.com/syntrex-lab/gomcp.git
synced 2026-04-25 04:16:22 +02:00
fix: exclude auth/SSE/events from global rate limiter
This commit is contained in:
parent
ab55fe2b58
commit
11c0e42af7
1 changed files with 14 additions and 0 deletions
|
|
@ -62,6 +62,8 @@ func (rl *RateLimiter) Allow(ip string) bool {
|
|||
}
|
||||
|
||||
// Middleware wraps an HTTP handler with rate limiting.
|
||||
// Certain paths are excluded to prevent battle/scan traffic from blocking
|
||||
// dashboard access (auth, SSE stream, event ingestion).
|
||||
func (rl *RateLimiter) Middleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if !rl.enabled {
|
||||
|
|
@ -69,6 +71,18 @@ func (rl *RateLimiter) Middleware(next http.Handler) http.Handler {
|
|||
return
|
||||
}
|
||||
|
||||
// Exclude critical dashboard paths from global rate limiter
|
||||
p := r.URL.Path
|
||||
switch {
|
||||
case p == "/api/auth/login",
|
||||
p == "/api/auth/refresh",
|
||||
p == "/api/soc/stream",
|
||||
p == "/api/v1/soc/events",
|
||||
p == "/api/soc/events":
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
// T4-3 FIX: Use RemoteAddr directly to prevent X-Forwarded-For spoofing.
|
||||
// When behind a trusted reverse proxy, configure the proxy to set
|
||||
// X-Real-IP and strip external X-Forwarded-For headers.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue