Documentation
¶
Index ¶
- Constants
- Variables
- func IsUniqueViolation(err error, constraint string) bool
- func NormalizeUsername(u string) string
- type AdminAuditEventFilter
- type Config
- type Store
- func (s *Store) AddUserPlatformRoleByName(ctx context.Context, userID uuid.UUID, roleName string) error
- func (s *Store) ClaimNextEmailJob(ctx context.Context, now time.Time) (domain.EmailJob, error)
- func (s *Store) Close() error
- func (s *Store) ConsumeChallenge(ctx context.Context, challengeID uuid.UUID, now time.Time) error
- func (s *Store) ConsumePendingProviderLink(ctx context.Context, id uuid.UUID, now time.Time) error
- func (s *Store) ConsumeRefreshToken(ctx context.Context, tokenID uuid.UUID, consumedAt time.Time) error
- func (s *Store) ConsumeWebAuthnChallenge(ctx context.Context, challengeID uuid.UUID, now time.Time) error
- func (s *Store) CountActiveSessions(ctx context.Context, now time.Time) (int, error)
- func (s *Store) CountActiveSessionsByUserID(ctx context.Context, userID uuid.UUID, now time.Time) (int, error)
- func (s *Store) CountActiveUsersWithRole(ctx context.Context, roleName string) (int, error)
- func (s *Store) CountAllowedEmails(ctx context.Context, query string) (int, error)
- func (s *Store) CountAuthMethods(ctx context.Context, userID uuid.UUID) (int, error)
- func (s *Store) CountDisabledUsers(ctx context.Context) (int, error)
- func (s *Store) CountRecentFailedEmailJobs(ctx context.Context) (int, error)
- func (s *Store) CountRecentRiskyChallenges(ctx context.Context, now time.Time) (int, error)
- func (s *Store) CountUsers(ctx context.Context) (int, error)
- func (s *Store) CountUsersCreatedSince(ctx context.Context, since time.Time) (int, error)
- func (s *Store) CountUsersWithRole(ctx context.Context, roleName string) (int, error)
- func (s *Store) CreateAdminAuditEvent(ctx context.Context, event domain.AdminAuditEvent) (domain.AdminAuditEvent, error)
- func (s *Store) CreateAllowedEmail(ctx context.Context, allowedEmail domain.AllowedEmail) error
- func (s *Store) CreateAuthProvider(ctx context.Context, provider domain.AuthProvider) (domain.AuthProvider, error)
- func (s *Store) CreateChallenge(ctx context.Context, in domain.Challenge) (domain.Challenge, error)
- func (s *Store) CreateEmailJob(ctx context.Context, in domain.EmailJob) (domain.EmailJob, error)
- func (s *Store) CreatePasskey(ctx context.Context, passkey domain.Passkey) (domain.Passkey, error)
- func (s *Store) CreatePendingEmailChange(ctx context.Context, in domain.PendingEmailChange) (domain.PendingEmailChange, error)
- func (s *Store) CreatePendingPasswordReset(ctx context.Context, in domain.PendingPasswordReset) (domain.PendingPasswordReset, error)
- func (s *Store) CreatePendingProviderLink(ctx context.Context, link domain.PendingProviderLink) (domain.PendingProviderLink, error)
- func (s *Store) CreatePendingSignupAction(ctx context.Context, in domain.PendingSignupAction) (domain.PendingSignupAction, error)
- func (s *Store) CreateRefreshToken(ctx context.Context, token domain.RefreshToken) error
- func (s *Store) CreateSession(ctx context.Context, session domain.Session) (domain.Session, error)
- func (s *Store) CreateUser(ctx context.Context, user domain.User) (domain.User, error)
- func (s *Store) CreateWebAuthnChallenge(ctx context.Context, in domain.WebAuthnChallenge) (domain.WebAuthnChallenge, error)
- func (s *Store) CurrentSchemaVersion(ctx context.Context) (int, error)
- func (s *Store) DB() *sql.DB
- func (s *Store) DeleteAdminAuditEventsBefore(ctx context.Context, cutoff time.Time) (int64, error)
- func (s *Store) DeleteAllowedEmail(ctx context.Context, email string) error
- func (s *Store) DeleteAllowedEmailByID(ctx context.Context, id uuid.UUID) (domain.AllowedEmail, error)
- func (s *Store) DeleteAuthProviderByMethodAndUserID(ctx context.Context, provider domain.Provider, userID uuid.UUID) error
- func (s *Store) DeleteExpiredChallenges(ctx context.Context, now time.Time) error
- func (s *Store) DeleteExpiredRefreshTokens(ctx context.Context, now time.Time) error
- func (s *Store) DeleteExpiredSessions(ctx context.Context, now time.Time) error
- func (s *Store) DeleteExpiredWebAuthnChallenges(ctx context.Context, now time.Time) error
- func (s *Store) DeleteFailedEmailJobsBefore(ctx context.Context, t time.Time) error
- func (s *Store) DeletePasskeyByIDAndUserID(ctx context.Context, passkeyID, userID uuid.UUID) error
- func (s *Store) DeletePendingEmailChangeByChallengeID(ctx context.Context, challengeID uuid.UUID) error
- func (s *Store) DeletePendingPasswordResetByChallengeID(ctx context.Context, challengeID uuid.UUID) error
- func (s *Store) DeleteRefreshTokensBySession(ctx context.Context, sessionID uuid.UUID) error
- func (s *Store) DeleteRefreshTokensByUserID(ctx context.Context, userID uuid.UUID) error
- func (s *Store) DeleteRefreshTokensForOtherSessions(ctx context.Context, userID uuid.UUID, keepSessionID uuid.UUID) error
- func (s *Store) DeleteSentEmailJobsBefore(ctx context.Context, t time.Time) error
- func (s *Store) DeleteUser(ctx context.Context, userID uuid.UUID) error
- func (s *Store) DisableUser(ctx context.Context, userID uuid.UUID, disabledAt time.Time) error
- func (s *Store) EnableUser(ctx context.Context, userID uuid.UUID) error
- func (s *Store) GetActiveSessionByID(ctx context.Context, sessionID uuid.UUID, now time.Time) (domain.Session, error)
- func (s *Store) GetAuthProviderByMethodAndUserID(ctx context.Context, provider domain.Provider, userID uuid.UUID) (domain.AuthProvider, error)
- func (s *Store) GetAuthProviderByProviderAndProviderUserID(ctx context.Context, provider domain.Provider, providerUserID string) (domain.AuthProvider, error)
- func (s *Store) GetChallengeByID(ctx context.Context, challengeID uuid.UUID) (domain.Challenge, error)
- func (s *Store) GetChallengeByIDForUpdate(ctx context.Context, challengeID uuid.UUID) (domain.Challenge, error)
- func (s *Store) GetPasskeyByCredentialID(ctx context.Context, credentialID []byte) (domain.Passkey, error)
- func (s *Store) GetPasskeyByID(ctx context.Context, passkeyID uuid.UUID) (domain.Passkey, error)
- func (s *Store) GetPendingEmailChangeByChallengeID(ctx context.Context, challengeID uuid.UUID) (domain.PendingEmailChange, error)
- func (s *Store) GetPendingPasswordResetByChallengeID(ctx context.Context, challengeID uuid.UUID) (domain.PendingPasswordReset, error)
- func (s *Store) GetPendingProviderLinkByID(ctx context.Context, id uuid.UUID) (domain.PendingProviderLink, error)
- func (s *Store) GetPendingSignupActionByChallengeID(ctx context.Context, challengeID uuid.UUID) (domain.PendingSignupAction, error)
- func (s *Store) GetRefreshTokenByHash(ctx context.Context, hash string) (domain.RefreshToken, error)
- func (s *Store) GetSessionByID(ctx context.Context, sessionID uuid.UUID) (domain.Session, error)
- func (s *Store) GetUserByEmail(ctx context.Context, email string) (domain.User, error)
- func (s *Store) GetUserByEmailOrUsername(ctx context.Context, query string) (domain.User, error)
- func (s *Store) GetUserByID(ctx context.Context, userID uuid.UUID) (domain.User, error)
- func (s *Store) GetUserPlatformRoleNames(ctx context.Context, userID uuid.UUID) ([]string, error)
- func (s *Store) GetVerificationCodeByChallengeID(ctx context.Context, challengeID uuid.UUID) (domain.VerificationCode, error)
- func (s *Store) GetWebAuthnChallengeByIDForUpdate(ctx context.Context, challengeID uuid.UUID) (domain.WebAuthnChallenge, error)
- func (s *Store) IncrementChallengeAttemptCount(ctx context.Context, challengeID uuid.UUID) error
- func (s *Store) IncrementChallengeResendCount(ctx context.Context, challengeID uuid.UUID, now time.Time) (bool, error)
- func (s *Store) IsEmailAllowed(ctx context.Context, email string) (bool, error)
- func (s *Store) IsUserDisabled(ctx context.Context, userID uuid.UUID) (bool, error)
- func (s *Store) ListActiveSessionsByUserID(ctx context.Context, userID uuid.UUID, now time.Time) ([]domain.Session, error)
- func (s *Store) ListAdminAuditEvents(ctx context.Context, filter AdminAuditEventFilter) ([]domain.AdminAuditEvent, error)
- func (s *Store) ListAllowedEmails(ctx context.Context) ([]domain.AllowedEmail, error)
- func (s *Store) ListAllowedEmailsPage(ctx context.Context, query string, limit, offset int) ([]domain.AllowedEmail, error)
- func (s *Store) ListAuthProvidersByUserID(ctx context.Context, userID uuid.UUID) ([]domain.AuthProvider, error)
- func (s *Store) ListPasskeysByUserID(ctx context.Context, userID uuid.UUID) ([]domain.Passkey, error)
- func (s *Store) ListRecentFailedEmailJobs(ctx context.Context, limit, offset int) ([]domain.EmailJob, error)
- func (s *Store) ListRecentRiskyChallenges(ctx context.Context, now time.Time, limit, offset int) ([]domain.Challenge, error)
- func (s *Store) ListSessionsByUserID(ctx context.Context, userID uuid.UUID) ([]domain.Session, error)
- func (s *Store) LockPlatformRoleByName(ctx context.Context, roleName string) error
- func (s *Store) LockUserForAuthMethodMutation(ctx context.Context, userID uuid.UUID) error
- func (s *Store) MarkEmailJobFailed(ctx context.Context, jobID uuid.UUID, lastError string) error
- func (s *Store) MarkEmailJobSent(ctx context.Context, jobID uuid.UUID, now time.Time) error
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) RemoveUserPlatformRoleByName(ctx context.Context, userID uuid.UUID, roleName string) error
- func (s *Store) RequeueEmailJob(ctx context.Context, jobID uuid.UUID, lastError string, ...) error
- func (s *Store) RevokeAllActiveSessionsForUser(ctx context.Context, userID uuid.UUID, revokedAt time.Time) (int64, error)
- func (s *Store) RevokeAllSessionsForUser(ctx context.Context, userID uuid.UUID, revokedAt time.Time) error
- func (s *Store) RevokeOtherSessionsByUserID(ctx context.Context, userID uuid.UUID, keepSessionID uuid.UUID, ...) error
- func (s *Store) RevokeSession(ctx context.Context, sessionID uuid.UUID, revokedAt time.Time) error
- func (s *Store) RevokeSessionByIDAndUserID(ctx context.Context, sessionID uuid.UUID, userID uuid.UUID, ...) error
- func (s *Store) SetChallengeLastSentAt(ctx context.Context, challengeID uuid.UUID, now time.Time) error
- func (s *Store) UpdatePasskeyAfterLogin(ctx context.Context, credentialID []byte, signCount uint32, cloneWarning bool, ...) error
- func (s *Store) UpdatePasswordHash(ctx context.Context, userID uuid.UUID, passwordHash string) error
- func (s *Store) UpdatePendingProviderLinkOAuthIdentity(ctx context.Context, id uuid.UUID, providerUserID string, providerEmail string, ...) error
- func (s *Store) UpdateUserEmail(ctx context.Context, userID uuid.UUID, email string) error
- func (s *Store) UpdateUsername(ctx context.Context, userID uuid.UUID, username string) error
- func (s *Store) UpsertVerificationCode(ctx context.Context, in domain.VerificationCode) error
- func (s *Store) UserExistsByEmail(ctx context.Context, email string) (bool, error)
- func (s *Store) UserHasPlatformRole(ctx context.Context, userID uuid.UUID, roleName string) (bool, error)
Constants ¶
View Source
const ( TxKey contextKey = "store.tx.state" DbKey contextKey = "store.tx.db" )
View Source
const ( ConstraintUserEmail = "unique_user_email" ConstraintUserUsername = "unique_user_username" ConstraintPasskeyCredentialID = "unique_passkey_credential_id" ConstraintAllowedEmailEmail = "unique_allowed_email" )
Variables ¶
View Source
var ( ErrUserNotFound = errors.New("user not found") ErrSessionNotFound = errors.New("session not found") ErrorAuthProviderNotFound = errors.New("auth_provider not found") ErrRefreshTokenNotFound = errors.New("refresh_token not found") ErrorChallengeNotFound = errors.New("challenge not found") ErrorChallengeAlreadyConsumed = errors.New("challenge already consumed") ErrorVerificationCodeNotFound = errors.New("verification code not found") ErrorEmailJobNotFound = errors.New("email job not found") ErrorPendingSignupActionNotFound = errors.New("pending signup action not found") ErrorPendingPasswordResetNotFound = errors.New("pending password reset not found") ErrorPendingEmailChangeNotFound = errors.New("pending email change not found") ErrorRoleNotFound = errors.New("role not found") ErrorPendingProviderLinkNotFound = errors.New("pending provider link not found") ErrPasskeyNotFound = errors.New("passkey not found") ErrPasskeyAlreadyExists = errors.New("passkey already exists") ErrWebAuthnChallengeNotFound = errors.New("webauthn challenge not found") ErrWebAuthnChallengeAlreadyConsumed = errors.New("webauthn challenge already consumed") ErrAllowedEmailNotFound = errors.New("allowed email not found") ErrAllowedEmailAlreadyExists = errors.New("allowed email already exists") )
Functions ¶
func IsUniqueViolation ¶
func NormalizeUsername ¶
Types ¶
type AdminAuditEventFilter ¶ added in v0.1.23
type Config ¶
type Config struct {
Host string
Port int
Username string
Password string
Database string
Timezone string
Schema string
LogSql bool
MaxOpenConns int
MaxIdleConns int
ConnMaxLifetime time.Duration
ConnMaxIdleTime time.Duration
}
Config is the configuration for the database.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AddUserPlatformRoleByName ¶ added in v0.1.13
func (*Store) ClaimNextEmailJob ¶ added in v0.1.12
func (*Store) ConsumeChallenge ¶ added in v0.1.12
func (*Store) ConsumePendingProviderLink ¶ added in v0.1.17
func (*Store) ConsumeRefreshToken ¶
func (*Store) ConsumeWebAuthnChallenge ¶ added in v0.1.21
func (*Store) CountActiveSessions ¶ added in v0.1.23
func (*Store) CountActiveSessionsByUserID ¶ added in v0.1.23
func (*Store) CountActiveUsersWithRole ¶ added in v0.1.23
func (*Store) CountAllowedEmails ¶ added in v0.1.23
func (*Store) CountAuthMethods ¶ added in v0.1.21
func (*Store) CountDisabledUsers ¶ added in v0.1.23
func (*Store) CountRecentFailedEmailJobs ¶ added in v0.1.23
func (*Store) CountRecentRiskyChallenges ¶ added in v0.1.23
func (*Store) CountUsers ¶ added in v0.1.23
func (*Store) CountUsersCreatedSince ¶ added in v0.1.23
func (*Store) CountUsersWithRole ¶ added in v0.1.23
func (*Store) CreateAdminAuditEvent ¶ added in v0.1.23
func (s *Store) CreateAdminAuditEvent(ctx context.Context, event domain.AdminAuditEvent) (domain.AdminAuditEvent, error)
func (*Store) CreateAllowedEmail ¶ added in v0.1.10
func (*Store) CreateAuthProvider ¶
func (s *Store) CreateAuthProvider(ctx context.Context, provider domain.AuthProvider) (domain.AuthProvider, error)
func (*Store) CreateChallenge ¶ added in v0.1.12
func (*Store) CreateEmailJob ¶ added in v0.1.12
func (*Store) CreatePasskey ¶ added in v0.1.21
func (*Store) CreatePendingEmailChange ¶ added in v0.1.15
func (s *Store) CreatePendingEmailChange(ctx context.Context, in domain.PendingEmailChange) (domain.PendingEmailChange, error)
func (*Store) CreatePendingPasswordReset ¶ added in v0.1.14
func (s *Store) CreatePendingPasswordReset(ctx context.Context, in domain.PendingPasswordReset) (domain.PendingPasswordReset, error)
func (*Store) CreatePendingProviderLink ¶ added in v0.1.17
func (s *Store) CreatePendingProviderLink(ctx context.Context, link domain.PendingProviderLink) (domain.PendingProviderLink, error)
func (*Store) CreatePendingSignupAction ¶ added in v0.1.12
func (s *Store) CreatePendingSignupAction(ctx context.Context, in domain.PendingSignupAction) (domain.PendingSignupAction, error)
func (*Store) CreateRefreshToken ¶
func (*Store) CreateSession ¶
func (*Store) CreateUser ¶
func (*Store) CreateWebAuthnChallenge ¶ added in v0.1.21
func (s *Store) CreateWebAuthnChallenge(ctx context.Context, in domain.WebAuthnChallenge) (domain.WebAuthnChallenge, error)
func (*Store) CurrentSchemaVersion ¶
func (*Store) DeleteAdminAuditEventsBefore ¶ added in v0.1.23
func (*Store) DeleteAllowedEmail ¶ added in v0.1.10
func (*Store) DeleteAllowedEmailByID ¶ added in v0.1.23
func (*Store) DeleteAuthProviderByMethodAndUserID ¶ added in v0.1.17
func (*Store) DeleteExpiredChallenges ¶ added in v0.1.18
func (*Store) DeleteExpiredRefreshTokens ¶
func (*Store) DeleteExpiredSessions ¶
func (*Store) DeleteExpiredWebAuthnChallenges ¶ added in v0.1.21
func (*Store) DeleteFailedEmailJobsBefore ¶ added in v0.1.12
func (*Store) DeletePasskeyByIDAndUserID ¶ added in v0.1.21
func (*Store) DeletePendingEmailChangeByChallengeID ¶ added in v0.1.15
func (*Store) DeletePendingPasswordResetByChallengeID ¶ added in v0.1.14
func (*Store) DeleteRefreshTokensBySession ¶
func (*Store) DeleteRefreshTokensByUserID ¶ added in v0.1.18
func (*Store) DeleteRefreshTokensForOtherSessions ¶ added in v0.1.16
func (*Store) DeleteSentEmailJobsBefore ¶ added in v0.1.12
func (*Store) DisableUser ¶
func (*Store) EnableUser ¶ added in v0.1.23
func (*Store) GetActiveSessionByID ¶ added in v0.1.16
func (*Store) GetAuthProviderByMethodAndUserID ¶
func (*Store) GetAuthProviderByProviderAndProviderUserID ¶
func (*Store) GetChallengeByID ¶ added in v0.1.12
func (*Store) GetChallengeByIDForUpdate ¶ added in v0.1.18
func (*Store) GetPasskeyByCredentialID ¶ added in v0.1.21
func (*Store) GetPasskeyByID ¶ added in v0.1.21
func (*Store) GetPendingEmailChangeByChallengeID ¶ added in v0.1.15
func (*Store) GetPendingPasswordResetByChallengeID ¶ added in v0.1.14
func (*Store) GetPendingProviderLinkByID ¶ added in v0.1.17
func (*Store) GetPendingSignupActionByChallengeID ¶ added in v0.1.12
func (*Store) GetRefreshTokenByHash ¶
func (*Store) GetSessionByID ¶
func (*Store) GetUserByEmail ¶
func (*Store) GetUserByEmailOrUsername ¶ added in v0.1.23
func (*Store) GetUserByID ¶
func (*Store) GetUserPlatformRoleNames ¶ added in v0.1.13
func (*Store) GetVerificationCodeByChallengeID ¶ added in v0.1.12
func (*Store) GetWebAuthnChallengeByIDForUpdate ¶ added in v0.1.21
func (*Store) IncrementChallengeAttemptCount ¶ added in v0.1.12
func (*Store) IncrementChallengeResendCount ¶ added in v0.1.12
func (*Store) IsEmailAllowed ¶ added in v0.1.10
func (*Store) IsUserDisabled ¶
func (*Store) ListActiveSessionsByUserID ¶ added in v0.1.16
func (*Store) ListAdminAuditEvents ¶ added in v0.1.23
func (s *Store) ListAdminAuditEvents(ctx context.Context, filter AdminAuditEventFilter) ([]domain.AdminAuditEvent, error)
func (*Store) ListAllowedEmails ¶ added in v0.1.13
func (*Store) ListAllowedEmailsPage ¶ added in v0.1.23
func (*Store) ListAuthProvidersByUserID ¶ added in v0.1.17
func (*Store) ListPasskeysByUserID ¶ added in v0.1.21
func (*Store) ListRecentFailedEmailJobs ¶ added in v0.1.23
func (*Store) ListRecentRiskyChallenges ¶ added in v0.1.23
func (*Store) ListSessionsByUserID ¶ added in v0.1.23
func (*Store) LockPlatformRoleByName ¶ added in v0.1.23
func (*Store) LockUserForAuthMethodMutation ¶ added in v0.1.21
func (*Store) MarkEmailJobFailed ¶ added in v0.1.12
func (*Store) MarkEmailJobSent ¶ added in v0.1.12
func (*Store) RemoveUserPlatformRoleByName ¶ added in v0.1.13
func (*Store) RequeueEmailJob ¶ added in v0.1.12
func (*Store) RevokeAllActiveSessionsForUser ¶ added in v0.1.23
func (*Store) RevokeAllSessionsForUser ¶
func (*Store) RevokeOtherSessionsByUserID ¶ added in v0.1.16
func (*Store) RevokeSession ¶
func (*Store) RevokeSessionByIDAndUserID ¶ added in v0.1.23
func (*Store) SetChallengeLastSentAt ¶ added in v0.1.12
func (*Store) UpdatePasskeyAfterLogin ¶ added in v0.1.21
func (*Store) UpdatePasswordHash ¶ added in v0.1.14
func (*Store) UpdatePendingProviderLinkOAuthIdentity ¶ added in v0.1.19
func (*Store) UpdateUserEmail ¶ added in v0.1.15
func (*Store) UpdateUsername ¶
func (*Store) UpsertVerificationCode ¶ added in v0.1.12
func (*Store) UserExistsByEmail ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.