middlewares

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth() gin.HandlerFunc

BasicAuth is a middleware that checks if the user is authenticated. It skips authentication for the paths in ConfigProxyGuardPolicy().WhiteList. It seeks the proxy_token query parameter to authenticate the user. Otherwise, it seeks the user session. If the user is not authenticated, it redirects to the login page.

func CORS

func CORS() gin.HandlerFunc

func CSRF

func CSRF() gin.HandlerFunc

CSRF is a middleware that checks if the CSRF token is valid.

func GeoLocation added in v0.0.15

func GeoLocation() gin.HandlerFunc

GeoLocation is a middleware that checks if the client is in Germany. It uses the IP2Location API to lookup the client IP address. If the client is not in expected country, it returns 403 Forbidden.

func Logger

func Logger() gin.HandlerFunc

Logger is a middleware that logs the request and response headers.

func ProxyGuard added in v0.0.12

func ProxyGuard() gin.HandlerFunc

ProxyGuard is a middleware that checks if the request is allowed. It evaluates ABAC rules to authorize the request. It uses the ConfigProxyGuardPolicy().BlackList for evaluation.

func Rate

func Rate(rps float64, burst int) gin.HandlerFunc

Rate is a middleware that limits the request rate. It uses the token bucket algorithm to limit the request rate. rps is the rate per second. burst is the maximum number of requests that can be made at once. It tries to wait for a token before processing the request. If the rate limit is exceeded, it returns 429 Too Many Requests.

func Recover

func Recover() gin.HandlerFunc

Recover is a middleware that recovers from panics. It logs the error and returns a 500 Internal Server Error.

func Session

func Session() gin.HandlerFunc

Session is a middleware that manages the session. It sets the session cookie with the domain and secret. If the domain is empty, it will log a fatal error. If the secret is at least 64 bytes, it setup an AES-GCM encryption.

Types

This section is empty.

Jump to

Keyboard shortcuts

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