Documentation
¶
Overview ¶
SPDX-License-Identifier: AGPL-3.0-or-later
SPDX-License-Identifier: AGPL-3.0-or-later
SPDX-License-Identifier: AGPL-3.0-or-later
Index ¶
- type SessionRepository
- type SessionService
- func (s *SessionService) GetNewSession(r *http.Request) (*sessions.Session, error)
- func (s *SessionService) GetSession(r *http.Request) (*sessions.Session, error)
- func (s *SessionService) GetUser(r *http.Request) (*models.User, error)
- func (s *SessionService) Logout(w http.ResponseWriter, r *http.Request)
- func (s *SessionService) SetUser(w http.ResponseWriter, r *http.Request, user *models.User) error
- func (s *SessionService) StoreRefreshToken(ctx context.Context, w http.ResponseWriter, r *http.Request, ...) error
- type SessionServiceConfig
- type SessionWorker
- type SessionWorkerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SessionRepository ¶
type SessionRepository interface {
Create(ctx context.Context, session *models.OAuthSession) error
GetBySessionID(ctx context.Context, sessionID string) (*models.OAuthSession, error)
UpdateRefreshToken(ctx context.Context, sessionID string, encryptedToken []byte, expiresAt time.Time) error
DeleteBySessionID(ctx context.Context, sessionID string) error
DeleteExpired(ctx context.Context, olderThan time.Duration) (int64, error)
}
SessionRepository defines the interface for OAuth session storage
type SessionService ¶ added in v1.2.1
type SessionService struct {
// contains filtered or unexported fields
}
SessionService manages user sessions independently of authentication method This service is always required, regardless of whether OAuth or MagicLink is used
func NewSessionService ¶ added in v1.2.1
func NewSessionService(config SessionServiceConfig) *SessionService
NewSessionService creates a new session service
func (*SessionService) GetNewSession ¶ added in v1.2.1
GetNewSession creates a new session
func (*SessionService) GetSession ¶ added in v1.2.1
GetSession returns the raw session (useful for storing additional data like OAuth state)
func (*SessionService) GetUser ¶ added in v1.2.1
GetUser retrieves the authenticated user from the session
func (*SessionService) Logout ¶ added in v1.2.1
func (s *SessionService) Logout(w http.ResponseWriter, r *http.Request)
Logout clears the user session
func (*SessionService) SetUser ¶ added in v1.2.1
func (s *SessionService) SetUser(w http.ResponseWriter, r *http.Request, user *models.User) error
SetUser stores a user in the session (works for both OAuth and MagicLink)
func (*SessionService) StoreRefreshToken ¶ added in v1.2.1
func (s *SessionService) StoreRefreshToken(ctx context.Context, w http.ResponseWriter, r *http.Request, token *oauth2.Token, user *models.User) error
StoreRefreshToken encrypts and stores the OAuth refresh token This is called by OAuthProvider after successful authentication
type SessionServiceConfig ¶ added in v1.2.1
type SessionServiceConfig struct {
CookieSecret []byte
SecureCookies bool
SessionRepo SessionRepository
}
SessionServiceConfig holds configuration for the session service
type SessionWorker ¶
type SessionWorker struct {
// contains filtered or unexported fields
}
SessionWorker handles background cleanup of expired OAuth sessions
func NewSessionWorker ¶
func NewSessionWorker(sessionRepo SessionRepository, config SessionWorkerConfig, parentCtx context.Context, db *sql.DB, tenants tenant.Provider) *SessionWorker
NewSessionWorker creates a new OAuth session cleanup worker
type SessionWorkerConfig ¶
type SessionWorkerConfig struct {
CleanupInterval time.Duration // How often to run cleanup (default: 24 hours)
CleanupAge time.Duration // Age of sessions to delete (default: 37 days = 30 + 7 grace period)
}
SessionWorkerConfig contains configuration for the session worker
func DefaultSessionWorkerConfig ¶
func DefaultSessionWorkerConfig() SessionWorkerConfig
DefaultSessionWorkerConfig returns default session worker configuration