Add per-IP rate limiting (login + general API)

This commit is contained in:
root
2026-03-24 11:40:36 +01:00
parent e2d8bd344d
commit d9de02f08d
3 changed files with 127 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package auth
import (
"ResendIt/internal/api/middleware"
"time"
"github.com/gin-gonic/gin"
)
@@ -9,7 +10,9 @@ import (
func RegisterRoutes(r *gin.RouterGroup, h *Handler) {
auth := r.Group("/auth")
auth.POST("/login", h.Login)
// Stricter rate limit on login to reduce brute-force / log spam.
// 5 attempts per minute per IP, burst 10.
auth.POST("/login", middleware.RateLimitByIP(5, time.Minute, 10, 15*time.Minute), h.Login)
protected := auth.Group("/")
protected.Use(middleware.AuthMiddleware())