mirror of
https://github.com/gin-gonic/gin.git
synced 2026-11-23 11:33:37 +08:00
fix: secure auth.go
The BasicAuth middleware lacks rate limiting, account lockout, or progressive delay mechanisms Addresses CWE-799
This commit is contained in:
parent
43fe48e8a0
commit
c45d55938b
6
auth.go
6
auth.go
@ -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"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user