auth

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 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() 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

func CheckAndRequireBasicAuth(ctx *gin.Context) 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 MaybeThrottleAuthByIP

func MaybeThrottleAuthByIP(ctx *gin.Context) bool

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.

Jump to

Keyboard shortcuts

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