Documentation
¶
Index ¶
- func ApplyAuthBackoffOnFailure(ctx *gin.Context)
- func BasicAuthMiddleware() gin.HandlerFunc
- func CheckAndRequireBasicAuth(ctx *gin.Context) bool
- func MaybeThrottleAuthByIP(ctx *gin.Context) bool
- func ProtectEndpointMiddleware() gin.HandlerFunc
- func SetProtectMiddleware(factory func() 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 ¶
func BasicAuthMiddleware() gin.HandlerFunc
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 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 MaybeThrottleAuthByIP ¶
MaybeThrottleAuthByIP checks if the client IP is temporarily blocked and, if so, responds with 429 and a Retry-After header.
func ProtectEndpointMiddleware ¶
func ProtectEndpointMiddleware() gin.HandlerFunc
ProtectEndpointMiddleware returns the configured ProtectEndpoint middleware. If no factory was registered, it returns a no-op middleware that simply calls Next(). This indirection allows external packages to depend on middleware/auth without importing core.
func SetProtectMiddleware ¶
func SetProtectMiddleware(factory func() gin.HandlerFunc)
SetProtectMiddleware registers the factory used by ProtectEndpointMiddleware. The core package should call this during initialization to provide the implementation.
Types ¶
This section is empty.