Documentation
¶
Index ¶
- Constants
- func LoggingMiddleware(log logging.Logger) echo.MiddlewareFunc
- func NewJWTMiddleware(userService user.Service, secret string, logger logging.Logger, ...) (echo.MiddlewareFunc, error)
- func ValidateCSRFToken(c echo.Context) error
- type CookieAuthMiddleware
- func (m *CookieAuthMiddleware) Authenticate(next echo.HandlerFunc) echo.HandlerFunc
- func (m *CookieAuthMiddleware) RefreshToken(next echo.HandlerFunc) echo.HandlerFunc
- func (m *CookieAuthMiddleware) RequireAuth(next echo.HandlerFunc) echo.HandlerFunc
- func (m *CookieAuthMiddleware) RequireNoAuth(next echo.HandlerFunc) echo.HandlerFunc
- type EchoValidator
- type JWTMiddleware
- type Manager
- type ManagerConfig
Constants ¶
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" )
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 ¶
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 (*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
type ManagerConfig ¶
type ManagerConfig struct {
Logger logging.Logger
UserService user.Service
Security *config.SecurityConfig
Config *config.Config
}
ManagerConfig holds middleware configuration