Skip to content

Instantly share code, notes, and snippets.

@ntakouris
Created August 5, 2017 18:48
Show Gist options
  • Save ntakouris/1a6606a84f1ea0563482c3eab294d105 to your computer and use it in GitHub Desktop.
Save ntakouris/1a6606a84f1ea0563482c3eab294d105 to your computer and use it in GitHub Desktop.
store.go fragment
// store represents the session storage used for CSRF tokens.
type store interface {
 // Get returns the real CSRF token from the store.
 Get(*http.Request) ([]byte, error)
 // Save stores the real CSRF token in the store and writes a
 // cookie to the http.ResponseWriter.
 // For non-cookie stores, the cookie should contain a unique (256 bit) ID
 // or key that references the token in the backend store.
 // csrf.GenerateRandomBytes is a helper function for generating secure IDs.
 Save(token []byte, w http.ResponseWriter) error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment