fix: secure auth.go

The BasicAuth middleware lacks rate limiting, account lockout, or progressive delay mechanisms
Addresses CWE-799
This commit is contained in:
anupamme 2026-10-03 08:09:20 +00:00
parent 43fe48e8a0
commit c45d55938b

View File

@ -9,10 +9,16 @@ import (
"encoding/base64"
"net/http"
"strconv"
"time"
"github.com/gin-gonic/gin/internal/bytesconv"
)
// basicAuthFailureDelay is a small artificial delay applied on failed
// authentication attempts to throttle brute-force and credential-stuffing
// attacks against BasicAuth protected routes.
const basicAuthFailureDelay = 500 * time.Millisecond
// AuthUserKey is the cookie name for user credential in basic auth.
const AuthUserKey = "user"