postgres

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package postgres provides Authlier storage backed by PostgreSQL.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidConfig = errors.New("invalid PostgreSQL adapter configuration")

Functions

This section is empty.

Types

type AccessSessionStore

type AccessSessionStore struct {
	// contains filtered or unexported fields
}

func (*AccessSessionStore) CreateSession

func (store *AccessSessionStore) CreateSession(
	ctx context.Context,
	session authlier.AccessSession,
	refreshToken refreshtoken.Record,
) error

func (*AccessSessionStore) ListBySubject

func (store *AccessSessionStore) ListBySubject(
	ctx context.Context,
	subjectID string,
) ([]authlier.AccessSession, error)

func (*AccessSessionStore) ResolveSession

func (store *AccessSessionStore) ResolveSession(
	ctx context.Context,
	sessionID string,
) (accesstoken.Session, error)

func (*AccessSessionStore) Revoke

func (store *AccessSessionStore) Revoke(
	ctx context.Context,
	sessionID string,
	revokedAt time.Time,
) error

func (*AccessSessionStore) RevokeAll

func (store *AccessSessionStore) RevokeAll(
	ctx context.Context,
	subjectID string,
	revokedAt time.Time,
) error

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

func New

func New(pool *pgxpool.Pool, config Config) (*Adapter, error)

func (*Adapter) AccessSessions

func (adapter *Adapter) AccessSessions() *AccessSessionStore

func (*Adapter) EmailPassword

func (adapter *Adapter) EmailPassword() *EmailPasswordStore

func (*Adapter) EmailVerification

func (adapter *Adapter) EmailVerification() *EmailVerificationStore

func (*Adapter) Google

func (adapter *Adapter) Google() *GoogleStore

func (*Adapter) Migrate

func (adapter *Adapter) Migrate(ctx context.Context) error

func (*Adapter) OIDC

func (adapter *Adapter) OIDC() *OIDCStore

func (*Adapter) Passkeys

func (adapter *Adapter) Passkeys() *PasskeyStore

func (*Adapter) PasswordReset

func (adapter *Adapter) PasswordReset() *PasswordResetStore

func (*Adapter) RefreshTokens

func (adapter *Adapter) RefreshTokens() *RefreshTokenStore

func (*Adapter) SAML

func (adapter *Adapter) SAML() *SAMLStore

func (*Adapter) Sessions

func (adapter *Adapter) Sessions() *SessionStore

func (*Adapter) Stores

func (adapter *Adapter) Stores() authlier.Stores

func (*Adapter) TOTP

func (adapter *Adapter) TOTP() *TOTPStore

type Config

type Config struct {
	Secrets SecretCodec
}

type EmailPasswordStore

type EmailPasswordStore struct {
	// contains filtered or unexported fields
}

func (*EmailPasswordStore) AddPassword

func (store *EmailPasswordStore) AddPassword(
	ctx context.Context,
	subjectID, passwordHash string,
	addedAt time.Time,
) (emailpassword.User, error)

func (*EmailPasswordStore) FindByEmail

func (*EmailPasswordStore) FindBySubject

func (store *EmailPasswordStore) FindBySubject(
	ctx context.Context,
	subjectID string,
) (emailpassword.User, emailpassword.PasswordCredential, error)

func (*EmailPasswordStore) Register

func (store *EmailPasswordStore) Register(
	ctx context.Context,
	registration emailpassword.Registration,
) (emailpassword.User, error)

func (*EmailPasswordStore) RemovePassword

func (store *EmailPasswordStore) RemovePassword(
	ctx context.Context,
	subjectID, currentHash string,
	_ time.Time,
) error

func (*EmailPasswordStore) ReplacePasswordHash

func (store *EmailPasswordStore) ReplacePasswordHash(
	ctx context.Context,
	userID, currentHash, replacementHash string,
	updatedAt time.Time,
) error

type EmailVerificationStore

type EmailVerificationStore struct {
	// contains filtered or unexported fields
}

func (*EmailVerificationStore) FindUserByEmail

func (store *EmailVerificationStore) FindUserByEmail(
	ctx context.Context,
	email string,
) (emailverification.User, error)

func (*EmailVerificationStore) Issue

func (*EmailVerificationStore) Verify

func (store *EmailVerificationStore) Verify(
	ctx context.Context,
	tokenHash emailverification.TokenHash,
	verifiedAt time.Time,
) (emailverification.User, error)

