Documentation
¶
Overview ¶
Package session implements session storage.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrLocalStorageIsNotAvailable = xerrors.New("localStorage is not available")
ErrLocalStorageIsNotAvailable is returned if localStorage is not available and Storage can't use it.
var ErrNotFound = errors.New("session storage: not found")
ErrNotFound means that session is not found in storage.
Functions ¶
This section is empty.
Types ¶
type FileStorage ¶
type FileStorage struct {
Path string
// contains filtered or unexported fields
}
FileStorage implements SessionStorage for file system as file stored in Path.
func (*FileStorage) LoadSession ¶
func (f *FileStorage) LoadSession(_ context.Context) ([]byte, error)
LoadSession loads session from file.
func (*FileStorage) StoreSession ¶
func (f *FileStorage) StoreSession(_ context.Context, data []byte) error
StoreSession stores session to file.
type Loader ¶
type Loader struct {
Storage Storage
}
Loader wraps Storage implementing Data (un-)marshaling.
type Storage ¶
type Storage interface {
LoadSession(ctx context.Context) ([]byte, error)
StoreSession(ctx context.Context, data []byte) error
}
Storage is secure persistent storage for client session.
NB: Implementation security is important, attacker can abuse it not only for connecting as authenticated user or bot, but even decrypting previous messages in some situations.
type StorageMemory ¶
type StorageMemory struct {
// contains filtered or unexported fields
}
StorageMemory implements in-memory session storage. Goroutine-safe.
func (*StorageMemory) LoadSession ¶
func (s *StorageMemory) LoadSession(ctx context.Context) ([]byte, error)
LoadSession loads session from memory.
func (*StorageMemory) StoreSession ¶
func (s *StorageMemory) StoreSession(ctx context.Context, data []byte) error
StoreSession stores session to memory.
type WebLocalStorage ¶ added in v0.40.0
type WebLocalStorage struct {
Key string
}
WebLocalStorage is a Web Storage API based session storage.
func (WebLocalStorage) LoadSession ¶ added in v0.40.0
func (w WebLocalStorage) LoadSession(_ context.Context) (_ []byte, rerr error)
LoadSession loads session using Web Storage API.
func (WebLocalStorage) StoreSession ¶ added in v0.40.0
func (w WebLocalStorage) StoreSession(_ context.Context, data []byte) (rerr error)
StoreSession saves session using Web Storage API.