Documentation
¶
Index ¶
- func BaseEndpoints() []core.Endpoint
- type EndpointRegistry
- type FakeCache
- func (f *FakeCache) Clear() error
- func (f *FakeCache) Delete(tokenHash string) error
- func (f *FakeCache) Get(tokenHash string) (*core.Session, error)
- func (f *FakeCache) Len() int
- func (f *FakeCache) Set(tokenHash string, session *core.Session) error
- func (f *FakeCache) SetDeleteError(err error)
- func (f *FakeCache) SetGetError(err error)
- func (f *FakeCache) SetSetError(err error)
- func (f *FakeCache) Stats() core.CacheStats
- type FakeSessionStorage
- func (f *FakeSessionStorage) CreateSession(s *core.Session) error
- func (f *FakeSessionStorage) DeleteExpiredSessions() (int, error)
- func (f *FakeSessionStorage) DeleteSessionByHash(tokenHash string) error
- func (f *FakeSessionStorage) DeleteSessionByID(id string) error
- func (f *FakeSessionStorage) DeleteUserSessions(userID string) (int, error)
- func (f *FakeSessionStorage) GetSessionByHash(tokenHash string) (*core.Session, error)
- func (f *FakeSessionStorage) GetSessionByID(id string) (*core.Session, error)
- func (f *FakeSessionStorage) GetUserSessions(userID string) ([]*core.Session, error)
- func (f *FakeSessionStorage) UpdateSession(s *core.Session) error
- type FakeStorageProvider
- func (f *FakeStorageProvider) CreateAccount(a *core.Account) error
- func (f *FakeStorageProvider) CreateUser(u *core.User) error
- func (f *FakeStorageProvider) DeleteAccount(id string) error
- func (f *FakeStorageProvider) DeleteUser(id string) error
- func (f *FakeStorageProvider) GetAccountByID(id string) (*core.Account, error)
- func (f *FakeStorageProvider) GetAccountByUserAndProvider(userID, providerID string) ([]*core.Account, error)
- func (f *FakeStorageProvider) GetUserByEmail(email string) (*core.User, error)
- func (f *FakeStorageProvider) GetUserByID(id string) (*core.User, error)
- func (f *FakeStorageProvider) UpdateAccount(a *core.Account) error
- func (f *FakeStorageProvider) UpdateUser(u *core.User) error
- type SessionManager
- func (sm *SessionManager) Create(userID, ip, userAgent string) (*core.CreateSessionResult, error)
- func (sm *SessionManager) Destroy(token string) error
- func (sm *SessionManager) DestroyAllUserSessions(userID string) (int, error)
- func (sm *SessionManager) DestroyBySessionID(sessionID string) error
- func (sm *SessionManager) GetSession(token string) (*core.SessionData, error)
- func (sm *SessionManager) Refresh(token string) (*core.RefreshResult, error)
- func (sm *SessionManager) SignIn(input core.SignInInput, ipAddress, userAgent string) (*core.SignInResult, error)
- func (sm *SessionManager) SignOut(token string) error
- func (sm *SessionManager) SignUp(input core.SignUpInput, ipAddress, userAgent string) (*core.SignUpResult, error)
- func (sm *SessionManager) Verify(token string) (*core.Session, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BaseEndpoints ¶
BaseEndpoints returns framework-agnostic endpoint specifications for all core authentication endpoints.
Each endpoint is a template: - Path and Method are set - Handler is nil (provided by adapters) - Metadata contains OpenAPI information
This allows multiple adapters (Fiber, Gin, Echo) to share the same endpoint definitions while providing their own framework-specific handlers.
Types ¶
type EndpointRegistry ¶
type EndpointRegistry struct {
// contains filtered or unexported fields
}
EndpointRegistry manages a collection of framework-agnostic endpoints and handles conflict detection for duplicate METHOD:PATH combinations.
It starts with base authentication endpoints and supports registration of additional plugin endpoints with automatic conflict detection.
func NewEndpointRegistry ¶
func NewEndpointRegistry() *EndpointRegistry
NewEndpointRegistry creates a new registry with all base authentication endpoints pre-registered.
func (*EndpointRegistry) Endpoints ¶
func (r *EndpointRegistry) Endpoints() []*core.Endpoint
Endpoints returns a slice of all registered endpoints (both base and plugin endpoints).
func (*EndpointRegistry) RegisterPlugin ¶
func (r *EndpointRegistry) RegisterPlugin(endpoints []core.Endpoint) error
RegisterPlugin registers additional plugin endpoints to the registry. Returns error if any plugin endpoint conflicts with existing endpoints or with other plugin endpoints in the same batch.
If an error occurs, no endpoints from the plugin are registered.
type FakeCache ¶
type FakeCache struct {
// contains filtered or unexported fields
}
FakeCache is a test-only fake implementing core.Cache. It stores sessions in a map and exposes error fields for behavior injection.
func NewFakeCache ¶
func NewFakeCache() *FakeCache
func (*FakeCache) SetDeleteError ¶
func (*FakeCache) SetSetError ¶
func (*FakeCache) Stats ¶
func (f *FakeCache) Stats() core.CacheStats
type FakeSessionStorage ¶
type FakeSessionStorage struct {
// contains filtered or unexported fields
}
FakeSessionStorage is a test-only fake implementing core.SessionStorage. It stores sessions in a map and exposes error fields for behavior injection.
func NewFakeSessionStorage ¶
func NewFakeSessionStorage() *FakeSessionStorage
func (*FakeSessionStorage) CreateSession ¶
func (f *FakeSessionStorage) CreateSession(s *core.Session) error
func (*FakeSessionStorage) DeleteExpiredSessions ¶
func (f *FakeSessionStorage) DeleteExpiredSessions() (int, error)
func (*FakeSessionStorage) DeleteSessionByHash ¶
func (f *FakeSessionStorage) DeleteSessionByHash(tokenHash string) error
func (*FakeSessionStorage) DeleteSessionByID ¶
func (f *FakeSessionStorage) DeleteSessionByID(id string) error
func (*FakeSessionStorage) DeleteUserSessions ¶
func (f *FakeSessionStorage) DeleteUserSessions(userID string) (int, error)
func (*FakeSessionStorage) GetSessionByHash ¶
func (f *FakeSessionStorage) GetSessionByHash(tokenHash string) (*core.Session, error)
func (*FakeSessionStorage) GetSessionByID ¶
func (f *FakeSessionStorage) GetSessionByID(id string) (*core.Session, error)
func (*FakeSessionStorage) GetUserSessions ¶
func (f *FakeSessionStorage) GetUserSessions(userID string) ([]*core.Session, error)
func (*FakeSessionStorage) UpdateSession ¶
func (f *FakeSessionStorage) UpdateSession(s *core.Session) error
type FakeStorageProvider ¶
type FakeStorageProvider struct {
*FakeSessionStorage
// contains filtered or unexported fields
}
FakeStorageProvider is a test-only fake implementing core.StorageProvider. It combines session, user, and account storage fakes.
func NewFakeStorageProvider ¶
func NewFakeStorageProvider() *FakeStorageProvider
func (*FakeStorageProvider) CreateAccount ¶
func (f *FakeStorageProvider) CreateAccount(a *core.Account) error
AccountStorage implementation
func (*FakeStorageProvider) CreateUser ¶
func (f *FakeStorageProvider) CreateUser(u *core.User) error
UserStorage implementation
func (*FakeStorageProvider) DeleteAccount ¶
func (f *FakeStorageProvider) DeleteAccount(id string) error
func (*FakeStorageProvider) DeleteUser ¶
func (f *FakeStorageProvider) DeleteUser(id string) error
func (*FakeStorageProvider) GetAccountByID ¶
func (f *FakeStorageProvider) GetAccountByID(id string) (*core.Account, error)
func (*FakeStorageProvider) GetAccountByUserAndProvider ¶
func (f *FakeStorageProvider) GetAccountByUserAndProvider(userID, providerID string) ([]*core.Account, error)
func (*FakeStorageProvider) GetUserByEmail ¶
func (f *FakeStorageProvider) GetUserByEmail(email string) (*core.User, error)
func (*FakeStorageProvider) GetUserByID ¶
func (f *FakeStorageProvider) GetUserByID(id string) (*core.User, error)
func (*FakeStorageProvider) UpdateAccount ¶
func (f *FakeStorageProvider) UpdateAccount(a *core.Account) error
func (*FakeStorageProvider) UpdateUser ¶
func (f *FakeStorageProvider) UpdateUser(u *core.User) error
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager handles both session management and authentication operations. It combines session lifecycle (create, verify, destroy) with authentication flows (signup, signin, signout) since all these operations are related to session management.
func NewSessionManager ¶
func NewSessionManager(config core.SessionConfig, storage core.StorageProvider, cache core.Cache, passwords crypto.PasswordHandler) *SessionManager
func (*SessionManager) Create ¶
func (sm *SessionManager) Create(userID, ip, userAgent string) (*core.CreateSessionResult, error)
func (*SessionManager) Destroy ¶
func (sm *SessionManager) Destroy(token string) error
func (*SessionManager) DestroyAllUserSessions ¶
func (sm *SessionManager) DestroyAllUserSessions(userID string) (int, error)
func (*SessionManager) DestroyBySessionID ¶
func (sm *SessionManager) DestroyBySessionID(sessionID string) error
func (*SessionManager) GetSession ¶
func (sm *SessionManager) GetSession(token string) (*core.SessionData, error)
GetSession retrieves session data by token and returns user information.
func (*SessionManager) Refresh ¶
func (sm *SessionManager) Refresh(token string) (*core.RefreshResult, error)
Refresh extends a session's expiry time and returns a new session and token. The old token becomes invalid immediately.
func (*SessionManager) SignIn ¶
func (sm *SessionManager) SignIn(input core.SignInInput, ipAddress, userAgent string) (*core.SignInResult, error)
SignIn authenticates a user and creates a session.
func (*SessionManager) SignOut ¶
func (sm *SessionManager) SignOut(token string) error
SignOut destroys a session (alias for Destroy for clearer API naming).
func (*SessionManager) SignUp ¶
func (sm *SessionManager) SignUp(input core.SignUpInput, ipAddress, userAgent string) (*core.SignUpResult, error)
SignUp creates a new user account and session.