csrf

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CSRF_NAME core.Provide = "CSRF"

Variables

This section is empty.

Functions

func CryptoRandom

func CryptoRandom(length int) string

func Guard

func Guard(ctrl *core.DynamicController, ctx *core.Ctx) bool

func Register

func Register(opt *Config) core.Module

Types

type Config

type Config struct {
	GetSecret            func() string
	GetSessionIdentifier func(r *http.Request) string
	CookieOptions        http.Cookie
	Size                 int
	IgnoreMethod         []string
	GetTokenFromRequest  func(*http.Request) string
}

func DefaultConfig

func DefaultConfig(config *Config) (*Config, error)

func InjectCSRF

func InjectCSRF(module *core.DynamicModule) *Config

func (*Config) Generate

func (c *Config) Generate(r *http.Request) string

func (*Config) GetCookie

func (c *Config) GetCookie(token string) *http.Cookie

func (*Config) Verify

func (c *Config) Verify(token string) bool

Jump to

Keyboard shortcuts

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