Documentation ¶
Index ¶
Constants ¶
View Source
const NotPresentErrorString = "http: named cookie not present"
Variables ¶
View Source
var Expired = errors.New("auth cookie expired")
Functions ¶
func GenerateRandomKey ¶
GenerateRandomKey is a convenience method which provides a pass-through to the securecookie.GenerateRandomKey function.
Types ¶
type CookieAuth ¶
type CookieAuth struct {
// contains filtered or unexported fields
}
CookieAuth provides secure pure cookie-based authentication capabilities to sign and set an encrypted userId in a cookie along with the timestamp of when the cookie was signed/created.
func (*CookieAuth) Clear ¶
func (cookieAuth *CookieAuth) Clear(w http.ResponseWriter)
Clear removes the auth cookie.
func (*CookieAuth) Read ¶
func (cookieAuth *CookieAuth) Read(req *http.Request) (userId int64, err error)
Read the cookie from a request and check for expiration.
func (*CookieAuth) Set ¶
func (cookieAuth *CookieAuth) Set(userId int64, w http.ResponseWriter) error
Set sets a userId cookie. Should be applied only after successful authentication.
Click to show internal directories.
Click to hide internal directories.