session

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package session standardizes session management with Gorilla sessions

Index

Constants

View Source
const FlashErrorsKey = "_flash_errors"

Variables

This section is empty.

Functions

func AddErrorMessage

func AddErrorMessage(s *sessions.Session, message string)

func GetErrorMessages

func GetErrorMessages(s *sessions.Session) ([]string, error)

func Invalidate

func Invalidate(s *sessions.Session)

func NewCSRFMiddleware

func NewCSRFMiddleware(config Config, opts ...csrf.Option) func(http.Handler) http.Handler

func Regenerate

func Regenerate(s *sessions.Session)

Types

type CSRFOptions

type CSRFOptions struct {
	HeaderName string
	FieldName  string
}

type CSRFTokenChecker

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

func NewCSRFTokenChecker

func NewCSRFTokenChecker(config Config) *CSRFTokenChecker

func (*CSRFTokenChecker) Check

func (c *CSRFTokenChecker) Check(r *http.Request, token string) error

type Config

type Config struct {
	AuthKey       []byte
	EncryptionKey []byte
	Timeouts      Timeouts
	CookieOptions sessions.Options
	CookieName    string
	CSRFOptions   CSRFOptions
}

func GetConfig

func GetConfig() (c Config, err error)

type Store

type Store struct {
	Config       Config
	BackingStore sessions.Store
	Codecs       []securecookie.Codec
}

func (*Store) CSRFOptions

func (ss *Store) CSRFOptions() CSRFOptions

func (*Store) Get

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

func (*Store) Lookup

func (ss *Store) Lookup(id string) (*sessions.Session, error)

func (*Store) New

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

func (*Store) NewCSRFMiddleware

func (ss *Store) NewCSRFMiddleware(opts ...csrf.Option) func(http.Handler) http.Handler

type Timeouts

type Timeouts struct {
	Absolute time.Duration
}

Directories

Path Synopsis
Package memstore provides an in-RAM (non-persistent) session store
Package memstore provides an in-RAM (non-persistent) session store
Package sqlitestore store provides a sqlite-backed session store using [database.DB]
Package sqlitestore store provides a sqlite-backed session store using [database.DB]

Jump to

Keyboard shortcuts

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