Documentation
¶
Overview ¶
CSRF protection.
Version: 0.0.1. Repository: https://github.com/ordinary-dev/go-sfl. License: MIT.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCSRFToken ¶
Get CSRF token generated by the CSRF middleware.
Types ¶
type Protection ¶
type Protection struct {
CookieName string // Name of the cookie with the first CSRF token.
Secure bool // `Secure` cookie attribute.
SameSite http.SameSite // `SameSite` cookie attribute.
FormFieldName string // Name of the form field with the second token.
HeaderName string // Name of the header with the second token.
TokenLength uint // Length of generated CSRF tokens in bytes (symbols).
}
func Default ¶
func Default() Protection
Create a new instance of CSRF protection. You can tweak settings after initialization.
func (*Protection) Middleware ¶
func (p *Protection) Middleware(next http.Handler) http.Handler
Middleware to prevent CSRF attacks.
Click to show internal directories.
Click to hide internal directories.