cookiestore

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CookieStore

type CookieStore struct {
	// contains filtered or unexported fields
}

CookieStore represents the currently configured session store.

func New

func New(key []byte, oldKeys ...[]byte) *CookieStore

New returns a new CookieStore instance.

The key parameter should contain the secret you want to use to authenticate and encrypt session cookies. This should be exactly 32 bytes long.

Optionally, the variadic oldKeys parameter can be used to provide an arbitrary number of old Keys. This should be used to ensure that valid cookies continue to work correctly after key rotation.

func (*CookieStore) Delete

func (c *CookieStore) Delete(token string) error

Delete is a no-op. The function exists only to ensure that a CookieStore instance satisfies the scs.Store interface.

func (*CookieStore) Find

func (c *CookieStore) Find(token string) (b []byte, exists bool, error error)

Find returns the session data for given cookie token. It loops through all available keys (including old keys) to try to decode the cookie. If the cookie could not be decoded, or has expired, the returned exists flag will be set to false.

func (*CookieStore) MakeToken

func (c *CookieStore) MakeToken(b []byte, expiry time.Time) (token string, err error)

MakeToken creates a signed, optionally encrypted, cookie token for the provided session data. The returned token is limited to 4096 characters in length. An error will be returned if this is exceeded.

func (*CookieStore) Save

func (c *CookieStore) Save(token string, b []byte, expiry time.Time) error

Save is a no-op. The function exists only to ensure that a CookieStore instance satisfies the scs.Store interface.

Jump to

Keyboard shortcuts

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