Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoToken = errors.New("没有提供CSRF令牌") ErrInvalidToken = errors.New("无效的CSRF令牌") )
Functions ¶
Types ¶
type Options ¶
type Options struct {
// TokenLength 令牌长度
TokenLength int
// TokenExpiry 令牌有效期
TokenExpiry time.Duration
// CookieName CSRF令牌cookie名称
CookieName string
// HeaderName CSRF令牌头名称
HeaderName string
// FormField CSRF令牌表单字段名称
FormField string
// CookiePath Cookie路径
CookiePath string
// CookieDomain Cookie域
CookieDomain string
// CookieSecure 是否只通过HTTPS发送Cookie
CookieSecure bool
// CookieHTTPOnly 是否禁止JavaScript访问Cookie
CookieHTTPOnly bool
// CookieSameSite Cookie的SameSite属性
CookieSameSite http.SameSite
// TrustedOrigins 可信来源列表
TrustedOrigins []string
// IgnoreMethods 忽略的HTTP方法列表
IgnoreMethods []string
// ErrorHandler 错误处理函数
ErrorHandler func(*mist.Context, error)
}
Options CSRF中间件选项
Click to show internal directories.
Click to hide internal directories.