type GoogleStore

type GoogleStore struct {
	// contains filtered or unexported fields
}

func (*GoogleStore) ConsumeChallenge

func (store *GoogleStore) ConsumeChallenge(
	ctx context.Context,
	stateHash [32]byte,
	consumedAt time.Time,
) (googleoauth.Challenge, error)

func (*GoogleStore) CreateChallenge

func (store *GoogleStore) CreateChallenge(ctx context.Context, challenge googleoauth.Challenge) error

func (*GoogleStore) ListIdentities

func (store *GoogleStore) ListIdentities(
	ctx context.Context,
	subjectID string,
) ([]googleoauth.LinkedIdentity, error)

func (*GoogleStore) ResolveIdentity

func (store *GoogleStore) ResolveIdentity(
	ctx context.Context,
	resolution googleoauth.IdentityResolution,
) (googleoauth.User, error)

func (*GoogleStore) UnlinkIdentity

func (store *GoogleStore) UnlinkIdentity(
	ctx context.Context,
	subjectID, providerSubject string,
	_ time.Time,
) error

type OIDCStore

type OIDCStore struct {
	// contains filtered or unexported fields
}

func (*OIDCStore) ConsumeChallenge

func (store *OIDCStore) ConsumeChallenge(
	ctx context.Context,
	stateHash oidc.StateHash,
	consumedAt time.Time,
) (oidc.Challenge, error)

func (*OIDCStore) CreateChallenge

func (store *OIDCStore) CreateChallenge(ctx context.Context, challenge oidc.Challenge) error

type PasskeyStore

type PasskeyStore struct {
	// contains filtered or unexported fields
}

func (*PasskeyStore) CompleteAuthentication

func (store *PasskeyStore) CompleteAuthentication(
	ctx context.Context,
	ceremonyHash passkey.CeremonyHash,
	subjectID string,
	previous, updated passkey.Credential,
	completedAt time.Time,
) error

func (*PasskeyStore) CompleteRegistration

func (store *PasskeyStore) CompleteRegistration(
	ctx context.Context,
	ceremonyHash passkey.CeremonyHash,
	subjectID string,
	credential passkey.Credential,
	completedAt time.Time,
) error

func (*PasskeyStore) CreateCeremony

func (store *PasskeyStore) CreateCeremony(ctx context.Context, ceremony passkey.Ceremony) error

func (*PasskeyStore) DeleteCredential

func (store *PasskeyStore) DeleteCredential(
	ctx context.Context,
	subjectID string,
	credentialID []byte,
	_ time.Time,
) error

func (*PasskeyStore) FindCeremony

func (store *PasskeyStore) FindCeremony(
	ctx context.Context,
	ceremonyHash passkey.CeremonyHash,
) (passkey.Ceremony, error)

func (*PasskeyStore) FindUserByCredential

func (store *PasskeyStore) FindUserByCredential(
	ctx context.Context,
	credentialID, userHandle []byte,
) (passkey.User, error)

func (*PasskeyStore) FindUserBySubject

func (store *PasskeyStore) FindUserBySubject(ctx context.Context, subjectID string) (passkey.User, error)

type PasswordResetStore

type PasswordResetStore struct {
	// contains filtered or unexported fields
}

func (*PasswordResetStore) FindUserByEmail

func (store *PasswordResetStore) FindUserByEmail(
	ctx context.Context,
	email string,
) (passwordreset.User, error)

func (*PasswordResetStore) Issue

func (store *PasswordResetStore) Issue(ctx context.Context, record passwordreset.Record) error

func (*PasswordResetStore) ResetPassword

func (store *PasswordResetStore) ResetPassword(
	ctx context.Context,
	tokenHash passwordreset.TokenHash,
	passwordHash string,
	resetAt time.Time,
) (passwordreset.User, error)

type RefreshTokenStore

type RefreshTokenStore struct {
	// contains filtered or unexported fields
}

func (*RefreshTokenStore) Create

func (store *RefreshTokenStore) Create(ctx context.Context, record refreshtoken.Record) error

func (*RefreshTokenStore) FindByTokenHash

func (store *RefreshTokenStore) FindByTokenHash(
	ctx context.Context,
	tokenHash refreshtoken.TokenHash,
) (refreshtoken.Record, error)

