securecookie

package module
v0.0.0-...-e3c3b33 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2013 License: MIT Imports: 10 Imported by: 1

README

securecookie

-- import "github.com/andreadipersio/securecookie"

securecookie provide a go implementation of tornado (2.4) secure cookies.

GoDoc

Usage

func CreateSignedValue
func CreateSignedValue(secret, name, value string, createdAt time.Time) string

CreateSignedValue signs and timestamps a string so it cannot be forged.

func DecodeSignedValue
func DecodeSignedValue(secret, name, signedValue string) (string, error)

DecodeSignedValue returns the given signed cookie if it validates, or error.

func GetSecureCookie
func GetSecureCookie(r *http.Response, 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. Secret should be a long, random sequence of bytes

func MustDecodeSignedValue
func MustDecodeSignedValue(secret, name, signedValue string) string
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
func SignCookie(c *http.Cookie, secret string)

SignCookie replace Value of cookie c with a signed string

Documentation

Overview

securecookie provide a go implementation of tornado (2.4) secure cookies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSignedValue

func CreateSignedValue(secret, name, value string, createdAt time.Time) string

CreateSignedValue signs and timestamps a string so it cannot be forged.

func DecodeSignedValue

func DecodeSignedValue(secret, name, signedValue string) (string, error)

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 MustDecodeSignedValue(secret, name, signedValue string) string

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

func SignCookie(c *http.Cookie, secret string)

Types

type WithCookie

type WithCookie interface {
	Cookies() []*http.Cookie
}

WithCookie is usually a http.Request or http.Response.

Jump to

Keyboard shortcuts

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