mid

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: MPL-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrModSecMaliciousRequest = errors.New("malicious request")

Functions

func Denylist added in v0.6.8

func Denylist(options *DenylistOptions) web.Middleware

Denylist forbidden requests with tokens in the blacklist

func Errors

func Errors(logger zerolog.Logger) web.Middleware

Errors handles errors coming out of the call chain. It detects normal application errors which are used to respond to the client in a uniform way. Unexpected errors (status >= 500) are logged.

func IPAllowlist added in v0.6.16

func IPAllowlist(options *IPAllowListOptions) web.Middleware

The IPAllowlist function checks if an IP is allowed else gives error

func Logger

func Logger(logger zerolog.Logger) web.Middleware

Logger writes some information about the request to the logs in the format: TraceID : (200) GET /foo -> IP ADDR (latency)

func MIMETypeIdentifier added in v0.6.12

func MIMETypeIdentifier(logger zerolog.Logger) web.Middleware

MIMETypeIdentifier identifies the MIME type of the content in case of CT header is missing

func Panics

func Panics(logger zerolog.Logger) web.Middleware

Panics recovers from panics and converts the panic to an error so it is reported in Metrics and handled in Errors.

func Proxy

func Proxy(options *ProxyOptions) web.Middleware

Proxy changes request scheme before request

func ShadowAPIMonitor added in v0.6.12

func ShadowAPIMonitor(logger zerolog.Logger, cfg *config.ShadowAPI) web.Middleware

ShadowAPIMonitor check each request for the params, methods or paths that are not specified in the OpenAPI specification and log each violation

func WAFModSecurity added in v0.7.0

func WAFModSecurity(options *ModSecurityOptions) web.Middleware

Types

type DenylistOptions added in v0.6.13

type DenylistOptions struct {
	Mode                  string
	Config                *config.Denylist
	CustomBlockStatusCode int
	DeniedTokens          *denylist.DeniedTokens
	Logger                zerolog.Logger
}

type IPAllowListOptions added in v0.6.16

type IPAllowListOptions struct {
	Mode                  string
	Config                *config.AllowIP
	CustomBlockStatusCode int
	AllowedIPs            *allowiplist.AllowedIPsType
	Logger                zerolog.Logger
}

type ModSecurityOptions added in v0.7.0

type ModSecurityOptions struct {
	Mode                  string
	WAF                   coraza.WAF
	RequestValidation     string
	ResponseValidation    string
	CustomBlockStatusCode int
	Logger                zerolog.Logger
}

type ProxyOptions added in v0.6.13

type ProxyOptions struct {
	Mode                 string
	RequestValidation    string
	DeleteAcceptEncoding bool
	ServerURL            *url.URL
}

Jump to

Keyboard shortcuts

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