csrf

package
v2.7.4+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2018 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// CookieName is a name of the cookie
	CookieName = "grv_csrf"
	// HeaderName is the default HTTP request header to inspect
	HeaderName = "X-CSRF-Token"
)

Variables

This section is empty.

Functions

func AddCSRFProtection

func AddCSRFProtection(w http.ResponseWriter, r *http.Request) (string, error)

AddCSRFProtection adds CSRF token into the user session via secure cookie, it implements "double submit cookie" approach to check against CSRF attacks https://www.owasp.org/index.php/Cross-Site_Request_Forgery_%28CSRF%29_Prevention_Cheat_Sheet#Double_Submit_Cookie

func ExtractTokenFromCookie

func ExtractTokenFromCookie(r *http.Request) (string, error)

ExtractTokenFromCookie retrieves a CSRF token from the session cookie.

func VerifyHTTPHeader

func VerifyHTTPHeader(r *http.Request) error

VerifyHTTPHeader checks if HTTP header value matches the cookie.

func VerifyToken

func VerifyToken(token string, r *http.Request) error

VerifyToken validates given token based on HTTP request cookie

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL