feat(story-1.4): add session-based authentication with login/logout

This commit is contained in:
Michael committed 2026-02-04 14:44:48 +01:00
1 parent e186a4dd87
commit d67e169a43
8 files changed
+446 -13

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
package domain
import (
"time"
"github.com/google/uuid"
)
// Session represents an active user session.
type Session struct {
ID uuid.UUID `json:"id"`
UserID uuid.UUID `json:"user_id"`
Token string `json:"-"` // Never expose in JSON
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
UserAgent string `json:"user_agent,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
}
// SessionRepository defines the interface for session data access.
type SessionRepository interface {
Create(session *Session) error
GetByToken(token string) (*Session, error)
Delete(token string) error
DeleteByUserID(userID uuid.UUID) error
DeleteExpired() (int64, error)
}