v2
This commit is contained in:
@ -104,6 +104,57 @@ type GrantedPermissionRepository interface {
|
||||
HasAnyPermission(ctx context.Context, tokenType domain.TokenType, tokenID uuid.UUID, scopes []string) (map[string]bool, error)
|
||||
}
|
||||
|
||||
// SessionRepository defines the interface for user session data operations
|
||||
type SessionRepository interface {
|
||||
// Create creates a new user session
|
||||
Create(ctx context.Context, session *domain.UserSession) error
|
||||
|
||||
// GetByID retrieves a session by its ID
|
||||
GetByID(ctx context.Context, sessionID uuid.UUID) (*domain.UserSession, error)
|
||||
|
||||
// GetByUserID retrieves all sessions for a user
|
||||
GetByUserID(ctx context.Context, userID string) ([]*domain.UserSession, error)
|
||||
|
||||
// GetByUserAndApp retrieves sessions for a specific user and application
|
||||
GetByUserAndApp(ctx context.Context, userID, appID string) ([]*domain.UserSession, error)
|
||||
|
||||
// GetActiveByUserID retrieves all active sessions for a user
|
||||
GetActiveByUserID(ctx context.Context, userID string) ([]*domain.UserSession, error)
|
||||
|
||||
// List retrieves sessions with filtering and pagination
|
||||
List(ctx context.Context, req *domain.SessionListRequest) (*domain.SessionListResponse, error)
|
||||
|
||||
// Update updates an existing session
|
||||
Update(ctx context.Context, sessionID uuid.UUID, updates *domain.UpdateSessionRequest) error
|
||||
|
||||
// UpdateActivity updates the last activity timestamp for a session
|
||||
UpdateActivity(ctx context.Context, sessionID uuid.UUID) error
|
||||
|
||||
// Revoke revokes a session
|
||||
Revoke(ctx context.Context, sessionID uuid.UUID, revokedBy string) error
|
||||
|
||||
// RevokeAllByUser revokes all sessions for a user
|
||||
RevokeAllByUser(ctx context.Context, userID string, revokedBy string) error
|
||||
|
||||
// RevokeAllByUserAndApp revokes all sessions for a user and application
|
||||
RevokeAllByUserAndApp(ctx context.Context, userID, appID string, revokedBy string) error
|
||||
|
||||
// ExpireOldSessions marks expired sessions as expired
|
||||
ExpireOldSessions(ctx context.Context) (int, error)
|
||||
|
||||
// DeleteExpiredSessions removes expired sessions older than the specified duration
|
||||
DeleteExpiredSessions(ctx context.Context, olderThan time.Duration) (int, error)
|
||||
|
||||
// Exists checks if a session exists
|
||||
Exists(ctx context.Context, sessionID uuid.UUID) (bool, error)
|
||||
|
||||
// GetSessionCount returns the total number of sessions for a user
|
||||
GetSessionCount(ctx context.Context, userID string) (int, error)
|
||||
|
||||
// GetActiveSessionCount returns the number of active sessions for a user
|
||||
GetActiveSessionCount(ctx context.Context, userID string) (int, error)
|
||||
}
|
||||
|
||||
// DatabaseProvider defines the interface for database operations
|
||||
type DatabaseProvider interface {
|
||||
// GetDB returns the underlying database connection
|
||||
|
||||
Reference in New Issue
Block a user