Documentation ¶
Index ¶
- Variables
- func FromForm(req *http.Request, key string) (string, error)
- func FromHeader(req *http.Request, key string) (string, error)
- func FromQuery(req *http.Request, key string) (string, error)
- func New(store sessions.Store, options ...CSRFOption) *csrf
- func TokenFromRequest(req *http.Request) string
- type CSRFOption
- type TokenContextType
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func FromHeader ¶
Extract the CSRF token from the request header.
func New ¶
func New(store sessions.Store, options ...CSRFOption) *csrf
New returns a new CSRF middleware. Usage:
var store = sessions.NewCookieStore([]byte("secret key")) store.Options = &sessions.Options{ Path: "/", MaxAge: 0, Domain: "localhost", Secure: false, HttpOnly: true, SameSite: http.SameSiteLaxMode, } mux.Use(middleware.New(store).Middleware)
func TokenFromRequest ¶
Types ¶
type CSRFOption ¶
type CSRFOption func(*csrf)
func WithFormKeyName ¶
func WithFormKeyName(name string) CSRFOption
func WithHeaderKeyName ¶
func WithHeaderKeyName(name string) CSRFOption
func WithSessionName ¶
func WithSessionName(name string) CSRFOption
type TokenContextType ¶
type TokenContextType string
Click to show internal directories.
Click to hide internal directories.