Documentation
¶
Index ¶
- func ApplyAuthBackoffOnFailure(ctx *gin.Context)
- func BasicAuthMiddleware(cfg config.File, logger *slog.Logger) gin.HandlerFunc
- func BasicAuthMiddlewareWithDeps(cfg config.File, logger *slog.Logger) gin.HandlerFunc
- func CheckAndRequireBasicAuth(ctx *gin.Context, cfg config.File) bool
- func CheckAndRequireBasicAuthWithCfg(ctx *gin.Context, cfg config.File) bool
- func MaybeThrottleAuthByIP(ctx *gin.Context, cfg config.File) bool
- func ProtectEndpointMiddleware(cfg config.File, logger *slog.Logger) gin.HandlerFunc
- func SetProtectMiddleware(factory func(cfg config.File, logger *slog.Logger) gin.HandlerFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyAuthBackoffOnFailure ¶
ApplyAuthBackoffOnFailure notes a failure for this IP and sleeps a short duration.
func BasicAuthMiddleware ¶
BasicAuthMiddleware provides HTTP Basic Authentication for protected routes in a Gin application. It validates credentials against configured username and password, and challenges unauthorized requests. If basic auth is disabled or bypassed based on the route configuration, it allows the request to proceed.
func BasicAuthMiddlewareWithDeps ¶ added in v1.12.0
func CheckAndRequireBasicAuth ¶
CheckAndRequireBasicAuth enforces basic authentication if it's enabled in the server configuration. It validates credentials provided in the request against the configured username and password. Returns true if authentication is successful or not required, false if the authentication fails or is throttled.
func CheckAndRequireBasicAuthWithCfg ¶ added in v1.12.0
func MaybeThrottleAuthByIP ¶
MaybeThrottleAuthByIP checks if the client IP is temporarily blocked and, if so, responds with 429 and a Retry-After header. It only enforces throttling if the brute-force feature is enabled in the configuration.
func ProtectEndpointMiddleware ¶
ProtectEndpointMiddleware returns the configured ProtectEndpoint middleware. If no factory was registered, it returns a no-op middleware that simply calls Next().
func SetProtectMiddleware ¶
SetProtectMiddleware registers the factory used by ProtectEndpointMiddleware. The core package should call this during initialization to provide the implementation.
Types ¶
This section is empty.