csrf

package
v0.19.6 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) zeroapi.Handler

New 为请求填充 csrf 需要启用 cache 功能

func Verify

func Verify(opts ...Option) zeroapi.Handler

Verify 验证 csrf

Types

type Option

type Option struct {
	// Key 生成 token 使用的密钥
	Key string

	// CookieName token 在 cookie 中的名字
	CookieName string
	// HeaderName token 在 header 中的名字
	HeaderName string
	// BodyName token 在 body 中的名字
	BodyName string
	// QueryName token 在 query 中的名字
	QueryName string

	// CookieMaxAge cookie 有效时间,秒,默认为 24小时
	CookieMaxAge int
	// CookieDomain ..
	CookieDomain string
	// CookiePath ..
	CookiePath string
	// CookieHTTPOnly
	CookieHTTPOnly bool

	// Methods 这些方法参与验证
	Methods []string

	// IgnoreFunc 忽略检测,返回 true 表示不检测
	IgnoreFunc func(ctx zeroapi.Context) bool
}

Option ..

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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