session

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSessionNotFound = errors.New("session: session not found")
)

Common errors

Functions

func Count

func Count(store kvs.Store) (int, error)

Count returns the number of active sessions in KVS.

func Delete

func Delete(store kvs.Store, id string) error

Delete removes a session from KVS by ID.

func Set

func Set(store kvs.Store, id string, session *Session) error

Set stores a session in KVS with the given ID. The session's ExpiresAt field is used to calculate the TTL.

Types

type Session

type Session struct {
	ID            string
	Email         string
	Name          string                 // User's display name from OAuth2 provider
	Provider      string                 // OAuth2 provider name or "email" for email auth
	Extra         map[string]interface{} // Additional user data from OAuth2 provider (for custom forwarding)
	CreatedAt     time.Time
	ExpiresAt     time.Time
	Authenticated bool
}

Session represents a user session

func Get

func Get(store kvs.Store, id string) (*Session, error)

Get retrieves a session from KVS by ID. Returns ErrSessionNotFound if the session doesn't exist or has expired.

func List

func List(store kvs.Store) ([]*Session, error)

List returns all active sessions from KVS.

func (*Session) IsValid

func (s *Session) IsValid() bool

IsValid checks if the session is still valid

type Store

type Store = kvs.Store

Store is an alias for kvs.Store for backward compatibility Use the session helper functions (Get, Set, Delete) to work with sessions

Jump to

Keyboard shortcuts

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