Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CSRF ¶
func CSRF() handler.Middleware
Types ¶
type Config ¶
type Config struct {
Skipper handler.Skipper
// Exclude is a list of http paths to exclude from JWT auth
//
// path format must same as url.URL.Path started with "/" and ended with "/"
Exclude []string `json:"exclude" yaml:"exclude"`
// TokenLength is the length of the generated token.
// Optional. Default value 32.
TokenLength uint8 `yaml:"tokenLength"`
AuthKey string `json:"authKey" yaml:"authKey"`
// Default: X-CSRF-Token
RequestHeader string `json:"requestHeader" yaml:"requestHeader"`
Cookie *CookieConfig `json:"cookie" yaml:"cookie"`
TrustedOrigins []string `json:"trustedOrigins" yaml:"trustedOrigins"`
}
type CookieConfig ¶
type CookieConfig struct {
Name string `json:"name" yaml:"name"`
Path string `json:"path" yaml:"path"`
Domain string `json:"domain" yaml:"domain"`
MaxAge int `json:"maxAge" yaml:"maxAge"`
Secure bool `json:"secure" yaml:"secure"`
HttpOnly bool `json:"httpOnly" yaml:"httpOnly"` //nolint:stylecheck
SameSite http.SameSite `json:"sameSite" yaml:"sameSite"`
}
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware implements a Cross-Site Request Forgery (CSRF) protection middleware.
func NewMiddleware ¶
func NewMiddleware() *Middleware
func (*Middleware) ApplyFunc ¶
func (mw *Middleware) ApplyFunc(cfg *conf.Configuration) gin.HandlerFunc
func (*Middleware) Name ¶
func (mw *Middleware) Name() string
func (*Middleware) ServeHTTP ¶
func (mw *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP empty implementation for csrf.Protect
Click to show internal directories.
Click to hide internal directories.