Documentation
¶
Index ¶
Constants ¶
const (
DefaultCookieName = "csrf_token"
)
Variables ¶
This section is empty.
Functions ¶
func HandleFunc ¶
func HandleFunc(secretKey []byte, opts ...Option) xun.HandleFunc
HandleFunc serves the JavaScript token required for the CSRF middleware.
It takes the secret key and options to customize the behavior. See the Option type for more information.
func New ¶
func New(secretKey []byte, opts ...Option) xun.Middleware
New returns a middleware that generates a CSRF token and validates it in the request.
The opts parameter is a list of Option functions that can be used to customize the behavior of the CSRF middleware. See the Option type for more information.
Types ¶
type Option ¶
type Option func(o *Options)
Option is a function type that takes a pointer to Options and modifies it. It is used to customize the behavior of the CSRF middleware.
func WithCookie ¶
WithCookie sets the name of the cookie to use for storing the CSRF token. Defaults to "csrf_token".
func WithJsToken ¶
func WithJsToken() Option
WithJsToken enables the JavaScript token feature for CSRF protection.
It sets the JsToken field in the Options struct to true, allowing the middleware to generate and handle CSRF tokens via JavaScript.