session

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CookieName is the name of the session cookie
	CookieName = "forrus_cookie"
	// SessionTTL is the time-to-live for sessions (7 days)
	SessionTTL = 7 * 24 * time.Hour
	// CleanupInterval is how often to run the cleanup goroutine
	CleanupInterval = 1 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager manages user sessions in memory

func NewManager

func NewManager() *Manager

NewManager creates a new session manager and starts the cleanup goroutine

func (*Manager) CreateSession

func (m *Manager) CreateSession(ctx context.Context, forgejoAuthID int32, username, issuer string) (*Session, error)

CreateSession creates a new session for the user

func (*Manager) DeleteSession

func (m *Manager) DeleteSession(ctx context.Context, sessionID string)

DeleteSession removes a session

func (*Manager) GetSession

func (m *Manager) GetSession(ctx context.Context, sessionID string) (*Session, bool)

GetSession retrieves a session by ID and updates last accessed time

func (*Manager) IsValid

func (m *Manager) IsValid(ctx context.Context, sessionID string) bool

IsValid checks if a session exists and is valid

func (*Manager) Stop

func (m *Manager) Stop()

Stop stops the cleanup goroutine

type Session

type Session struct {
	ID             string
	ForgejoAuthID  int32
	Username       string
	Issuer         string
	CreatedAt      time.Time
	LastAccessedAt time.Time
	ExpiresAt      time.Time
}

Session represents a user session

func (*Session) IsValid

func (s *Session) IsValid() bool

IsValid checks if the session is still valid

Jump to

Keyboard shortcuts

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