security

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	RateLimit      config.RateLimitConfig
	CircuitBreaker config.CircuitBreakerConfig
	CORS           config.CORSConfig
}

Config holds security middleware configuration

type SecurityMiddleware

type SecurityMiddleware struct {
	// contains filtered or unexported fields
}

SecurityMiddleware provides security-related middleware

func NewSecurityMiddleware

func NewSecurityMiddleware(config Config, logger logger.Logger) (*SecurityMiddleware, error)

NewSecurityMiddleware creates a new security middleware instance

func (*SecurityMiddleware) CORS

func (s *SecurityMiddleware) CORS(corsConfig config.CORSConfig) gin.HandlerFunc

CORS middleware handles Cross-Origin Resource Sharing

func (*SecurityMiddleware) CSRFProtection

func (s *SecurityMiddleware) CSRFProtection() gin.HandlerFunc

CSRFProtection middleware provides CSRF protection

func (*SecurityMiddleware) IPWhitelist

func (s *SecurityMiddleware) IPWhitelist(allowedIPs []string) gin.HandlerFunc

IPWhitelist middleware allows only whitelisted IPs

func (*SecurityMiddleware) InputValidation

func (s *SecurityMiddleware) InputValidation() gin.HandlerFunc

InputValidation middleware validates input for common security threats

func (*SecurityMiddleware) RateLimit

RateLimit middleware implements rate limiting per client IP

func (*SecurityMiddleware) RequestSizeLimit

func (s *SecurityMiddleware) RequestSizeLimit(maxSize int64) gin.HandlerFunc

RequestSizeLimit middleware limits the size of request bodies

func (*SecurityMiddleware) SecurityHeaders

func (s *SecurityMiddleware) SecurityHeaders() gin.HandlerFunc

SecurityHeaders middleware adds security headers

Jump to

Keyboard shortcuts

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