Documentation
¶
Index ¶
- type CSRFHookID
- type CSRFPlugin
- func (p *CSRFPlugin) Close() error
- func (p *CSRFPlugin) Config() any
- func (p *CSRFPlugin) Hooks() []models.Hook
- func (p *CSRFPlugin) Init(ctx *models.PluginContext) error
- func (p *CSRFPlugin) Metadata() models.PluginMetadata
- func (p *CSRFPlugin) Middleware() func(http.Handler) http.Handler
- func (p *CSRFPlugin) OnConfigUpdate(config *models.Config) error
- type CSRFPluginConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CSRFHookID ¶
type CSRFHookID string
const ( // HookIDCSRFGenerate identifies the CSRF token generation hook. // Generates CSRF tokens for safe requests HookIDCSRFGenerate CSRFHookID = "csrf.generate" // HookIDCSRFProtect identifies the CSRF protection hook. // Validates CSRF tokens on state-changing requests HookIDCSRFProtect CSRFHookID = "csrf.protect" )
Constants for CSRF plugin hook IDs and metadata
func (CSRFHookID) String ¶
func (id CSRFHookID) String() string
type CSRFPlugin ¶
type CSRFPlugin struct {
// contains filtered or unexported fields
}
func New ¶
func New(config CSRFPluginConfig) *CSRFPlugin
func (*CSRFPlugin) Close ¶
func (p *CSRFPlugin) Close() error
func (*CSRFPlugin) Config ¶
func (p *CSRFPlugin) Config() any
func (*CSRFPlugin) Hooks ¶
func (p *CSRFPlugin) Hooks() []models.Hook
Hooks implements models.PluginWithHooks to provide CSRF protection via hooks
func (*CSRFPlugin) Init ¶
func (p *CSRFPlugin) Init(ctx *models.PluginContext) error
func (*CSRFPlugin) Metadata ¶
func (p *CSRFPlugin) Metadata() models.PluginMetadata
func (*CSRFPlugin) Middleware ¶
func (p *CSRFPlugin) Middleware() func(http.Handler) http.Handler
Middleware returns a CSRF protection middleware that users can add to custom routes.
func (*CSRFPlugin) OnConfigUpdate ¶
func (p *CSRFPlugin) OnConfigUpdate(config *models.Config) error
type CSRFPluginConfig ¶
type CSRFPluginConfig struct {
Enabled bool `json:"enabled" toml:"enabled"`
CookieName string `json:"cookie_name" toml:"cookie_name"`
HeaderName string `json:"header_name" toml:"header_name"`
MaxAge time.Duration `json:"max_age" toml:"max_age"`
Secure bool `json:"secure" toml:"secure"`
SameSite string `json:"same_site" toml:"same_site"`
EnableHeaderProtection bool `json:"enable_header_protection" toml:"enable_header_protection"`
}
func (*CSRFPluginConfig) ApplyDefaults ¶
func (config *CSRFPluginConfig) ApplyDefaults()
Click to show internal directories.
Click to hide internal directories.