net: golang.org/x/net/xsrftoken Index | Files

package xsrftoken

import "golang.org/x/net/xsrftoken"

Package xsrftoken provides methods for generating and validating secure XSRF tokens.

Index

Package Files

xsrf.go

Constants

const Timeout = 24 * time.Hour

Timeout is the duration for which XSRF tokens are valid. It is exported so clients may set cookie timeouts that match generated tokens.

func Generate

func Generate(key, userID, actionID string) string

Generate returns a URL-safe secure XSRF token that expires in 24 hours.

key is a secret key for your application. userID is a unique identifier for the user. actionID is the action the user is taking (e.g. POSTing to a particular path).

func Valid

func Valid(token, key, userID, actionID string) bool

Valid reports whether a token is a valid, unexpired token returned by Generate.

Package xsrftoken imports 8 packages (graph) and is imported by 3 packages. Updated 6 days ago. Refresh now. Tools for package owners.