Documentation
¶
Index ¶
- func MigrateDown(databaseURL string) error
- func MigrateUp(databaseURL string) error
- func MigrateVersion(databaseURL string) (uint, bool, error)
- type DB
- type LoginAttemptsDB
- func (r *LoginAttemptsDB) DeleteLoginAttempts(ctx context.Context, userID uuid.UUID) error
- func (r *LoginAttemptsDB) GetMostRecentLockout(ctx context.Context, email string) (*time.Time, error)
- func (r *LoginAttemptsDB) GetRecentFailedAttempts(ctx context.Context, email string, since time.Time) (int64, error)
- func (r *LoginAttemptsDB) RecordAttempt(ctx context.Context, email string, userID *uuid.UUID, lockedUntil *time.Time) error
- type MFABackupCodesDB
- func (r *MFABackupCodesDB) CountUnused(ctx context.Context, userID uuid.UUID) (int, error)
- func (r *MFABackupCodesDB) CreateBatch(ctx context.Context, userID uuid.UUID, codeHashes []string) error
- func (r *MFABackupCodesDB) DeleteByUserID(ctx context.Context, userID uuid.UUID) error
- func (r *MFABackupCodesDB) GetUnusedByUserID(ctx context.Context, userID uuid.UUID) ([]*iam.MFABackupCode, error)
- func (r *MFABackupCodesDB) MarkUsed(ctx context.Context, codeID uuid.UUID) error
- type MFASettingsDB
- func (r *MFASettingsDB) Create(ctx context.Context, userID uuid.UUID, encryptedSecret string) (*iam.MFASettings, error)
- func (r *MFASettingsDB) Delete(ctx context.Context, userID uuid.UUID) error
- func (r *MFASettingsDB) GetByUserID(ctx context.Context, userID uuid.UUID) (*iam.MFASettings, error)
- func (r *MFASettingsDB) Update(ctx context.Context, settings *iam.MFASettings) error
- func (r *MFASettingsDB) UpdateLastUsed(ctx context.Context, userID uuid.UUID, window int64) error
- type OIDCLinksDB
- func (o *OIDCLinksDB) CreateOIDCLink(ctx context.Context, link *iam.OIDCLink) (*iam.OIDCLink, error)
- func (o *OIDCLinksDB) DeleteOIDCLink(ctx context.Context, userID uuid.UUID, providerID uuid.UUID) error
- func (o *OIDCLinksDB) GetOIDCLinkByProvider(ctx context.Context, providerID uuid.UUID, providerUserID string) (*iam.OIDCLink, error)
- func (o *OIDCLinksDB) GetOIDCLinkByUser(ctx context.Context, userID uuid.UUID, providerID uuid.UUID) (*iam.OIDCLink, error)
- func (o *OIDCLinksDB) ListOIDCLinksByUser(ctx context.Context, userID uuid.UUID) ([]*iam.OIDCLink, error)
- func (o *OIDCLinksDB) UpdateOIDCLinkLastUsed(ctx context.Context, id uuid.UUID) error
- type OIDCProvidersDB
- func (o *OIDCProvidersDB) CreateOIDCProvider(ctx context.Context, provider *iam.OIDCProviderConfig) (*iam.OIDCProviderConfig, error)
- func (o *OIDCProvidersDB) DeleteOIDCProviderByID(ctx context.Context, id uuid.UUID) error
- func (o *OIDCProvidersDB) GetOIDCProviderByID(ctx context.Context, id uuid.UUID) (*iam.OIDCProviderConfig, error)
- func (o *OIDCProvidersDB) GetOIDCProvidersByDomain(ctx context.Context, domain string) ([]*iam.OIDCProviderConfig, error)
- func (o *OIDCProvidersDB) ListOIDCProviders(ctx context.Context) ([]*iam.OIDCProviderConfig, error)
- func (o *OIDCProvidersDB) UpdateOIDCProvider(ctx context.Context, params *iam.UpdateOIDCProviderParams) (*iam.OIDCProviderConfig, error)
- type OIDCSessionsDB
- func (o *OIDCSessionsDB) CreateOIDCSession(ctx context.Context, session *iam.OIDCSession) (*iam.OIDCSession, error)
- func (o *OIDCSessionsDB) DeleteExpiredOIDCSessions(ctx context.Context) error
- func (o *OIDCSessionsDB) DeleteOIDCSession(ctx context.Context, id uuid.UUID) error
- func (o *OIDCSessionsDB) GetOIDCSessionByState(ctx context.Context, state string) (*iam.OIDCSession, error)
- type PasswordResetTokensDB
- func (r *PasswordResetTokensDB) CreateToken(ctx context.Context, userID uuid.UUID, token string, expiresAt time.Time) (*iam.UserToken, error)
- func (r *PasswordResetTokensDB) DeleteExpiredTokens(ctx context.Context) error
- func (r *PasswordResetTokensDB) DeleteToken(ctx context.Context, userID uuid.UUID) error
- func (r *PasswordResetTokensDB) GetToken(ctx context.Context, token string) (*iam.UserToken, error)
- type PermissionsDB
- func (p *PermissionsDB) GetPermissionByID(ctx context.Context, permissionID uuid.UUID) (*iam.Permission, error)
- func (p *PermissionsDB) GetUserPermissions(ctx context.Context, userID uuid.UUID) ([]*iam.EffectivePermission, error)
- func (p *PermissionsDB) ListPermissions(ctx context.Context) ([]*iam.Permission, error)
- type RefreshTokensDB
- func (r *RefreshTokensDB) Create(ctx context.Context, token *iam.RefreshToken) (*iam.RefreshToken, error)
- func (r *RefreshTokensDB) DeleteExpired(ctx context.Context) error
- func (r *RefreshTokensDB) GetByHash(ctx context.Context, tokenHash string) (*iam.RefreshToken, error)
- func (r *RefreshTokensDB) GetByHashIncludingRevoked(ctx context.Context, tokenHash string) (*iam.RefreshToken, error)
- func (r *RefreshTokensDB) ListByUserID(ctx context.Context, userID uuid.UUID) ([]*iam.RefreshToken, error)
- func (r *RefreshTokensDB) RevokeAllByUserID(ctx context.Context, userID uuid.UUID) error
- func (r *RefreshTokensDB) RevokeByFamilyID(ctx context.Context, familyID uuid.UUID) error
- func (r *RefreshTokensDB) RevokeByHash(ctx context.Context, tokenHash string) error
- func (r *RefreshTokensDB) RevokeByID(ctx context.Context, id uuid.UUID) error
- func (r *RefreshTokensDB) UpdateLastUsed(ctx context.Context, id uuid.UUID) error
- type RolePermissionsDB
- type RolesDB
- func (r *RolesDB) CreateRole(ctx context.Context, role *iam.Role) (*iam.Role, error)
- func (r *RolesDB) DeleteRole(ctx context.Context, roleID uuid.UUID) error
- func (r *RolesDB) GetRoleByID(ctx context.Context, roleID uuid.UUID) (*iam.Role, error)
- func (r *RolesDB) ListRoles(ctx context.Context) ([]*iam.Role, error)
- func (r *RolesDB) UpdateRole(ctx context.Context, params iam.UpdateRoleParams) (*iam.Role, error)
- type TenantsDB
- type TrustedDevicesDB
- func (r *TrustedDevicesDB) Create(ctx context.Context, device *iam.TrustedDevice) (*iam.TrustedDevice, error)
- func (r *TrustedDevicesDB) DeleteExpired(ctx context.Context) error
- func (r *TrustedDevicesDB) GetByTokenHash(ctx context.Context, tokenHash string) (*iam.TrustedDevice, error)
- func (r *TrustedDevicesDB) RevokeAllByUserID(ctx context.Context, userID uuid.UUID) error
- func (r *TrustedDevicesDB) UpdateLastUsed(ctx context.Context, id uuid.UUID, expiresAt time.Time, ipAddress string) error
- type UserPermissionsDB
- type UserRolesDB
- type UsersDB
- func (u *UsersDB) CreateUser(ctx context.Context, user *iam.User) (*iam.User, error)
- func (u *UsersDB) DeleteOldUnverifiedUsers(ctx context.Context, days int32) error
- func (u *UsersDB) DeleteUser(ctx context.Context, id uuid.UUID) error
- func (u *UsersDB) GetUser(ctx context.Context, id uuid.UUID) (*iam.User, error)
- func (u *UsersDB) GetUserByEmail(ctx context.Context, email string) (*iam.User, error)
- func (u *UsersDB) UpdateLastLogin(ctx context.Context, id uuid.UUID) error
- func (u *UsersDB) UpdateUser(ctx context.Context, params *iam.UpdateUserParams) (*iam.User, error)
- type VerificationTokensDB
- func (r *VerificationTokensDB) CreateToken(ctx context.Context, userID uuid.UUID, token string, expiresAt time.Time) (*iam.UserToken, error)
- func (r *VerificationTokensDB) DeleteExpiredTokens(ctx context.Context) error
- func (r *VerificationTokensDB) DeleteToken(ctx context.Context, userID uuid.UUID) error
- func (r *VerificationTokensDB) GetToken(ctx context.Context, token string) (*iam.UserToken, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateDown ¶
MigrateDown rolls back the last migration
Types ¶
type LoginAttemptsDB ¶
type LoginAttemptsDB struct {
// contains filtered or unexported fields
}
LoginAttemptsDB tracks failed login attempts for progressive lockout and audit trail
func NewLoginAttemptsDB ¶
func NewLoginAttemptsDB(db *DB) *LoginAttemptsDB
func (*LoginAttemptsDB) DeleteLoginAttempts ¶
DeleteLoginAttempts removes all login attempts for a user after successful authentication
func (*LoginAttemptsDB) GetMostRecentLockout ¶
func (r *LoginAttemptsDB) GetMostRecentLockout(ctx context.Context, email string) (*time.Time, error)
GetMostRecentLockout returns latest lockout expiry time (nil if no active lockouts)
func (*LoginAttemptsDB) GetRecentFailedAttempts ¶
func (r *LoginAttemptsDB) GetRecentFailedAttempts(ctx context.Context, email string, since time.Time) (int64, error)
GetRecentFailedAttempts counts failed login attempts since specified time (for lockout calculation)
type MFABackupCodesDB ¶
type MFABackupCodesDB struct {
// contains filtered or unexported fields
}
MFABackupCodesDB manages MFA backup codes (authenticated operations)
func NewMFABackupCodesDB ¶
func NewMFABackupCodesDB(db *DB) *MFABackupCodesDB
func (*MFABackupCodesDB) CountUnused ¶
CountUnused counts unused backup codes for a user
func (*MFABackupCodesDB) CreateBatch ¶
func (r *MFABackupCodesDB) CreateBatch(ctx context.Context, userID uuid.UUID, codeHashes []string) error
CreateBatch creates multiple backup codes using batch insert
func (*MFABackupCodesDB) DeleteByUserID ¶
DeleteByUserID deletes all backup codes for a user
func (*MFABackupCodesDB) GetUnusedByUserID ¶
func (r *MFABackupCodesDB) GetUnusedByUserID(ctx context.Context, userID uuid.UUID) ([]*iam.MFABackupCode, error)
GetUnusedByUserID retrieves all unused backup codes for a user
type MFASettingsDB ¶
type MFASettingsDB struct {
// contains filtered or unexported fields
}
MFASettingsDB manages MFA settings (authenticated operations)
func NewMFASettingsDB ¶
func NewMFASettingsDB(db *DB) *MFASettingsDB
func (*MFASettingsDB) Create ¶
func (r *MFASettingsDB) Create(ctx context.Context, userID uuid.UUID, encryptedSecret string) (*iam.MFASettings, error)
Create creates MFA settings for a user
func (*MFASettingsDB) GetByUserID ¶
func (r *MFASettingsDB) GetByUserID(ctx context.Context, userID uuid.UUID) (*iam.MFASettings, error)
GetByUserID retrieves MFA settings by user ID
func (*MFASettingsDB) Update ¶
func (r *MFASettingsDB) Update(ctx context.Context, settings *iam.MFASettings) error
Update updates MFA settings
func (*MFASettingsDB) UpdateLastUsed ¶
UpdateLastUsed updates last used window and timestamp (for replay prevention)
type OIDCLinksDB ¶
type OIDCLinksDB struct {
// contains filtered or unexported fields
}
OIDCLinksDB manages user-to-provider links for SSO (tracks by provider's sub claim)
func NewOIDCLinksDB ¶
func NewOIDCLinksDB(db *DB) *OIDCLinksDB
func (*OIDCLinksDB) CreateOIDCLink ¶
func (o *OIDCLinksDB) CreateOIDCLink(ctx context.Context, link *iam.OIDCLink) (*iam.OIDCLink, error)
CreateOIDCLink creates link between user and provider (tracks by immutable sub claim)
func (*OIDCLinksDB) DeleteOIDCLink ¶
func (o *OIDCLinksDB) DeleteOIDCLink(ctx context.Context, userID uuid.UUID, providerID uuid.UUID) error
DeleteOIDCLink deletes an OIDC link by user ID and provider ID
func (*OIDCLinksDB) GetOIDCLinkByProvider ¶
func (o *OIDCLinksDB) GetOIDCLinkByProvider(ctx context.Context, providerID uuid.UUID, providerUserID string) (*iam.OIDCLink, error)
GetOIDCLinkByProvider retrieves link by provider's sub claim (allows email reassignment)
func (*OIDCLinksDB) GetOIDCLinkByUser ¶
func (o *OIDCLinksDB) GetOIDCLinkByUser(ctx context.Context, userID uuid.UUID, providerID uuid.UUID) (*iam.OIDCLink, error)
GetOIDCLinkByUser retrieves an OIDC link by user ID and provider ID
func (*OIDCLinksDB) ListOIDCLinksByUser ¶
func (o *OIDCLinksDB) ListOIDCLinksByUser(ctx context.Context, userID uuid.UUID) ([]*iam.OIDCLink, error)
ListOIDCLinksByUser lists all OIDC links for a user
func (*OIDCLinksDB) UpdateOIDCLinkLastUsed ¶
UpdateOIDCLinkLastUsed updates the last_used_at timestamp
type OIDCProvidersDB ¶
type OIDCProvidersDB struct {
// contains filtered or unexported fields
}
OIDCProvidersDB manages tenant-specific OIDC provider configs with encrypted secrets
func NewOIDCProvidersDB ¶
func NewOIDCProvidersDB(db *DB, cipher *aes.Cipher) *OIDCProvidersDB
func (*OIDCProvidersDB) CreateOIDCProvider ¶
func (o *OIDCProvidersDB) CreateOIDCProvider(ctx context.Context, provider *iam.OIDCProviderConfig) (*iam.OIDCProviderConfig, error)
CreateOIDCProvider stores provider config with AES-256-GCM encrypted client secret
func (*OIDCProvidersDB) DeleteOIDCProviderByID ¶
DeleteOIDCProviderByID deletes an OAuth provider by ID
func (*OIDCProvidersDB) GetOIDCProviderByID ¶
func (o *OIDCProvidersDB) GetOIDCProviderByID(ctx context.Context, id uuid.UUID) (*iam.OIDCProviderConfig, error)
GetOIDCProviderByID retrieves provider by ID; RLS enforces tenant isolation
func (*OIDCProvidersDB) GetOIDCProvidersByDomain ¶
func (o *OIDCProvidersDB) GetOIDCProvidersByDomain(ctx context.Context, domain string) ([]*iam.OIDCProviderConfig, error)
GetOIDCProvidersByDomain retrieves all OAuth providers configured for an email domain This is used for SSO discovery during login (cross-tenant, pre-authentication)
func (*OIDCProvidersDB) ListOIDCProviders ¶
func (o *OIDCProvidersDB) ListOIDCProviders(ctx context.Context) ([]*iam.OIDCProviderConfig, error)
ListOIDCProviders lists all enabled OAuth providers for the tenant
func (*OIDCProvidersDB) UpdateOIDCProvider ¶
func (o *OIDCProvidersDB) UpdateOIDCProvider(ctx context.Context, params *iam.UpdateOIDCProviderParams) (*iam.OIDCProviderConfig, error)
UpdateOIDCProvider updates an OAuth provider Fields in params that are pointers (nil) or empty slices will not be updated (COALESCE in SQL)
type OIDCSessionsDB ¶
type OIDCSessionsDB struct {
// contains filtered or unexported fields
}
OIDCSessionsDB manages OAuth flow sessions (state, PKCE, provider tracking)
func NewOIDCSessionsDB ¶
func NewOIDCSessionsDB(db *DB) *OIDCSessionsDB
func (*OIDCSessionsDB) CreateOIDCSession ¶
func (o *OIDCSessionsDB) CreateOIDCSession(ctx context.Context, session *iam.OIDCSession) (*iam.OIDCSession, error)
CreateOIDCSession creates temporary session for OAuth flow (CSRF protection via state)
func (*OIDCSessionsDB) DeleteExpiredOIDCSessions ¶
func (o *OIDCSessionsDB) DeleteExpiredOIDCSessions(ctx context.Context) error
DeleteExpiredOIDCSessions deletes all expired OAuth sessions
func (*OIDCSessionsDB) DeleteOIDCSession ¶
DeleteOIDCSession deletes an OAuth session by ID
func (*OIDCSessionsDB) GetOIDCSessionByState ¶
func (o *OIDCSessionsDB) GetOIDCSessionByState(ctx context.Context, state string) (*iam.OIDCSession, error)
GetOIDCSessionByState retrieves session by state parameter (validates CSRF token)
type PasswordResetTokensDB ¶
type PasswordResetTokensDB struct {
// contains filtered or unexported fields
}
PasswordResetTokensDB manages password reset tokens (pre-authentication operation)
func NewPasswordResetTokensDB ¶
func NewPasswordResetTokensDB(db *DB) *PasswordResetTokensDB
func (*PasswordResetTokensDB) CreateToken ¶
func (r *PasswordResetTokensDB) CreateToken(ctx context.Context, userID uuid.UUID, token string, expiresAt time.Time) (*iam.UserToken, error)
CreateToken creates or replaces reset token (user_id is PK, enforces one token per user)
func (*PasswordResetTokensDB) DeleteExpiredTokens ¶
func (r *PasswordResetTokensDB) DeleteExpiredTokens(ctx context.Context) error
DeleteExpiredTokens cleans up expired tokens (should be called periodically via cleanup job)
func (*PasswordResetTokensDB) DeleteToken ¶
DeleteToken removes reset token after successful password change
type PermissionsDB ¶
type PermissionsDB struct {
// contains filtered or unexported fields
}
PermissionsDB provides database operations for permissions
func NewPermissionsDB ¶
func NewPermissionsDB(db *DB) *PermissionsDB
NewPermissionsDB creates a new PermissionsDB
func (*PermissionsDB) GetPermissionByID ¶
func (p *PermissionsDB) GetPermissionByID(ctx context.Context, permissionID uuid.UUID) (*iam.Permission, error)
GetPermissionByID retrieves a permission by ID
func (*PermissionsDB) GetUserPermissions ¶
func (p *PermissionsDB) GetUserPermissions(ctx context.Context, userID uuid.UUID) ([]*iam.EffectivePermission, error)
GetUserPermissions retrieves all permissions for a user (from roles + direct)
func (*PermissionsDB) ListPermissions ¶
func (p *PermissionsDB) ListPermissions(ctx context.Context) ([]*iam.Permission, error)
ListPermissions lists all available permissions (system-wide)
type RefreshTokensDB ¶
type RefreshTokensDB struct {
// contains filtered or unexported fields
}
RefreshTokensDB manages refresh token storage for session tracking
func NewRefreshTokensDB ¶
func NewRefreshTokensDB(db *DB) *RefreshTokensDB
func (*RefreshTokensDB) Create ¶
func (r *RefreshTokensDB) Create(ctx context.Context, token *iam.RefreshToken) (*iam.RefreshToken, error)
Create stores a new refresh token (requires tenant context from auth flow)
func (*RefreshTokensDB) DeleteExpired ¶
func (r *RefreshTokensDB) DeleteExpired(ctx context.Context) error
DeleteExpired cleans up expired and old revoked tokens (cleanup job: no tenant context)
func (*RefreshTokensDB) GetByHash ¶
func (r *RefreshTokensDB) GetByHash(ctx context.Context, tokenHash string) (*iam.RefreshToken, error)
GetByHash retrieves a valid (non-revoked, non-expired) token by hash (requires tenant context)
func (*RefreshTokensDB) GetByHashIncludingRevoked ¶
func (r *RefreshTokensDB) GetByHashIncludingRevoked(ctx context.Context, tokenHash string) (*iam.RefreshToken, error)
GetByHashIncludingRevoked retrieves a token by hash even if revoked (for reuse detection, requires tenant context)
func (*RefreshTokensDB) ListByUserID ¶
func (r *RefreshTokensDB) ListByUserID(ctx context.Context, userID uuid.UUID) ([]*iam.RefreshToken, error)
ListByUserID returns all active sessions for a user (authenticated: requires tenant context)
func (*RefreshTokensDB) RevokeAllByUserID ¶
RevokeAllByUserID revokes all sessions for a user (authenticated: sign out everywhere)
func (*RefreshTokensDB) RevokeByFamilyID ¶
RevokeByFamilyID revokes all tokens in a family (for token reuse detection, requires tenant context)
func (*RefreshTokensDB) RevokeByHash ¶
func (r *RefreshTokensDB) RevokeByHash(ctx context.Context, tokenHash string) error
RevokeByHash revokes a token by its hash (requires tenant context)
func (*RefreshTokensDB) RevokeByID ¶
RevokeByID revokes a specific session (authenticated: requires tenant context)
func (*RefreshTokensDB) UpdateLastUsed ¶
UpdateLastUsed updates the last_used_at timestamp (requires tenant context)
type RolePermissionsDB ¶
type RolePermissionsDB struct {
// contains filtered or unexported fields
}
RolePermissionsDB provides database operations for role permissions
func NewRolePermissionsDB ¶
func NewRolePermissionsDB(db *DB) *RolePermissionsDB
NewRolePermissionsDB creates a new RolePermissionsDB
func (*RolePermissionsDB) GetRolePermissions ¶
func (r *RolePermissionsDB) GetRolePermissions(ctx context.Context, roleID uuid.UUID) ([]*iam.Permission, error)
GetRolePermissions retrieves all permissions for a role
func (*RolePermissionsDB) SetRolePermissions ¶
func (r *RolePermissionsDB) SetRolePermissions(ctx context.Context, roleID uuid.UUID, permissionIDs []uuid.UUID) error
SetRolePermissions replaces all permissions for a role (bulk update)
type RolesDB ¶
type RolesDB struct {
// contains filtered or unexported fields
}
RolesDB provides database operations for roles
func (*RolesDB) CreateRole ¶
CreateRole creates a new role
func (*RolesDB) DeleteRole ¶
DeleteRole deletes a role
func (*RolesDB) GetRoleByID ¶
GetRoleByID retrieves a role by ID
func (*RolesDB) UpdateRole ¶
UpdateRole updates a role
type TenantsDB ¶
type TenantsDB struct {
// contains filtered or unexported fields
}
TenantsDB provides database operations for tenants
type TrustedDevicesDB ¶
type TrustedDevicesDB struct {
// contains filtered or unexported fields
}
TrustedDevicesDB manages trusted device storage for MFA bypass
func NewTrustedDevicesDB ¶
func NewTrustedDevicesDB(db *DB) *TrustedDevicesDB
func (*TrustedDevicesDB) Create ¶
func (r *TrustedDevicesDB) Create(ctx context.Context, device *iam.TrustedDevice) (*iam.TrustedDevice, error)
Create stores a new trusted device (requires tenant context)
func (*TrustedDevicesDB) DeleteExpired ¶
func (r *TrustedDevicesDB) DeleteExpired(ctx context.Context) error
DeleteExpired cleans up expired and old revoked devices (cleanup job: no tenant context)
func (*TrustedDevicesDB) GetByTokenHash ¶
func (r *TrustedDevicesDB) GetByTokenHash(ctx context.Context, tokenHash string) (*iam.TrustedDevice, error)
GetByTokenHash retrieves a valid (non-revoked, non-expired) device by token hash
func (*TrustedDevicesDB) RevokeAllByUserID ¶
RevokeAllByUserID revokes all trusted devices for a user
type UserPermissionsDB ¶
type UserPermissionsDB struct {
// contains filtered or unexported fields
}
UserPermissionsDB provides database operations for direct user permissions
func NewUserPermissionsDB ¶
func NewUserPermissionsDB(db *DB) *UserPermissionsDB
NewUserPermissionsDB creates a new UserPermissionsDB
func (*UserPermissionsDB) GetDirectPermissions ¶
func (u *UserPermissionsDB) GetDirectPermissions(ctx context.Context, userID uuid.UUID) ([]*iam.EffectivePermission, error)
GetDirectPermissions retrieves direct permissions assigned to a user
func (*UserPermissionsDB) SetDirectPermissions ¶
func (u *UserPermissionsDB) SetDirectPermissions(ctx context.Context, userID uuid.UUID, permissions []iam.DirectPermission) error
SetDirectPermissions sets all direct permissions for a user (replaces existing direct permissions)
type UserRolesDB ¶
type UserRolesDB struct {
// contains filtered or unexported fields
}
UserRolesDB provides database operations for user roles
func NewUserRolesDB ¶
func NewUserRolesDB(db *DB) *UserRolesDB
NewUserRolesDB creates a new UserRolesDB
func (*UserRolesDB) GetUserRoles ¶
GetUserRoles retrieves all roles for a user
func (*UserRolesDB) SetUserRoles ¶
func (u *UserRolesDB) SetUserRoles(ctx context.Context, userID uuid.UUID, roleIDs []uuid.UUID) error
SetUserRoles sets all roles for a user (replaces existing roles)
type UsersDB ¶
type UsersDB struct {
// contains filtered or unexported fields
}
UsersDB handles user database operations with tenant isolation
func (*UsersDB) CreateUser ¶
CreateUser persists a user in the current tenant context
func (*UsersDB) DeleteOldUnverifiedUsers ¶
DeleteOldUnverifiedUsers deletes unverified users older than the specified number of days Cross-tenant cleanup operation runs via scheduled job, not user request
func (*UsersDB) DeleteUser ¶
DeleteUser deletes a user with tenant isolation
func (*UsersDB) GetUserByEmail ¶
GetUserByEmail retrieves a user by email without tenant isolation Pre-authentication operation: emails are globally unique for password users, but may duplicate for SSO users
func (*UsersDB) UpdateLastLogin ¶
UpdateLastLogin updates a user's last login timestamp
func (*UsersDB) UpdateUser ¶
UpdateUser performs a flexible partial update without tenant isolation Used for pre-authentication operations (email verification, password reset)
type VerificationTokensDB ¶
type VerificationTokensDB struct {
// contains filtered or unexported fields
}
VerificationTokensDB manages email verification tokens (pre-authentication operation)
func NewVerificationTokensDB ¶
func NewVerificationTokensDB(db *DB) *VerificationTokensDB
func (*VerificationTokensDB) CreateToken ¶
func (r *VerificationTokensDB) CreateToken(ctx context.Context, userID uuid.UUID, token string, expiresAt time.Time) (*iam.UserToken, error)
CreateToken creates or replaces verification token (user_id is PK, enforces one token per user)
func (*VerificationTokensDB) DeleteExpiredTokens ¶
func (r *VerificationTokensDB) DeleteExpiredTokens(ctx context.Context) error
DeleteExpiredTokens cleans up expired tokens (should be called periodically via cleanup job)
func (*VerificationTokensDB) DeleteToken ¶
DeleteToken removes verification token after successful email confirmation