Documentation
¶
Overview ¶
Package postgres provides a Postgres-backed storage.Storage implementation built on top of sqlc-generated queries and pgx/v5.
Index ¶
- type Store
- func (s *Store) ConfirmTOTPSecret(ctx context.Context, userID theauth.ULID, at time.Time) error
- func (s *Store) ConsumeMagicLink(ctx context.Context, tokenHash []byte) (*theauth.MagicLink, error)
- func (s *Store) ConsumePasswordResetToken(ctx context.Context, tokenHash []byte) (*theauth.PasswordResetToken, error)
- func (s *Store) ConsumeRecoveryCode(ctx context.Context, userID theauth.ULID, code string, at time.Time) error
- func (s *Store) CreateMagicLink(ctx context.Context, ml theauth.MagicLink) error
- func (s *Store) CreatePasswordResetToken(ctx context.Context, t theauth.PasswordResetToken) error
- func (s *Store) CreateSession(ctx context.Context, sess theauth.Session) (theauth.Session, error)
- func (s *Store) CreateSessionWithAuthLevel(ctx context.Context, sess theauth.Session) (theauth.Session, error)
- func (s *Store) CreateUser(ctx context.Context, u theauth.User) (theauth.User, error)
- func (s *Store) DeleteTOTPSecret(ctx context.Context, userID theauth.ULID) error
- func (s *Store) DeleteWebAuthnCredential(ctx context.Context, id theauth.ULID, userID theauth.ULID) error
- func (s *Store) InsertRecoveryCodes(ctx context.Context, codes []theauth.RecoveryCode) error
- func (s *Store) InsertWebAuthnCredential(ctx context.Context, c theauth.WebAuthnCredential) (theauth.WebAuthnCredential, error)
- func (s *Store) MarkEmailVerified(ctx context.Context, userID theauth.ULID) error
- func (s *Store) OAuthAccountByProviderUserID(ctx context.Context, provider, providerUserID string) (*theauth.OAuthAccount, error)
- func (s *Store) RevokeSession(ctx context.Context, id theauth.ULID) error
- func (s *Store) RevokeUserSessions(ctx context.Context, userID theauth.ULID) error
- func (s *Store) SessionByTokenHash(ctx context.Context, hash []byte) (*theauth.Session, error)
- func (s *Store) SetUserPassword(ctx context.Context, userID theauth.ULID, passwordHash string) error
- func (s *Store) TOTPSecretByUserID(ctx context.Context, userID theauth.ULID) (*theauth.TOTPSecret, error)
- func (s *Store) UpdateSessionAuthLevel(ctx context.Context, id theauth.ULID, level string) error
- func (s *Store) UpdateWebAuthnSignCount(ctx context.Context, credentialID []byte, newCount uint32, usedAt time.Time) error
- func (s *Store) UpsertOAuthAccount(ctx context.Context, a theauth.OAuthAccount) (theauth.OAuthAccount, error)
- func (s *Store) UpsertPendingTOTPSecret(ctx context.Context, sec theauth.TOTPSecret) error
- func (s *Store) UserByEmail(ctx context.Context, email string) (*theauth.User, error)
- func (s *Store) UserByEmailWithPassword(ctx context.Context, email string) (*theauth.User, string, error)
- func (s *Store) UserByID(ctx context.Context, id theauth.ULID) (*theauth.User, error)
- func (s *Store) WebAuthnCredentialByCredentialID(ctx context.Context, credentialID []byte) (*theauth.WebAuthnCredential, error)
- func (s *Store) WebAuthnCredentialsByUserID(ctx context.Context, userID theauth.ULID) ([]theauth.WebAuthnCredential, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the Postgres-backed storage adapter.
func (*Store) ConfirmTOTPSecret ¶ added in v0.5.0
func (*Store) ConsumeMagicLink ¶
func (*Store) ConsumePasswordResetToken ¶ added in v0.2.0
func (*Store) ConsumeRecoveryCode ¶ added in v0.5.0
func (*Store) CreateMagicLink ¶
func (*Store) CreatePasswordResetToken ¶ added in v0.2.0
func (*Store) CreateSession ¶
func (*Store) CreateSessionWithAuthLevel ¶ added in v0.5.0
func (*Store) CreateUser ¶
func (*Store) DeleteTOTPSecret ¶ added in v0.5.0
func (*Store) DeleteWebAuthnCredential ¶ added in v0.5.0
func (*Store) InsertRecoveryCodes ¶ added in v0.5.0
func (*Store) InsertWebAuthnCredential ¶ added in v0.5.0
func (s *Store) InsertWebAuthnCredential(ctx context.Context, c theauth.WebAuthnCredential) (theauth.WebAuthnCredential, error)
func (*Store) MarkEmailVerified ¶
func (*Store) OAuthAccountByProviderUserID ¶ added in v0.3.0
func (*Store) RevokeSession ¶
func (*Store) RevokeUserSessions ¶
func (*Store) SessionByTokenHash ¶
func (*Store) SetUserPassword ¶ added in v0.2.0
func (*Store) TOTPSecretByUserID ¶ added in v0.5.0
func (*Store) UpdateSessionAuthLevel ¶ added in v0.5.0
func (*Store) UpdateWebAuthnSignCount ¶ added in v0.5.0
func (s *Store) UpdateWebAuthnSignCount(ctx context.Context, credentialID []byte, newCount uint32, usedAt time.Time) error
UpdateWebAuthnSignCount executes the strictly-greater UPDATE; zero rows affected with the credential present means the supplied count was not strictly greater than the stored one, which is the WebAuthn replay signal. We disambiguate "no such credential" from "replay" via a follow up SELECT only when the UPDATE is a miss, to keep the happy path single round-trip.
func (*Store) UpsertOAuthAccount ¶ added in v0.3.0
func (s *Store) UpsertOAuthAccount(ctx context.Context, a theauth.OAuthAccount) (theauth.OAuthAccount, error)