session

package
v0.0.0-...-fd1ce1a Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPayloadTooShort = errors.New("payload too short; not enough space for nonce")
)

Functions

func GenSessionID

func GenSessionID() []byte

func GetKeys

func GetKeys() (keys [][32]byte, err error)

func ReadCookie

func ReadCookie[T CookieReader](store Store, req *http.Request, val T) error

func WriteCookie

func WriteCookie[T CookieWriter](store Store, req *http.Request, w http.ResponseWriter, val T) error

Types

type CookieReader

type CookieReader interface {
	Unseal(Store, Payload) error
	CookieName() string
}

type CookieWriter

type CookieWriter interface {
	Seal(Store) (string, error)
	CookieName() string
}

type GrainSession

type GrainSession struct {
	GrainID   types.GrainID `capnp:"grainId"`
	SessionID []byte        `capnp:"sessionId"`
}

func (GrainSession) CookieName

func (sess GrainSession) CookieName() string

func (GrainSession) Seal

func (sess GrainSession) Seal(store Store) (string, error)

func (*GrainSession) Unseal

func (sess *GrainSession) Unseal(store Store, payload Payload) error

type Payload

type Payload struct {
	CookieName string
	Data       string
}

func (Payload) ToCookie

func (p Payload) ToCookie(isHttps bool) *http.Cookie

type Store

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

func NewStore

func NewStore(keys [][32]byte) Store

type UserSession

type UserSession struct {
	SessionID  []byte `capnp:"sessionId"`
	Credential types.Credential
}

func (UserSession) CookieName

func (sess UserSession) CookieName() string

func (UserSession) Seal

func (sess UserSession) Seal(store Store) (string, error)

func (*UserSession) Unseal

func (sess *UserSession) Unseal(store Store, payload Payload) error

Jump to

Keyboard shortcuts

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