cookieauth

package
v0.0.0-...-785fa05 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2018 License: MIT Imports: 7 Imported by: 0

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

func GenerateRandomKey(length int) []byte

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 New

func New(hashKey []byte, blockKey []byte, cookieName string, expireAfter time.Duration) *CookieAuth

New creates a new instance of CookieAuth.

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.

Jump to

Keyboard shortcuts

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