func (*RefreshTokenStore) RevokeSession

func (store *RefreshTokenStore) RevokeSession(
	ctx context.Context,
	sessionID string,
	revokedAt time.Time,
) error

func (*RefreshTokenStore) Rotate

func (store *RefreshTokenStore) Rotate(
	ctx context.Context,
	current refreshtoken.TokenHash,
	replacement refreshtoken.Record,
	rotatedAt time.Time,
) error

type SAMLStore

type SAMLStore struct {
	// contains filtered or unexported fields
}

func (*SAMLStore) ConsumeRequest

func (store *SAMLStore) ConsumeRequest(
	ctx context.Context,
	stateHash saml.StateHash,
	consumedAt time.Time,
) (saml.Request, error)

func (*SAMLStore) CreateRequest

func (store *SAMLStore) CreateRequest(ctx context.Context, request saml.Request) error

type SecretCodec

type SecretCodec interface {
	Encrypt(ctx context.Context, plaintext []byte) ([]byte, error)
	Decrypt(ctx context.Context, ciphertext []byte) ([]byte, error)
}

type SessionStore

type SessionStore struct {
	// contains filtered or unexported fields
}

func (*SessionStore) Create

func (store *SessionStore) Create(ctx context.Context, record sessiontoken.Record) error

func (*SessionStore) Extend

func (store *SessionStore) Extend(
	ctx context.Context,
	tokenHash sessiontoken.TokenHash,
	extendedAt, expiresAt time.Time,
) (sessiontoken.Record, error)

func (*SessionStore) FindByTokenHash

func (store *SessionStore) FindByTokenHash(
	ctx context.Context,
	tokenHash sessiontoken.TokenHash,
) (sessiontoken.Record, error)

func (*SessionStore) ListBySubject

func (store *SessionStore) ListBySubject(
	ctx context.Context,
	subjectID string,
) ([]sessiontoken.Record, error)

func (*SessionStore) Revoke

func (store *SessionStore) Revoke(
	ctx context.Context,
	tokenHash sessiontoken.TokenHash,
	revokedAt time.Time,
) error

func (*SessionStore) RevokeAll

func (store *SessionStore) RevokeAll(
	ctx context.Context,
	subjectID string,
	revokedAt time.Time,
) ([]sessiontoken.Record, error)

func (*SessionStore) Rotate

func (store *SessionStore) Rotate(
	ctx context.Context,
	current sessiontoken.TokenHash,
	replacement sessiontoken.Record,
	rotatedAt time.Time,
) error

type TOTPStore

type TOTPStore struct {
	// contains filtered or unexported fields
}

func (*TOTPStore) BeginEnrollment

func (store *TOTPStore) BeginEnrollment(ctx context.Context, enrollment totp.Enrollment) error

func (*TOTPStore) CompleteCode

func (store *TOTPStore) CompleteCode(
	ctx context.Context,
	challengeHash totp.ChallengeHash,
	counter uint64,
	completedAt time.Time,
) (string, error)

func (*TOTPStore) CompleteRecovery

func (store *TOTPStore) CompleteRecovery(
	ctx context.Context,
	challengeHash totp.ChallengeHash,
	recoveryCode totp.RecoveryCodeHash,
	completedAt time.Time,
) (string, error)

func (*TOTPStore) CreateChallenge

func (store *TOTPStore) CreateChallenge(ctx context.Context, challenge totp.Challenge) error

func (*TOTPStore) Disable

func (store *TOTPStore) Disable(ctx context.Context, subjectID string, disabledAt time.Time) error

func (*TOTPStore) Enable

func (store *TOTPStore) Enable(
	ctx context.Context,
	subjectID string,
	confirmedCounter uint64,
	recoveryCodes []totp.RecoveryCodeHash,
	enabledAt time.Time,
) error

func (*TOTPStore) FindChallenge

func (store *TOTPStore) FindChallenge(
	ctx context.Context,
	challengeHash totp.ChallengeHash,
) (totp.Challenge, totp.Credential, error)

func (*TOTPStore) FindEnrollment

func (store *TOTPStore) FindEnrollment(
	ctx context.Context,
	subjectID string,
) (totp.Enrollment, error)

func (*TOTPStore) IsEnabled

func (store *TOTPStore) IsEnabled(ctx context.Context, subjectID string) (bool, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL