v2
This commit is contained in:
@ -67,3 +67,54 @@ type AuthenticationService interface {
|
||||
// RefreshJWTToken refreshes an existing JWT token
|
||||
RefreshJWTToken(ctx context.Context, tokenString string, newExpiration time.Time) (string, error)
|
||||
}
|
||||
|
||||
// SessionService defines the interface for session management business logic
|
||||
type SessionService interface {
|
||||
// CreateSession creates a new user session
|
||||
CreateSession(ctx context.Context, req *domain.CreateSessionRequest) (*domain.UserSession, error)
|
||||
|
||||
// GetSession retrieves a session by its ID
|
||||
GetSession(ctx context.Context, sessionID uuid.UUID) (*domain.UserSession, error)
|
||||
|
||||
// GetUserSessions retrieves all sessions for a user
|
||||
GetUserSessions(ctx context.Context, userID string) ([]*domain.UserSession, error)
|
||||
|
||||
// GetUserAppSessions retrieves sessions for a specific user and application
|
||||
GetUserAppSessions(ctx context.Context, userID, appID string) ([]*domain.UserSession, error)
|
||||
|
||||
// GetActiveSessions retrieves all active sessions for a user
|
||||
GetActiveSessions(ctx context.Context, userID string) ([]*domain.UserSession, error)
|
||||
|
||||
// ListSessions retrieves sessions with filtering and pagination
|
||||
ListSessions(ctx context.Context, req *domain.SessionListRequest) (*domain.SessionListResponse, error)
|
||||
|
||||
// UpdateSession updates an existing session
|
||||
UpdateSession(ctx context.Context, sessionID uuid.UUID, updates *domain.UpdateSessionRequest) error
|
||||
|
||||
// UpdateSessionActivity updates the last activity timestamp for a session
|
||||
UpdateSessionActivity(ctx context.Context, sessionID uuid.UUID) error
|
||||
|
||||
// RevokeSession revokes a specific session
|
||||
RevokeSession(ctx context.Context, sessionID uuid.UUID, revokedBy string) error
|
||||
|
||||
// RevokeUserSessions revokes all sessions for a user
|
||||
RevokeUserSessions(ctx context.Context, userID string, revokedBy string) error
|
||||
|
||||
// RevokeUserAppSessions revokes all sessions for a user and application
|
||||
RevokeUserAppSessions(ctx context.Context, userID, appID string, revokedBy string) error
|
||||
|
||||
// ValidateSession validates if a session is active and valid
|
||||
ValidateSession(ctx context.Context, sessionID uuid.UUID) (*domain.UserSession, error)
|
||||
|
||||
// RefreshSession refreshes a session's expiration time
|
||||
RefreshSession(ctx context.Context, sessionID uuid.UUID, newExpiration time.Time) error
|
||||
|
||||
// CleanupExpiredSessions marks expired sessions as expired and optionally deletes old ones
|
||||
CleanupExpiredSessions(ctx context.Context, deleteOlderThan *time.Duration) (expired int, deleted int, err error)
|
||||
|
||||
// GetSessionStats returns session statistics for a user
|
||||
GetSessionStats(ctx context.Context, userID string) (total int, active int, err error)
|
||||
|
||||
// CreateOAuth2Session creates a session from OAuth2 authentication flow
|
||||
CreateOAuth2Session(ctx context.Context, userID, appID string, tokenResponse *domain.TokenResponse, userInfo *domain.UserInfo, sessionType domain.SessionType, ipAddress, userAgent string) (*domain.UserSession, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user