sessionstore

package
v0.0.0-...-24fb135 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package sessionstore provides a session store for persistence of HTTP session data. The session store is compatible with Gorilla sessions (github.com/gorilla/sessions).

The session store also persists randomly generated secret keying material that is used for generating the keys used to sign and encrypt the secure session cookies. The secret keying material is regularly rotated.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	DB      storage.Provider
	Options sessions.Options
	AppID   string // set if multiple apps share the same storage provider
	Codec   *codec.Codec
}

Store implements the Gorilla Sessions sessions.Store interface for persistence of HTTP session data.

The Store automatically generates and persists random secret keying material that is used for generating the keys used to sign and encrypt the secure session cookies. The secret keying material is regularly rotated.

While all fields are public, they should not be modified once the store is in use.

func New

func New(db storage.Provider, options sessions.Options, appid string) *Store

New creates a new store suitable for persisting sessions. Session data is persisted using db and options provides information about the session cookies. If multiple web applications use the same provider (eg the same database table), then each web application should use a different appid so that they generate and rotate their own, independent secret keying material.

func (*Store) Get

func (ss *Store) Get(r *http.Request, name string) (*sessions.Session, error)

Get returns a cached session.

func (*Store) New

func (ss *Store) New(r *http.Request, name string) (*sessions.Session, error)

New creates and returns a new session.

Note that New should never return a nil session, even in the case of an error if using the Registry infrastructure to cache the session.

func (*Store) Save

func (ss *Store) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error

Save persists session to the underlying store implementation.

Jump to

Keyboard shortcuts

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