csrf_std

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Std

type Std struct {
	// contains filtered or unexported fields
}

func NewStd

func NewStd(ctx context.Context, sm *session.Manager, routeCodeCtxField string) *Std

func (*Std) GetConfig

func (s *Std) GetConfig(pattern string) (*csrf.Config, bool)

func (*Std) Middleware

func (s *Std) Middleware() func(http.Handler) http.Handler

Middleware 中间件 在接口运行过程中 实时查询csrf配置信息,并进行验证

func (*Std) SetConfig

func (s *Std) SetConfig(pattern string, config *csrf.Config)

SetConfig 设置路径的CSRF配置

func (*Std) TokenHandler

func (s *Std) TokenHandler(w http.ResponseWriter, r *http.Request, method, path string, config *csrf.Config) (string, error)

TokenHandler 设置csrf token 前端调用的时候,切记不能每个接口都访问前都访问这个接口,否则会重复设置cookie,导致csrf验证失败。 根据接口的安全程度来设置调用频率即可。

func (*Std) WrapHandler

func (s *Std) WrapHandler(handler http.HandlerFunc) http.HandlerFunc

WrapHandler 包装单个处理器 csrf配置信息,一般时固定好了后不会再改变。

Jump to

Keyboard shortcuts

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