session

package
v0.0.0-...-83de6d7 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultEncryptionKeyLength = 32

DefaultEncryptionKeyLength is the length of the generated encryption keys used for session management.

View Source
const WebauthnSession = "webauthn-session"

WebauthnSession is the name of the session cookie used to manage session- related information.

Variables

View Source
var ErrInsufficientBytesRead = errors.New("insufficient bytes read")

ErrInsufficientBytesRead is returned in the rare case that an unexpected number of bytes are returned from the crypto/rand reader when creating session cookie encryption keys.

View Source
var ErrMarshal = errors.New("error unmarshaling data")

ErrMarshal is returned if unexpected data is present in a webauthn session.

Functions

func GenerateSecureKey

func GenerateSecureKey(n int) ([]byte, error)

GenerateSecureKey reads and returns n bytes from the crypto/rand reader

Types

type Store

type Store struct {
	*sessions.CookieStore
}

Store is a wrapper around sessions.CookieStore which provides some helper methods related to webauthn operations.

func NewStore

func NewStore(keyPairs ...[]byte) (*Store, error)

NewStore returns a new session store.

func (*Store) GetWebauthnSession

func (store *Store) GetWebauthnSession(key string, r *http.Request) (webauthn.SessionData, error)

GetWebauthnSession unmarshals and returns the webauthn session information from the session cookie.

func (*Store) SaveWebauthnSession

func (store *Store) SaveWebauthnSession(key string, data *webauthn.SessionData, r *http.Request, w http.ResponseWriter) error

SaveWebauthnSession marhsals and saves the webauthn data to the provided key given the request and responsewriter

func (*Store) Set

func (store *Store) Set(key string, value interface{}, r *http.Request, w http.ResponseWriter) error

Set stores a value to the session with the provided key.

Jump to

Keyboard shortcuts

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