Documentation
¶
Overview ¶
Package csrf provides Cross-Site Request Forgery protection using the double-submit-cookie pattern. A random token is issued in a cookie and, for state-changing requests, must be echoed back in a request header or form field. Requests whose submitted token does not match the cookie are rejected with 403 Forbidden.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// CookieName is the name of the cookie that stores the token
// (default "csrf").
CookieName string
// Header is the request header inspected for the submitted token
// (default "X-CSRF-Token").
Header string
// FormField is the form field inspected for the submitted token when the
// header is absent (default "_csrf").
FormField string
// MaxAge sets the token cookie Max-Age in seconds (0 = session cookie).
MaxAge int
// Secure marks the token cookie Secure (HTTPS only).
Secure bool
}
Options configures the CSRF middleware.
Click to show internal directories.
Click to hide internal directories.