Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APICredentials ¶
type APICredentials interface {
GetID() string
GetUserID() string
GetAPIKey() string
GetAPISecret() string
GetStatus() string
GetExpiresAt() time.Time
GetLastUsedAt() *time.Time
}
APICredentials represents the interface for API credentials
type APIKeyRepository ¶
type APIKeyRepository interface {
Create(ctx context.Context, data map[string]any) (APICredentials, error)
FindByKey(ctx context.Context, apiKey string) (APICredentials, error)
FindByUser(ctx context.Context, userID string) ([]APICredentials, error)
UpdateLastUsed(ctx context.Context, creds APICredentials) error
Revoke(ctx context.Context, id string) error
}
APIKeyRepository defines the interface for API key-related operations
type AuthHandler ¶
type AuthHandler interface {
RegisterRoutes(router *gin.RouterGroup, socialSignupHandler gin.HandlerFunc)
RegisterSocialSignupRoutes(router *gin.RouterGroup, handler gin.HandlerFunc)
InitiateSocialLogin(c *gin.Context)
SocialSignup(next gin.HandlerFunc) gin.HandlerFunc
Login(c *gin.Context)
Logout(c *gin.Context)
RefreshToken(c *gin.Context)
}
AuthHandler defines the interface for authentication handlers
type AuthMiddleware ¶
type AuthMiddleware interface {
JWT() gin.HandlerFunc
Optional() gin.HandlerFunc
APIKey() gin.HandlerFunc
RequireAuth() gin.HandlerFunc
RequireRole(role string) gin.HandlerFunc
RequirePermission(resource, action string) gin.HandlerFunc
}
AuthMiddleware defines the interface for authentication middleware
type GoogleSignin ¶
type JWKSProvider ¶
JWKSProvider is implemented by TokenIssuers that can publish their verification key as a JSON Web Key Set (RS256 only — HS256 has no public half to publish). Kept separate from TokenIssuer so HS256 issuers and test doubles aren't forced to grow a meaningless JWKS method.
type PasswordHandler ¶
type PasswordHandler interface {
RegisterRoutes(router *gin.RouterGroup)
RequestPasswordReset(c *gin.Context)
VerifyPasswordReset(c *gin.Context)
ChangePassword(c *gin.Context)
}
PasswordHandler defines the interface for password handlers
type PasswordHasher ¶
type PasswordHasher interface {
Hash(password string) (string, error)
Verify(password, hash string) error
}
PasswordHasher defines the interface for password hashing operations
type SocialAccount ¶
type SocialAccount interface {
GetID() string
GetUser() User
GetUserID() string
GetProvider() string
GetProviderUserID() string
GetMetadata() map[string]any
}
SocialAccount represents the interface for social login accounts
type SocialAccountRepository ¶
type SocialAccountRepository interface {
Create(ctx context.Context, data *models.SocialAccount) (*models.SocialAccount, error)
DeleteByUserID(ctx context.Context, userID string) error
FindByProvider(ctx context.Context, provider authTypes.AuthProvider, providerUserID string) (*models.SocialAccount, error)
FindByUserID(ctx context.Context, userID string) (*models.SocialAccount, error)
}
SocialAccountRepository defines the interface for social account operations
type TokenIssuer ¶
type TokenIssuer interface {
IssueToken(user User) (*responses.TokenResponse, error)
ValidateToken(token string) (map[string]any, error)
RevokeToken(token string) error
RefreshToken(refreshToken string) (*responses.TokenResponse, error)
}
TokenIssuer defines the interface for JWT token operations
type User ¶
type User interface {
GetID() uuid.UUID
GetUsername() string
GetEmail() string
GetPhoneNumber() string
GetPasswordHash() string
GetRole() string
IsActive() bool
GetLastLoginAt() *time.Time
GetMetadata() map[string]any
GetEmailVerified() bool
GetEmailVerifiedAt() *types.DateTime
GetPasswordResetToken() *string
GetPasswordResetAt() *time.Time
SetPasswordResetToken(token *string)
SetPasswordResetAt(at *time.Time)
SetPassword(password string)
}
User represents the interface that all user models must implement
type UserRepository ¶
type UserRepository interface {
Create(ctx context.Context, data map[string]any) (User, error)
FindByID(ctx context.Context, id uuid.UUID) (User, error)
FindByEmail(ctx context.Context, email string) (User, error)
FindByUsername(ctx context.Context, username string) (User, error)
FindByPhoneNumber(ctx context.Context, phone string) (User, error)
FindByIdentifier(ctx context.Context, identifier string) (User, error)
FindByResetToken(ctx context.Context, token string) (User, error)
UpdateLastLogin(ctx context.Context, user User) error
ChangePassword(ctx context.Context, user User, newPasswordHash string) error
Update(ctx context.Context, user User, updates map[string]any) error
}
UserRepository defines the interface for user-related database operations
type UserRepositoryFactory ¶
UserRepositoryFactory defines the interface for user repository factories