Documentation
¶
Index ¶
- Constants
- 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) SessionMiddleware() echo.MiddlewareFunc
- func (sm *Manager) SetSessionCookie(c echo.Context, sessionID string)
- type Session
- type SessionConfig
- type SessionStorage
Constants ¶
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 FileStorage ¶
type FileStorage struct {
// contains filtered or unexported fields
}
FileStorage implements SessionStorage 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 SessionStorage.Delete
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages user sessions
func NewManager ¶
func NewManager( logger logging.Logger, cfg *SessionConfig, lc fx.Lifecycle, accessManager *access.AccessManager, ) *Manager
NewManager creates a new session manager
func (*Manager) ClearSessionCookie ¶
func (sm *Manager) ClearSessionCookie(c echo.Context)
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
func (*Manager) SessionMiddleware ¶ added in v0.2.0
func (sm *Manager) SessionMiddleware() echo.MiddlewareFunc
SessionMiddleware creates a new session middleware
func (*Manager) SetSessionCookie ¶
SetSessionCookie sets the session cookie
type Session ¶
type Session struct { UserID string `json:"user_id"` Email string `json:"email"` Role string `json:"role"` CreatedAt time.Time `json:"created_at"` ExpiresAt time.Time `json:"expires_at"` }
Session represents a user session
type SessionConfig ¶ added in v0.2.0
type SessionConfig 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 }
SessionConfig extends the base config with additional session-specific settings