middleware

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NonceSize is the size of the nonce in bytes (32 bytes = 256 bits)
	NonceSize = 32
	// HSTSOneYear is the number of seconds in one year
	HSTSOneYear = 31536000
	// DefaultTokenLength is the default length for generated tokens
	DefaultTokenLength = 32
	// RateLimitBurst is the number of requests allowed in a burst
	RateLimitBurst = 5
	// CookieMaxAge is the maximum age of cookies in seconds (24 hours)
	CookieMaxAge = 86400
	// StaticFileFavicon is the path to the favicon
	StaticFileFavicon = "/favicon.ico"
	// StaticFileRobots is the path to the robots.txt file
	StaticFileRobots = "/robots.txt"
)
View Source
const CSRFContextKey = "csrf"

CSRFContextKey is the key used to store the CSRF token in the context

Variables

This section is empty.

Functions

func LoggingMiddleware

func LoggingMiddleware(log logging.Logger) echo.MiddlewareFunc

LoggingMiddleware creates a middleware that logs HTTP requests and responses

func NewJWTMiddleware

func NewJWTMiddleware(
	userService user.Service,
	secret string,
	logger logging.Logger,
	cfg *config.Config,
) (echo.MiddlewareFunc, error)

NewJWTMiddleware creates a new JWT middleware

func ValidateCSRFToken

func ValidateCSRFToken(c echo.Context) error

ValidateCSRFToken validates the CSRF token in the request

Types

type CookieAuthMiddleware

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

CookieAuthMiddleware handles cookie-based authentication

func NewCookieAuthMiddleware

func NewCookieAuthMiddleware(userService user.Service, logger logging.Logger) *CookieAuthMiddleware

NewCookieAuthMiddleware creates a new cookie auth middleware

func (*CookieAuthMiddleware) Authenticate

func (m *CookieAuthMiddleware) Authenticate(next echo.HandlerFunc) echo.HandlerFunc

Authenticate middleware attempts to authenticate the user

func (*CookieAuthMiddleware) RefreshToken

func (m *CookieAuthMiddleware) RefreshToken(next echo.HandlerFunc) echo.HandlerFunc

RefreshToken middleware attempts to refresh the token

func (*CookieAuthMiddleware) RequireAuth

func (m *CookieAuthMiddleware) RequireAuth(next echo.HandlerFunc) echo.HandlerFunc

RequireAuth middleware ensures the user is authenticated

func (*CookieAuthMiddleware) RequireNoAuth

func (m *CookieAuthMiddleware) RequireNoAuth(next echo.HandlerFunc) echo.HandlerFunc

RequireNoAuth middleware ensures the user is not authenticated

type EchoValidator

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

EchoValidator wraps the domain validator to implement Echo's Validator interface.

func NewValidator

func NewValidator() *EchoValidator

NewValidator creates a new Echo validator

func (*EchoValidator) Validate

func (v *EchoValidator) Validate(i any) error

Validate implements echo.Validator interface.

type JWTMiddleware

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

JWTMiddleware handles JWT authentication

func (*JWTMiddleware) Handle

func (m *JWTMiddleware) Handle(next echo.HandlerFunc) echo.HandlerFunc

Handle processes JWT authentication

type Manager

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

Manager handles middleware configuration and setup

func New

func New(cfg *ManagerConfig) *Manager

New creates a new middleware manager

func (*Manager) Setup

func (m *Manager) Setup(e *echo.Echo)

Setup initializes the middleware manager with the Echo instance

type ManagerConfig

type ManagerConfig struct {
	Logger      logging.Logger
	UserService user.Service
	Security    *config.SecurityConfig
	Config      *config.Config
}

ManagerConfig holds middleware configuration

Jump to

Keyboard shortcuts

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