Documentation ¶
Index ¶
Constants ¶
View Source
const ( ErrTokenNotFound = "CSRF token not found" ErrTokenMismatch = "CSRF token mismatch" ErrRefererNotSpecified = "Referer not specified" ErrRefererMismatch = "Referer mismatch" )
Default errors to use
View Source
const ( CSRF_TOKEN_COOKIE_NAME = "csrf_token" CSRF_TOKEN_HEADER_NAME = "X-CSRF-Token" CSRF_TOKEN_FORMFIELD_NAME = "csrf_token" CSRF_TOKEN_COOKIE_EXPIRE = time.Hour * 24 CSRF_TOKEN_COOKIE_MAX_AGE = 3600 CSRF_TOKEN_COOKIE_SECURE = false CSRF_TOKEN_COOKIE_HTTP_ONLY = true )
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
func Middleware(next router.Handler) router.Handler
func Token ¶
Get the token for a given request once the middleware has been run If the token is not found, an empty string is returned
func VerifyToken ¶
VerifyToken verifies the sent token equals the real one and returns a bool value indicating if tokens are equal. Supports masked tokens. realToken comes from Token(r) and sentToken is token sent unusual way.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.