sessionstore

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package sessionstore is a postgresql backend implementation of gorilla/sessions Session interface, based on antonlindstrom/pgstore. Key change is to use GORM instead of typical sql driver using queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFilesystemStore

func NewFilesystemStore(conf env.ServerConf) *sessions.FilesystemStore

NewFilesystemStore takes session key pairs to create a session-store in the local fs without using a db.

Types

type NewStoreOpts added in v0.10.0

type NewStoreOpts struct {
	SessionRepository repository.SessionRepository
	CookieSecrets     []string
}

type PGStore

type PGStore struct {
	Codecs  []securecookie.Codec
	Options *sessions.Options
	Path    string
	Repo    repository.SessionRepository
}

PGStore is a wrapper around gorilla/sessions store.

func NewStore

func NewStore(opts *NewStoreOpts) (*PGStore, error)

NewStore takes an initialized db and session key pairs to create a session-store in postgres db.

func (*PGStore) Get

func (store *PGStore) Get(r *http.Request, name string) (*sessions.Session, error)

Get Fetches a session for a given name after it has been added to the registry.

func (*PGStore) MaxAge

func (store *PGStore) MaxAge(age int)

MaxAge sets the maximum age for the store and the underlying cookie implementation. Individual sessions can be deleted by setting Options.MaxAge = -1 for that session.

func (*PGStore) MaxLength

func (store *PGStore) MaxLength(l int)

MaxLength restricts the maximum length of new sessions to l. If l is 0 there is no limit to the size of a session, use with caution. The default for a new PGStore is 4096. PostgreSQL allows for max value sizes of up to 1GB (http://www.postgresql.org/docs/current/interactive/datatype-character.html)

func (*PGStore) New

func (store *PGStore) New(r *http.Request, name string) (*sessions.Session, error)

New returns a new session for the given name without adding it to the registry.

func (*PGStore) Save

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

Save saves the given session into the database and deletes cookies if needed

Jump to

Keyboard shortcuts

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