auth

package
v1.12.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAuthBackoffOnFailure

func ApplyAuthBackoffOnFailure(ctx *gin.Context)

ApplyAuthBackoffOnFailure notes a failure for this IP and sleeps a short duration.

func BasicAuthMiddleware

func BasicAuthMiddleware(cfg config.File, logger *slog.Logger) 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 BasicAuthMiddlewareWithDeps added in v1.12.0

func BasicAuthMiddlewareWithDeps(cfg config.File, logger *slog.Logger) gin.HandlerFunc

func CheckAndRequireBasicAuth

func CheckAndRequireBasicAuth(ctx *gin.Context, cfg config.File) bool

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 CheckAndRequireBasicAuthWithCfg(ctx *gin.Context, cfg config.File) bool

func MaybeThrottleAuthByIP

func MaybeThrottleAuthByIP(ctx *gin.Context, cfg config.File) bool

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

func ProtectEndpointMiddleware(cfg config.File, logger *slog.Logger) gin.HandlerFunc

ProtectEndpointMiddleware returns the configured ProtectEndpoint middleware. If no factory was registered, it returns a no-op middleware that simply calls Next().

func SetProtectMiddleware

func SetProtectMiddleware(factory func(cfg config.File, logger *slog.Logger) 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL