Documentation ¶
Overview ¶
securecookie provide a go implementation of tornado (2.4) secure cookies.
Index ¶
- func CreateSignedValue(secret, name, value string, createdAt time.Time) string
- func DecodeSignedValue(secret, name, signedValue string) (string, error)
- func GetSecureCookie(r WithCookie, secret, name string) (*http.Cookie, error)
- func MustDecodeSignedValue(secret, name, signedValue string) string
- func SetSecureCookie(w http.ResponseWriter, secret string, c *http.Cookie)
- func SignCookie(c *http.Cookie, secret string)
- type WithCookie
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateSignedValue ¶
CreateSignedValue signs and timestamps a string so it cannot be forged.
func DecodeSignedValue ¶
DecodeSignedValue returns the given signed cookie if it validates, or error.
func GetSecureCookie ¶
func GetSecureCookie(r WithCookie, secret, name string) (*http.Cookie, error)
GetSecureCookie returns the named cookie provided in the response or ErrNoCookie if not found, or error if secure cookie value cannot be decoded. r is usually a http.Request if you're in an handler or http.Response if you're dealing with http.Get client response; secret should be a long, random sequence of bytes
func MustDecodeSignedValue ¶
func SetSecureCookie ¶
func SetSecureCookie(w http.ResponseWriter, secret string, c *http.Cookie)
SetSecureCookie signs and timestamps a cookie so it cannot be forged. Secret should be a long, random sequence of bytes to be used as the HMAC secret for the signature. Secure cookies may contain arbitrary byte values, not just unicode strings (unlike regular cookies)
func SignCookie ¶
Types ¶
type WithCookie ¶
WithCookie is usually a http.Request or http.Response.