Documentation
¶
Overview ¶
Package session provides session management middleware and utilities for the application.
Index ¶
- Constants
- type Config
- type FileStorage
- type Manager
- func (sm *Manager) ClearSessionCookie(c echo.Context)
- func (sm *Manager) CreateSession(userID, email, role string) (string, error)
- func (sm *Manager) DeleteSession(sessionID string)
- func (sm *Manager) GetCookieName() string
- func (sm *Manager) GetSession(sessionID string) (*Session, bool)
- func (sm *Manager) Middleware() echo.MiddlewareFunc
- func (sm *Manager) SetSessionCookie(c echo.Context, sessionID string)
- type Session
- type Storage
Constants ¶
View Source
const ( // SessionExpiryHours is the number of hours before a session expires SessionExpiryHours = 24 // SessionIDLength is the length of the session ID in bytes SessionIDLength = 32 // SessionKey is a key used in the context SessionKey = "session" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
*config.SessionConfig
*config.Config
PublicPaths []string `json:"public_paths"`
ExemptPaths []string `json:"exempt_paths"`
StaticPaths []string `json:"static_paths"`
ErrorHandler func(c echo.Context, message string) error
}
Config extends the base config with additional session-specific settings
type FileStorage ¶
type FileStorage struct {
// contains filtered or unexported fields
}
FileStorage implements Storage using file system
func NewFileStorage ¶
func NewFileStorage(storeFile string, logger logging.Logger) *FileStorage
NewFileStorage creates a new file-based session storage
func (*FileStorage) Delete ¶
func (fs *FileStorage) Delete(sessionID string) error
Delete implements Storage.Delete
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages user sessions
func NewManager ¶
func NewManager( logger logging.Logger, cfg *Config, lc fx.Lifecycle, accessManager *access.Manager, ) *Manager
NewManager creates a new session manager
func (*Manager) ClearSessionCookie ¶
ClearSessionCookie clears the session cookie
func (*Manager) CreateSession ¶
CreateSession creates a new session for a user
func (*Manager) DeleteSession ¶
DeleteSession removes a session
func (*Manager) GetCookieName ¶
GetCookieName returns the name of the session cookie
func (*Manager) GetSession ¶
GetSession retrieves a session by ID
func (*Manager) Middleware ¶
func (sm *Manager) Middleware() echo.MiddlewareFunc
Middleware creates a new session middleware
Click to show internal directories.
Click to hide internal directories.