Help us shape the future of Go! Take the 2026 Go Developer Survey

db

package
v0.62.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Schema indirection (authkit issue 69).

Every SQL statement in authkit — the sqlc-generated constants in this package and the few raw statements in core — is schema-qualified with the literal prefix "profiles.". Hosts embed authkit with a pgx pool that is SHARED with their own queries, so pointing authkit at a different schema via search_path on the pool is ruled out (it would leak into host queries). Instead the qualifier stays in the SQL text and becomes a variable: ForSchema wraps a DBTX so the "profiles." prefix is rewritten to "<schema>." on every statement at execution time. This is a deliberate, documented string substitution: schema names are validated against a strict identifier grammar (ValidSchemaName) at configuration time, every authkit table/function reference is written as `profiles.<name>` (guarded by a test in this package), and the rewrite is the identity (no wrapper at all) for the default schema, so existing embedders see zero change.

Index

Constants

View Source
const DefaultSchema = "profiles"

DefaultSchema is the historical hard-coded schema name. All SQL in this package is written against it; ForSchema rewrites it when a host configures a different schema.

Variables

This section is empty.

Functions

func RewriteSQL added in v0.26.0

func RewriteSQL(sql, schema string) string

RewriteSQL returns sql with every literal "profiles." qualifier replaced by schema+".". Callers must have validated schema via ValidSchemaName.

func ValidSchemaName added in v0.26.0

func ValidSchemaName(s string) bool

ValidSchemaName reports whether s is acceptable as a configured schema name: lowercase snake_case identifier, at most 63 bytes (the Postgres identifier limit, so the name is never silently truncated server-side).

Types

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

func ForSchema added in v0.26.0

func ForSchema(d DBTX, schema string) DBTX

ForSchema wraps d so every statement executed through it has its "profiles." qualifiers rewritten to the given schema. For the default schema (or empty, meaning default) it returns d unchanged, so the default path has zero overhead. The per-call strings.ReplaceAll is negligible next to the network round trip and keeps the wrapper stateless, which matters because transaction-scoped wrappers are created per transaction.

type IdentityUpdateUserEmailParams

type IdentityUpdateUserEmailParams struct {
	ID    string
	Email *string
}

type IdentityUpdateUserUsernameParams

type IdentityUpdateUserUsernameParams struct {
	ID       string
	Username *string
}

type IdentityUserByIDRow

type IdentityUserByIDRow struct {
	ID            string
	Email         *string
	Username      *string
	EmailVerified bool
}

type IdentityUsersByIDsRow

type IdentityUsersByIDsRow struct {
	ID       string
	Username *string
	Email    *string
}

type MFAConsumeFactorTOTPStepParams added in v0.56.0

type MFAConsumeFactorTOTPStepParams struct {
	Step   *int64
	ID     string
	UserID string
}

type MFADeleteFactorParams added in v0.56.0

type MFADeleteFactorParams struct {
	UserID string
	ID     string
}

type MFAFactorByUserMethodParams added in v0.56.0

type MFAFactorByUserMethodParams struct {
	UserID string
	Method string
}

type MFASetBackupCodesParams added in v0.56.0

type MFASetBackupCodesParams struct {
	BackupCodes []string
	UserID      string
}

type MFASetDefaultFactorParams added in v0.56.0

type MFASetDefaultFactorParams struct {
	UserID string
	ID     string
}

type MFAUpsertFactorParams added in v0.56.0

type MFAUpsertFactorParams struct {
	UserID       string
	Method       string
	PhoneNumber  *string
	TotpSecret   []byte
	LastTotpStep *int64
	IsDefault    bool
}

type MFAUpsertSettingsParams added in v0.56.0

type MFAUpsertSettingsParams struct {
	UserID      string
	BackupCodes []string
}

type NamespaceUserBySlugRow

type NamespaceUserBySlugRow struct {
	ID       string
	Username string
	Deleted  bool
	Reserved bool
}

type NamespaceUserRenameBySlugRow

type NamespaceUserRenameBySlugRow struct {
	ID        string
	Username  string
	Deleted   bool
	RenamedAt time.Time
}

type OwnerSlugUserExistsParams

type OwnerSlugUserExistsParams struct {
	Slug          string
	ExcludeUserID string
}

type OwnerSlugUserRenameHeldParams

type OwnerSlugUserRenameHeldParams struct {
	Slug          string
	ReuseCutoff   time.Time
	ExcludeUserID string
}

type ProfilesApiKey added in v0.56.0

type ProfilesApiKey struct {
	ID                string
	PermissionGroupID string
	KeyID             string
	SecretHash        []byte
	Name              string
	CreatedBy         *string
	CreatedAt         time.Time
	LastUsedAt        *time.Time
	ExpiresAt         *time.Time
	RevokedAt         *time.Time
	// The single catalog/custom role this API key holds within its permission-group. Resource-scope is a separate binding.
	Role string
}

type ProfilesApiKeyResource added in v0.56.0

type ProfilesApiKeyResource struct {
	ApiKeyID   string
	Kind       string
	ResourceID string
	CreatedAt  time.Time
}

type ProfilesGroupCustomRole added in v0.49.0

type ProfilesGroupCustomRole struct {
	GroupID     string
	Role        string
	Permissions []string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}
type ProfilesGroupInviteLink struct {
	ID        string
	GroupID   string
	Role      string
	InvitedBy string
	CodeHash  string
	Email     *string
	MaxUses   *int32
	Uses      int32
	ExpiresAt *time.Time
	RevokedAt *time.Time
	CreatedAt time.Time
	UpdatedAt time.Time
}

type ProfilesGroupPersonaParent added in v0.56.0

type ProfilesGroupPersonaParent struct {
	Persona              string
	AllowedParentPersona string
	CreatedAt            time.Time
}

Declared containment schema: which parent persona each permission-group persona allows. root is absent.

type ProfilesGroupRemoteApplicationRole added in v0.56.0

type ProfilesGroupRemoteApplicationRole struct {
	GroupID             string
	RemoteApplicationID string
	Role                string
	CreatedAt           time.Time
	UpdatedAt           time.Time
	DeletedAt           *time.Time
}

type ProfilesGroupUserRole added in v0.56.0

type ProfilesGroupUserRole struct {
	GroupID   string
	UserID    string
	Role      string
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
}

type ProfilesMfaFactor added in v0.56.0

type ProfilesMfaFactor struct {
	ID           string
	UserID       string
	Method       string
	PhoneNumber  *string
	TotpSecret   []byte
	LastTotpStep *int64
	// Default factor AuthKit challenges first when 2FA is required
	IsDefault bool
	CreatedAt time.Time
	UpdatedAt time.Time
}

Enrolled 2FA factors per user (hard-deleted on removal); backup codes remain user-scoped on mfa_settings

type ProfilesMfaSetting added in v0.56.0

type ProfilesMfaSetting struct {
	UserID  string
	Enabled bool
	// Hashed backup codes for account recovery
	BackupCodes []string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

Account-level 2FA gate + backup codes per user. enabled=true ⇒ 2FA required at login. Per-factor data lives in mfa_factors.

type ProfilesOwnerReservedName

type ProfilesOwnerReservedName struct {
	Slug      string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type ProfilesPermissionGroup added in v0.49.0

type ProfilesPermissionGroup struct {
	ID            string
	Persona       string
	ParentID      *string
	ParentPersona *string
	// Lowercase URL-safe slug identifying WHICH instance of the persona (e.g. acme-store for a merchant); the API addressing key. The group id is internal only.
	InstanceSlug *string
	Metadata     []byte
	CreatedAt    time.Time
	UpdatedAt    time.Time
	DeletedAt    *time.Time
}

type ProfilesRefreshSession

type ProfilesRefreshSession struct {
	ID                  string
	UserID              string
	Issuer              string
	FamilyID            string
	CurrentTokenHash    []byte
	PreviousTokenHash   []byte
	CreatedAt           time.Time
	LastAuthenticatedAt *time.Time
	LastUsedAt          time.Time
	ExpiresAt           *time.Time
	RevokedAt           *time.Time
	UserAgent           *string
	IpAddr              *string
	AuthMethods         []string
}

type ProfilesRemoteApplication added in v0.27.0

type ProfilesRemoteApplication struct {
	ID         string
	Slug       string
	Issuer     string
	JwksUri    string
	Mode       string
	PublicKeys []byte
	Audiences  []string
	Enabled    bool
	Metadata   []byte
	CreatedAt  time.Time
	UpdatedAt  time.Time
	DeletedAt  *time.Time
	// Required controlling permission-group. Authority comes from group_remote_application_roles and the parent walk.
	PermissionGroupID string
	AllowedOrigins    []string
}

Federation principals: external systems that authenticate by signing JWTs verified against configured keys.

type ProfilesRemoteApplicationAttributeDef added in v0.27.0

type ProfilesRemoteApplicationAttributeDef struct {
	RemoteApplicationID string
	Key                 string
	Version             int32
	Definition          []byte
	CreatedAt           time.Time
	UpdatedAt           time.Time
}

Reference-mode attribute definitions: opaque JSON by remote application, key, and version.

type ProfilesUser

type ProfilesUser struct {
	ID            string
	Email         *string
	Username      *string
	EmailVerified bool
	// E.164 format phone number (e.g. +14155551234)
	PhoneNumber *string
	// Whether the phone number has been verified via SMS code
	PhoneVerified bool
	// When the user was banned
	BannedAt *time.Time
	// When a temporary ban expires (NULL for permanent)
	BannedUntil *time.Time
	// Reason for ban
	BanReason *string
	// User ID of admin who imposed ban
	BannedBy  *string
	DeletedAt *time.Time
	Biography *string
	// Arbitrary user metadata (internal/admin flags such as reserved)
	Metadata  []byte
	CreatedAt time.Time
	UpdatedAt time.Time
	LastLogin *time.Time
	// User communication/auth language, e.g. en, es, de, ko, zh
	PreferredLanguage *string
}

type ProfilesUserPasskey added in v0.56.0

type ProfilesUserPasskey struct {
	ID                      string
	UserID                  string
	Rpid                    string
	CredentialID            []byte
	PublicKey               []byte
	SignCount               int64
	CloneWarning            bool
	Aaguid                  []byte
	Transports              []string
	AuthenticatorAttachment string
	BackupEligible          bool
	BackupState             bool
	UserPresent             bool
	UserVerified            bool
	Flags                   []byte
	AttestationType         string
	AttestationFmt          string
	Label                   *string
	CreatedAt               time.Time
	LastUsedAt              *time.Time
	DeletedAt               *time.Time
}

type ProfilesUserPasskeyHandle added in v0.56.0

type ProfilesUserPasskeyHandle struct {
	UserID     string
	Rpid       string
	UserHandle []byte
	CreatedAt  time.Time
}

type ProfilesUserPassword

type ProfilesUserPassword struct {
	UserID            string
	PasswordHash      string
	HashAlgo          string
	HashParams        []byte
	PasswordUpdatedAt time.Time
}

type ProfilesUserProvider

type ProfilesUserProvider struct {
	ID              string
	UserID          string
	Issuer          string
	ProviderSlug    *string
	Subject         string
	EmailAtProvider *string
	Profile         []byte
	CreatedAt       time.Time
}

type ProfilesUserRename

type ProfilesUserRename struct {
	ID        int64
	UserID    string
	FromSlug  string
	RenamedAt time.Time
}

type ProviderLinkByIssuerParams

type ProviderLinkByIssuerParams struct {
	Issuer  string
	Subject string
}

type ProviderLinkByIssuerRow

type ProviderLinkByIssuerRow struct {
	UserID          string
	EmailAtProvider *string
}

type ProviderLinkBySlugParams

type ProviderLinkBySlugParams struct {
	ProviderSlug *string
	Subject      string
}

type ProviderLinkBySlugRow

type ProviderLinkBySlugRow struct {
	UserID          string
	EmailAtProvider *string
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) GroupAssignmentsDeleteByUser added in v0.56.0

func (q *Queries) GroupAssignmentsDeleteByUser(ctx context.Context, userID string) error

#125 D7: pre-delete cleanup for the hard-delete/purge path. group_invites.invited_by is ON DELETE RESTRICT so sent invites must be cleared before the user row is removed.

func (*Queries) IdentityCurrentUsername

func (q *Queries) IdentityCurrentUsername(ctx context.Context, username *string) (*string, error)

Rename-history forwarding (identity/renames.go).

func (*Queries) IdentityForwardUsername

func (q *Queries) IdentityForwardUsername(ctx context.Context, fromSlug string) (*string, error)

func (*Queries) IdentityUpdateUserEmail

func (q *Queries) IdentityUpdateUserEmail(ctx context.Context, arg IdentityUpdateUserEmailParams) error

func (*Queries) IdentityUpdateUserUsername

func (q *Queries) IdentityUpdateUserUsername(ctx context.Context, arg IdentityUpdateUserUsernameParams) error

func (*Queries) IdentityUserByID

func (q *Queries) IdentityUserByID(ctx context.Context, id string) (IdentityUserByIDRow, error)

func (*Queries) IdentityUserIDByUsername

func (q *Queries) IdentityUserIDByUsername(ctx context.Context, username *string) (string, error)

func (*Queries) IdentityUsersByIDs

func (q *Queries) IdentityUsersByIDs(ctx context.Context, ids []string) ([]IdentityUsersByIDsRow, error)

Identity store queries (identity package).

func (*Queries) MFAClearDefaultFactors added in v0.56.0

func (q *Queries) MFAClearDefaultFactors(ctx context.Context, userID string) error

func (*Queries) MFAConsumeFactorTOTPStep added in v0.56.0

func (q *Queries) MFAConsumeFactorTOTPStep(ctx context.Context, arg MFAConsumeFactorTOTPStepParams) (int64, error)

func (*Queries) MFADefaultFactorByUser added in v0.56.0

func (q *Queries) MFADefaultFactorByUser(ctx context.Context, userID string) (ProfilesMfaFactor, error)

func (*Queries) MFADelete added in v0.56.0

func (q *Queries) MFADelete(ctx context.Context, userID string) error

func (*Queries) MFADeleteAllFactors added in v0.56.0

func (q *Queries) MFADeleteAllFactors(ctx context.Context, userID string) error

func (*Queries) MFADeleteFactor added in v0.56.0

func (q *Queries) MFADeleteFactor(ctx context.Context, arg MFADeleteFactorParams) (int64, error)

func (*Queries) MFADisable added in v0.56.0

func (q *Queries) MFADisable(ctx context.Context, userID string) error

Two-factor queries (core/service.go).

#125: factors are hard-deleted (no per-factor `enabled` flag). mfa_settings holds only the account-level gate (`enabled`) + `backup_codes`; per-factor data (method/phone/totp_secret/last_totp_step) lives ONLY on mfa_factors.

func (*Queries) MFAFactorByUserMethod added in v0.56.0

func (q *Queries) MFAFactorByUserMethod(ctx context.Context, arg MFAFactorByUserMethodParams) (ProfilesMfaFactor, error)

func (*Queries) MFAListFactorsByUser added in v0.56.0

func (q *Queries) MFAListFactorsByUser(ctx context.Context, userID string) ([]ProfilesMfaFactor, error)

func (*Queries) MFASetBackupCodes added in v0.56.0

func (q *Queries) MFASetBackupCodes(ctx context.Context, arg MFASetBackupCodesParams) error

func (*Queries) MFASetDefaultFactor added in v0.56.0

func (q *Queries) MFASetDefaultFactor(ctx context.Context, arg MFASetDefaultFactorParams) (int64, error)

func (*Queries) MFASettingsByUser added in v0.56.0

func (q *Queries) MFASettingsByUser(ctx context.Context, userID string) (ProfilesMfaSetting, error)

func (*Queries) MFAUpsertFactor added in v0.56.0

func (q *Queries) MFAUpsertFactor(ctx context.Context, arg MFAUpsertFactorParams) (ProfilesMfaFactor, error)

func (*Queries) MFAUpsertSettings added in v0.56.0

func (q *Queries) MFAUpsertSettings(ctx context.Context, arg MFAUpsertSettingsParams) error

func (*Queries) NamespaceUserBySlug

func (q *Queries) NamespaceUserBySlug(ctx context.Context, username *string) (NamespaceUserBySlugRow, error)

Namespace lookup probes (core/owner_namespace_lookup.go). These read soft- deleted rows on purpose (deleted_at IS NOT NULL surfaces as a flag).

func (*Queries) NamespaceUserRenameBySlug

func (q *Queries) NamespaceUserRenameBySlug(ctx context.Context, fromSlug string) (NamespaceUserRenameBySlugRow, error)

func (*Queries) OwnerReservedNameDelete

func (q *Queries) OwnerReservedNameDelete(ctx context.Context, slug string) (int64, error)

func (*Queries) OwnerReservedNameExists

func (q *Queries) OwnerReservedNameExists(ctx context.Context, slug string) (bool, error)

Owner-namespace queries (core/service_owner_namespace*.go, core/owner_namespace_lookup.go).

Permission groups own group-scoped routing now. Only the user/owner-reserved name namespace queries remain here.

func (*Queries) OwnerReservedNameUpsert

func (q *Queries) OwnerReservedNameUpsert(ctx context.Context, slug string) error

func (*Queries) OwnerSlugUserExists

func (q *Queries) OwnerSlugUserExists(ctx context.Context, arg OwnerSlugUserExistsParams) (bool, error)

Slug-availability probes (core/service_owner_namespace.go ownerSlugAvailable).

func (*Queries) OwnerSlugUserRenameHeld

func (q *Queries) OwnerSlugUserRenameHeld(ctx context.Context, arg OwnerSlugUserRenameHeldParams) (bool, error)

func (*Queries) ProviderLinkByIssuer

func (q *Queries) ProviderLinkByIssuer(ctx context.Context, arg ProviderLinkByIssuerParams) (ProviderLinkByIssuerRow, error)

func (*Queries) ProviderLinkBySlug

func (q *Queries) ProviderLinkBySlug(ctx context.Context, arg ProviderLinkBySlugParams) (ProviderLinkBySlugRow, error)

func (*Queries) RemoteAppAttributeDefDelete added in v0.27.0

func (q *Queries) RemoteAppAttributeDefDelete(ctx context.Context, arg RemoteAppAttributeDefDeleteParams) (int64, error)

func (*Queries) RemoteAppAttributeDefGet added in v0.27.0

func (*Queries) RemoteAppAttributeDefGetLatest added in v0.27.0

func (*Queries) RemoteAppAttributeDefUpsert added in v0.27.0

Attribute definition registry (#75): REFERENCE-mode opaque definitions.

func (*Queries) RemoteAppAttributeDefsList added in v0.27.0

func (q *Queries) RemoteAppAttributeDefsList(ctx context.Context, remoteApplicationID string) ([]RemoteAppAttributeDefsListRow, error)

func (*Queries) RemoteApplicationByIssuer added in v0.27.0

func (q *Queries) RemoteApplicationByIssuer(ctx context.Context, issuer string) (RemoteApplicationByIssuerRow, error)

func (*Queries) RemoteApplicationBySlug added in v0.27.0

func (q *Queries) RemoteApplicationBySlug(ctx context.Context, slug string) (RemoteApplicationBySlugRow, error)

func (*Queries) RemoteApplicationDelete added in v0.27.0

func (q *Queries) RemoteApplicationDelete(ctx context.Context, issuer string) (int64, error)

func (*Queries) RemoteApplicationUpsert added in v0.27.0

func (q *Queries) RemoteApplicationUpsert(ctx context.Context, arg RemoteApplicationUpsertParams) (RemoteApplicationUpsertRow, error)

Remote application registry (core/service_remote_applications.go). A remote_application is the federation PRINCIPAL: it authenticates by signing JWTs verified against its JWKS/public keys (#74).

The controlling group is addressed as permission_group_id throughout.

func (*Queries) RemoteApplicationsAll added in v0.27.0

func (q *Queries) RemoteApplicationsAll(ctx context.Context) ([]RemoteApplicationsAllRow, error)

func (*Queries) RemoteApplicationsEnabled added in v0.27.0

func (q *Queries) RemoteApplicationsEnabled(ctx context.Context) ([]RemoteApplicationsEnabledRow, error)

func (*Queries) SessionFreshSince

func (q *Queries) SessionFreshSince(ctx context.Context, arg SessionFreshSinceParams) (SessionFreshSinceRow, error)

func (*Queries) SessionIDByCurrentTokenHash

func (q *Queries) SessionIDByCurrentTokenHash(ctx context.Context, arg SessionIDByCurrentTokenHashParams) (string, error)

func (*Queries) SessionInsert

func (q *Queries) SessionInsert(ctx context.Context, arg SessionInsertParams) (SessionInsertRow, error)

Refresh-session queries (core/service_sessions.go).

func (*Queries) SessionMarkAuthenticated

func (q *Queries) SessionMarkAuthenticated(ctx context.Context, arg SessionMarkAuthenticatedParams) (int64, error)

Re-proving identity refreshes the freshness window and UNIONS the methods just used into whatever the session already proved — it never downgrades assurance. A password-only re-auth on an MFA session keeps its otp/mfa AMR, so a later RequireMFA gate still passes.

func (*Queries) SessionRevokeByID

func (q *Queries) SessionRevokeByID(ctx context.Context, arg SessionRevokeByIDParams) (string, error)

func (*Queries) SessionRevokeByIDForUser

func (q *Queries) SessionRevokeByIDForUser(ctx context.Context, arg SessionRevokeByIDForUserParams) (string, error)

func (*Queries) SessionRotate

func (q *Queries) SessionRotate(ctx context.Context, arg SessionRotateParams) error

func (*Queries) SessionsCountActive

func (q *Queries) SessionsCountActive(ctx context.Context, arg SessionsCountActiveParams) (int64, error)

func (*Queries) SessionsDeleteRevokedOrExpired

func (q *Queries) SessionsDeleteRevokedOrExpired(ctx context.Context) error

func (*Queries) SessionsEvictOldest

func (q *Queries) SessionsEvictOldest(ctx context.Context, arg SessionsEvictOldestParams) ([]string, error)

func (*Queries) SessionsListByUser

func (q *Queries) SessionsListByUser(ctx context.Context, arg SessionsListByUserParams) ([]SessionsListByUserRow, error)

func (*Queries) SessionsRevokeAll

func (q *Queries) SessionsRevokeAll(ctx context.Context, arg SessionsRevokeAllParams) ([]string, error)

func (*Queries) SessionsRevokeAllExcept

func (q *Queries) SessionsRevokeAllExcept(ctx context.Context, arg SessionsRevokeAllExceptParams) ([]string, error)

func (*Queries) SessionsRevokeAllQuiet

func (q *Queries) SessionsRevokeAllQuiet(ctx context.Context, arg SessionsRevokeAllQuietParams) error

SessionsRevokeAllQuiet is AdminDeleteUser's pre-delete sweep; unlike SessionsRevokeAll it returns nothing (no per-session revoke logging).

func (*Queries) SessionsRevokeFamily

func (q *Queries) SessionsRevokeFamily(ctx context.Context, familyID string) ([]SessionsRevokeFamilyRow, error)

func (*Queries) UserApplyEmailChange

func (q *Queries) UserApplyEmailChange(ctx context.Context, arg UserApplyEmailChangeParams) error

func (*Queries) UserApplyPhoneChange

func (q *Queries) UserApplyPhoneChange(ctx context.Context, arg UserApplyPhoneChangeParams) error

func (*Queries) UserBan

func (q *Queries) UserBan(ctx context.Context, arg UserBanParams) error

func (*Queries) UserByEmail

func (q *Queries) UserByEmail(ctx context.Context, email string) (UserByEmailRow, error)

func (*Queries) UserByID

func (q *Queries) UserByID(ctx context.Context, id string) (UserByIDRow, error)

func (*Queries) UserByPhone

func (q *Queries) UserByPhone(ctx context.Context, phoneNumber *string) (UserByPhoneRow, error)

func (*Queries) UserBySlug

func (q *Queries) UserBySlug(ctx context.Context, username *string) (UserBySlugRow, error)

func (*Queries) UserBySlugViaRename

func (q *Queries) UserBySlugViaRename(ctx context.Context, fromSlug string) (UserBySlugViaRenameRow, error)

Fallback to renames table (issue #58). Most-recent rename wins when a slug has been used by multiple users at different times (only possible after hard-delete + reuse).

func (*Queries) UserByUsername

func (q *Queries) UserByUsername(ctx context.Context, username *string) (UserByUsernameRow, error)

func (*Queries) UserClearBan

func (q *Queries) UserClearBan(ctx context.Context, id string) error

func (*Queries) UserClearLoginIdentifiers

func (q *Queries) UserClearLoginIdentifiers(ctx context.Context, id string) error

func (*Queries) UserDeleteHard

func (q *Queries) UserDeleteHard(ctx context.Context, id string) error

func (*Queries) UserEmailByID

func (q *Queries) UserEmailByID(ctx context.Context, id string) (*string, error)

User-row queries (core/service.go).

func (*Queries) UserEmailOrUsernameExists

func (q *Queries) UserEmailOrUsernameExists(ctx context.Context, arg UserEmailOrUsernameExistsParams) (bool, error)

func (*Queries) UserEmailOrUsernameTaken

func (*Queries) UserHasPassword

func (q *Queries) UserHasPassword(ctx context.Context, userID string) (bool, error)

func (*Queries) UserIDReservedByUsername

func (q *Queries) UserIDReservedByUsername(ctx context.Context, username *string) (UserIDReservedByUsernameRow, error)

func (*Queries) UserImportInsert

func (q *Queries) UserImportInsert(ctx context.Context, arg UserImportInsertParams) error

func (*Queries) UserImportUpdate

func (q *Queries) UserImportUpdate(ctx context.Context, arg UserImportUpdateParams) (string, error)

func (*Queries) UserInsert

func (q *Queries) UserInsert(ctx context.Context, arg UserInsertParams) (UserInsertRow, error)

func (*Queries) UserIsReserved

func (q *Queries) UserIsReserved(ctx context.Context, id string) (bool, error)

func (*Queries) UserLastRenamedAt

func (q *Queries) UserLastRenamedAt(ctx context.Context, userID string) (time.Time, error)

func (*Queries) UserMetadata

func (q *Queries) UserMetadata(ctx context.Context, id string) ([]byte, error)

func (*Queries) UserMetadataPatch

func (q *Queries) UserMetadataPatch(ctx context.Context, arg UserMetadataPatchParams) (int64, error)

func (*Queries) UserPasswordDelete

func (q *Queries) UserPasswordDelete(ctx context.Context, userID string) error

func (*Queries) UserPasswordInsert

func (q *Queries) UserPasswordInsert(ctx context.Context, arg UserPasswordInsertParams) error

func (*Queries) UserPasswordRow

func (q *Queries) UserPasswordRow(ctx context.Context, userID string) (UserPasswordRowRow, error)

func (*Queries) UserPasswordUpsert

func (q *Queries) UserPasswordUpsert(ctx context.Context, arg UserPasswordUpsertParams) error

func (*Queries) UserPhoneOrUsernameExists

func (q *Queries) UserPhoneOrUsernameExists(ctx context.Context, arg UserPhoneOrUsernameExistsParams) (bool, error)

func (*Queries) UserPhoneOrUsernameTaken

func (*Queries) UserPreferredLanguage added in v0.54.0

func (q *Queries) UserPreferredLanguage(ctx context.Context, id string) (string, error)

func (*Queries) UserProviderDeleteBySlug

func (q *Queries) UserProviderDeleteBySlug(ctx context.Context, arg UserProviderDeleteBySlugParams) error

func (*Queries) UserProviderDeleteOtherSubjects

func (q *Queries) UserProviderDeleteOtherSubjects(ctx context.Context, arg UserProviderDeleteOtherSubjectsParams) error

func (*Queries) UserProviderInsertSimple

func (q *Queries) UserProviderInsertSimple(ctx context.Context, arg UserProviderInsertSimpleParams) error

func (*Queries) UserProviderLinkExists

func (q *Queries) UserProviderLinkExists(ctx context.Context, arg UserProviderLinkExistsParams) (bool, error)

HTTP-layer provider lookups (http/step_up.go, http/user_me_get.go).

func (*Queries) UserProviderMergeProfile

func (q *Queries) UserProviderMergeProfile(ctx context.Context, arg UserProviderMergeProfileParams) error

func (*Queries) UserProviderSetUsername

func (q *Queries) UserProviderSetUsername(ctx context.Context, arg UserProviderSetUsernameParams) error

func (*Queries) UserProviderSlugs

func (q *Queries) UserProviderSlugs(ctx context.Context, userID string) ([]string, error)

func (*Queries) UserProviderSlugsDistinct

func (q *Queries) UserProviderSlugsDistinct(ctx context.Context, userID string) ([]string, error)

func (*Queries) UserProviderSubjectByIssuer

func (q *Queries) UserProviderSubjectByIssuer(ctx context.Context, arg UserProviderSubjectByIssuerParams) (string, error)

func (*Queries) UserProviderUpsertByIssuer

func (q *Queries) UserProviderUpsertByIssuer(ctx context.Context, arg UserProviderUpsertByIssuerParams) error

func (*Queries) UserProviderUsername

func (q *Queries) UserProviderUsername(ctx context.Context, arg UserProviderUsernameParams) (*string, error)

func (*Queries) UserProvidersCount

func (q *Queries) UserProvidersCount(ctx context.Context, userID string) (int64, error)

Provider-link queries (core/service.go).

func (*Queries) UserProvidersDeleteByUser

func (q *Queries) UserProvidersDeleteByUser(ctx context.Context, userID string) error

func (*Queries) UserRenameInsert

func (q *Queries) UserRenameInsert(ctx context.Context, arg UserRenameInsertParams) error

func (*Queries) UserRestore

func (q *Queries) UserRestore(ctx context.Context, id string) error

func (*Queries) UserSetBiography

func (q *Queries) UserSetBiography(ctx context.Context, arg UserSetBiographyParams) error

func (*Queries) UserSetEmailAndUnverify

func (q *Queries) UserSetEmailAndUnverify(ctx context.Context, arg UserSetEmailAndUnverifyParams) error

func (*Queries) UserSetEmailAndVerified added in v0.54.0

func (q *Queries) UserSetEmailAndVerified(ctx context.Context, arg UserSetEmailAndVerifiedParams) error

func (*Queries) UserSetEmailVerified

func (q *Queries) UserSetEmailVerified(ctx context.Context, arg UserSetEmailVerifiedParams) error

func (*Queries) UserSetLastLogin

func (q *Queries) UserSetLastLogin(ctx context.Context, arg UserSetLastLoginParams) error

func (*Queries) UserSetPhoneAndVerified

func (q *Queries) UserSetPhoneAndVerified(ctx context.Context, arg UserSetPhoneAndVerifiedParams) error

func (*Queries) UserSetPhoneVerifiedByID

func (q *Queries) UserSetPhoneVerifiedByID(ctx context.Context, arg UserSetPhoneVerifiedByIDParams) error

func (*Queries) UserSetPhoneVerifiedByIDAndPhone

func (q *Queries) UserSetPhoneVerifiedByIDAndPhone(ctx context.Context, arg UserSetPhoneVerifiedByIDAndPhoneParams) error

func (*Queries) UserSetPreferredLanguage added in v0.54.0

func (q *Queries) UserSetPreferredLanguage(ctx context.Context, arg UserSetPreferredLanguageParams) error

func (*Queries) UserSetReserved

func (q *Queries) UserSetReserved(ctx context.Context, arg UserSetReservedParams) error

Reserved-account + metadata queries (core/service_reserved_accounts.go).

func (*Queries) UserSetUsername

func (q *Queries) UserSetUsername(ctx context.Context, arg UserSetUsernameParams) error

func (*Queries) UserSlugAliases

func (q *Queries) UserSlugAliases(ctx context.Context, userID string) ([]string, error)

func (*Queries) UserSoftDelete

func (q *Queries) UserSoftDelete(ctx context.Context, id string) error

func (*Queries) UserUsernameByID

func (q *Queries) UserUsernameByID(ctx context.Context, id string) (string, error)

func (*Queries) UserUsernameExists

func (q *Queries) UserUsernameExists(ctx context.Context, username *string) (bool, error)

func (*Queries) UsersPurgeCandidates

func (q *Queries) UsersPurgeCandidates(ctx context.Context, arg UsersPurgeCandidatesParams) ([]string, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RemoteAppAttributeDefDeleteParams added in v0.27.0

type RemoteAppAttributeDefDeleteParams struct {
	RemoteApplicationID string
	Key                 string
}

type RemoteAppAttributeDefGetLatestParams added in v0.27.0

type RemoteAppAttributeDefGetLatestParams struct {
	RemoteApplicationID string
	Key                 string
}

type RemoteAppAttributeDefGetLatestRow added in v0.27.0

type RemoteAppAttributeDefGetLatestRow struct {
	RemoteApplicationID string
	Key                 string
	Version             int32
	Definition          []byte
	CreatedAt           time.Time
	UpdatedAt           time.Time
}

type RemoteAppAttributeDefGetParams added in v0.27.0

type RemoteAppAttributeDefGetParams struct {
	RemoteApplicationID string
	Key                 string
	Version             int32
}

type RemoteAppAttributeDefGetRow added in v0.27.0

type RemoteAppAttributeDefGetRow struct {
	RemoteApplicationID string
	Key                 string
	Version             int32
	Definition          []byte
	CreatedAt           time.Time
	UpdatedAt           time.Time
}

type RemoteAppAttributeDefUpsertParams added in v0.27.0

type RemoteAppAttributeDefUpsertParams struct {
	RemoteApplicationID string
	Key                 string
	Version             int32
	Definition          []byte
}

type RemoteAppAttributeDefUpsertRow added in v0.27.0

type RemoteAppAttributeDefUpsertRow struct {
	RemoteApplicationID string
	Key                 string
	Version             int32
	Definition          []byte
	CreatedAt           time.Time
	UpdatedAt           time.Time
}

type RemoteAppAttributeDefsListRow added in v0.27.0

type RemoteAppAttributeDefsListRow struct {
	RemoteApplicationID string
	Key                 string
	Version             int32
	Definition          []byte
	CreatedAt           time.Time
	UpdatedAt           time.Time
}

type RemoteApplicationByIssuerRow added in v0.27.0

type RemoteApplicationByIssuerRow struct {
	ID                string
	Slug              string
	PermissionGroupID string
	Issuer            string
	JwksUri           string
	Mode              string
	PublicKeys        []byte
	Audiences         []string
	AllowedOrigins    []string
	Enabled           bool
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

type RemoteApplicationBySlugRow added in v0.27.0

type RemoteApplicationBySlugRow struct {
	ID                string
	Slug              string
	PermissionGroupID string
	Issuer            string
	JwksUri           string
	Mode              string
	PublicKeys        []byte
	Audiences         []string
	AllowedOrigins    []string
	Enabled           bool
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

type RemoteApplicationUpsertParams added in v0.27.0

type RemoteApplicationUpsertParams struct {
	Slug              string
	PermissionGroupID *string
	Issuer            string
	JwksUri           string
	Mode              string
	PublicKeys        []byte
	Audiences         []string
	AllowedOrigins    []string
	Enabled           bool
}

type RemoteApplicationUpsertRow added in v0.27.0

type RemoteApplicationUpsertRow struct {
	ID                string
	Slug              string
	PermissionGroupID string
	Issuer            string
	JwksUri           string
	Mode              string
	PublicKeys        []byte
	Audiences         []string
	AllowedOrigins    []string
	Enabled           bool
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

type RemoteApplicationsAllRow added in v0.27.0

type RemoteApplicationsAllRow struct {
	ID                string
	Slug              string
	PermissionGroupID string
	Issuer            string
	JwksUri           string
	Mode              string
	PublicKeys        []byte
	Audiences         []string
	AllowedOrigins    []string
	Enabled           bool
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

type RemoteApplicationsEnabledRow added in v0.27.0

type RemoteApplicationsEnabledRow struct {
	ID                string
	Slug              string
	PermissionGroupID string
	Issuer            string
	JwksUri           string
	Mode              string
	PublicKeys        []byte
	Audiences         []string
	AllowedOrigins    []string
	Enabled           bool
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

type SessionByCurrentTokenHashParams

type SessionByCurrentTokenHashParams struct {
	CurrentTokenHash []byte
	Issuer           string
}

type SessionByCurrentTokenHashRow

type SessionByCurrentTokenHashRow struct {
	ID          string
	UserID      string
	FamilyID    string
	AuthMethods []string
}

type SessionByPreviousTokenHashParams

type SessionByPreviousTokenHashParams struct {
	PreviousTokenHash []byte
	Issuer            string
}

type SessionByPreviousTokenHashRow

type SessionByPreviousTokenHashRow struct {
	ID       string
	UserID   string
	FamilyID string
}

type SessionFreshSinceParams

type SessionFreshSinceParams struct {
	SessionID string
	UserID    string
	Issuer    string
}

type SessionFreshSinceRow added in v0.52.0

type SessionFreshSinceRow struct {
	FreshSince  time.Time
	AuthMethods []string
}

type SessionIDByCurrentTokenHashParams

type SessionIDByCurrentTokenHashParams struct {
	CurrentTokenHash []byte
	Issuer           string
}

type SessionInsertParams

type SessionInsertParams struct {
	ID               string
	FamilyID         string
	UserID           string
	Issuer           string
	CurrentTokenHash []byte
	ExpiresAt        *time.Time
	UserAgent        *string
	IpAddr           *string
	AuthMethods      []string
}

type SessionInsertRow

type SessionInsertRow struct {
	ID       string
	FamilyID string
}

type SessionMarkAuthenticatedParams

type SessionMarkAuthenticatedParams struct {
	AuthMethods []string
	SessionID   string
	UserID      string
	Issuer      string
}

type SessionRevokeByIDForUserParams

type SessionRevokeByIDForUserParams struct {
	ID     string
	UserID string
	Issuer string
}

type SessionRevokeByIDParams

type SessionRevokeByIDParams struct {
	ID     string
	Issuer string
}

type SessionRotateParams

type SessionRotateParams struct {
	CurrentTokenHash []byte
	UserAgent        *string
	IpAddr           *string
	ID               string
}

type SessionsCountActiveParams

type SessionsCountActiveParams struct {
	UserID string
	Issuer string
}

type SessionsEvictOldestParams

type SessionsEvictOldestParams struct {
	UserID     string
	Issuer     string
	EvictCount int64
}

type SessionsListByUserParams

type SessionsListByUserParams struct {
	UserID string
	Issuer string
}

type SessionsListByUserRow

type SessionsListByUserRow struct {
	ID                  string
	FamilyID            string
	CreatedAt           time.Time
	LastAuthenticatedAt *time.Time
	LastUsedAt          time.Time
	ExpiresAt           *time.Time
	RevokedAt           *time.Time
	UserAgent           *string
	IpAddr              *string
}

type SessionsRevokeAllExceptParams

type SessionsRevokeAllExceptParams struct {
	UserID string
	Issuer string
	ID     string
}

type SessionsRevokeAllParams

type SessionsRevokeAllParams struct {
	UserID string
	Issuer string
}

type SessionsRevokeAllQuietParams

type SessionsRevokeAllQuietParams struct {
	UserID string
	Issuer string
}

type SessionsRevokeFamilyRow

type SessionsRevokeFamilyRow struct {
	ID     string
	UserID string
}

type UserApplyEmailChangeParams

type UserApplyEmailChangeParams struct {
	ID    string
	Email string
}

type UserApplyPhoneChangeParams

type UserApplyPhoneChangeParams struct {
	ID          string
	PhoneNumber *string
}

type UserBanParams

type UserBanParams struct {
	BannedAt    *time.Time
	BannedUntil *time.Time
	BanReason   *string
	BannedBy    *string
	ID          string
}

type UserByEmailRow

type UserByEmailRow struct {
	ID            string
	Email         *string
	PhoneNumber   *string
	Username      *string
	EmailVerified bool
	PhoneVerified bool
	BannedAt      *time.Time
	BannedUntil   *time.Time
	BanReason     *string
	BannedBy      *string
	DeletedAt     *time.Time
	Biography     *string
	CreatedAt     time.Time
	UpdatedAt     time.Time
	LastLogin     *time.Time
}

type UserByIDRow

type UserByIDRow struct {
	ID            string
	Email         *string
	PhoneNumber   *string
	Username      *string
	EmailVerified bool
	PhoneVerified bool
	BannedAt      *time.Time
	BannedUntil   *time.Time
	BanReason     *string
	BannedBy      *string
	DeletedAt     *time.Time
	Biography     *string
	CreatedAt     time.Time
	UpdatedAt     time.Time
	LastLogin     *time.Time
}

type UserByPhoneRow

type UserByPhoneRow struct {
	ID            string
	Email         *string
	PhoneNumber   *string
	Username      *string
	EmailVerified bool
	PhoneVerified bool
	BannedAt      *time.Time
	BannedUntil   *time.Time
	BanReason     *string
	BannedBy      *string
	DeletedAt     *time.Time
	Biography     *string
	CreatedAt     time.Time
	UpdatedAt     time.Time
	LastLogin     *time.Time
}

type UserBySlugRow

type UserBySlugRow struct {
	ID       string
	Username string
}

type UserBySlugViaRenameRow

type UserBySlugViaRenameRow struct {
	ID       string
	Username string
}

type UserByUsernameRow

type UserByUsernameRow struct {
	ID            string
	Email         *string
	PhoneNumber   *string
	Username      *string
	EmailVerified bool
	PhoneVerified bool
	BannedAt      *time.Time
	BannedUntil   *time.Time
	BanReason     *string
	BannedBy      *string
	DeletedAt     *time.Time
	Biography     *string
	CreatedAt     time.Time
	UpdatedAt     time.Time
	LastLogin     *time.Time
}

type UserEmailOrUsernameExistsParams

type UserEmailOrUsernameExistsParams struct {
	Email    string
	Username string
}

type UserEmailOrUsernameTakenParams

type UserEmailOrUsernameTakenParams struct {
	Email    string
	Username string
}

type UserEmailOrUsernameTakenRow

type UserEmailOrUsernameTakenRow struct {
	EmailTaken    bool
	UsernameTaken bool
}

type UserIDReservedByUsernameRow

type UserIDReservedByUsernameRow struct {
	ID       string
	Reserved bool
}

type UserImportInsertParams

type UserImportInsertParams struct {
	ID            string
	Email         *string
	PhoneNumber   *string
	Username      *string
	EmailVerified bool
	PhoneVerified bool
	BannedAt      *time.Time
	BannedUntil   *time.Time
	BanReason     *string
	BannedBy      *string
	Metadata      []byte
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

type UserImportUpdateParams

type UserImportUpdateParams struct {
	Email         *string
	PhoneNumber   *string
	Username      *string
	EmailVerified bool
	PhoneVerified bool
	BannedAt      *time.Time
	BannedUntil   *time.Time
	BanReason     *string
	BannedBy      *string
	Metadata      []byte
	CreatedAt     time.Time
	UpdatedAt     time.Time
	ID            string
}

type UserInsertParams

type UserInsertParams struct {
	ID       string
	Email    string
	Username *string
}

type UserInsertRow

type UserInsertRow struct {
	ID            string
	Email         *string
	Username      *string
	EmailVerified bool
	BannedAt      *time.Time
	DeletedAt     *time.Time
}

type UserMetadataPatchParams

type UserMetadataPatchParams struct {
	Patch []byte
	ID    string
}

type UserPasswordInsertParams

type UserPasswordInsertParams struct {
	UserID       string
	PasswordHash string
}

type UserPasswordRowRow

type UserPasswordRowRow struct {
	PasswordHash string
	HashAlgo     string
	HashParams   []byte
}

type UserPasswordUpsertParams

type UserPasswordUpsertParams struct {
	UserID       string
	PasswordHash string
	HashAlgo     string
	HashParams   []byte
}

type UserPhoneOrUsernameExistsParams

type UserPhoneOrUsernameExistsParams struct {
	Phone    string
	Username string
}

type UserPhoneOrUsernameTakenParams

type UserPhoneOrUsernameTakenParams struct {
	Phone    string
	Username string
}

type UserPhoneOrUsernameTakenRow

type UserPhoneOrUsernameTakenRow struct {
	PhoneTaken    bool
	UsernameTaken bool
}

type UserProviderDeleteBySlugParams

type UserProviderDeleteBySlugParams struct {
	UserID       string
	ProviderSlug *string
}

type UserProviderDeleteOtherSubjectsParams

type UserProviderDeleteOtherSubjectsParams struct {
	UserID  string
	Issuer  string
	Subject string
}

type UserProviderInsertSimpleParams

type UserProviderInsertSimpleParams struct {
	ID              string
	UserID          string
	Issuer          string
	Subject         string
	EmailAtProvider *string
}

type UserProviderLinkExistsParams

type UserProviderLinkExistsParams struct {
	UserID       string
	Issuer       string
	ProviderSlug *string
}

type UserProviderMergeProfileParams

type UserProviderMergeProfileParams struct {
	UserID  string
	Issuer  string
	Subject string
	Patch   []byte
}

type UserProviderSetUsernameParams

type UserProviderSetUsernameParams struct {
	UserID   string
	Issuer   string
	Subject  string
	Username string
}

type UserProviderSubjectByIssuerParams

type UserProviderSubjectByIssuerParams struct {
	UserID string
	Issuer string
}

type UserProviderSubjectProfileByIssuerParams

type UserProviderSubjectProfileByIssuerParams struct {
	UserID string
	Issuer string
}

type UserProviderSubjectProfileByIssuerRow

type UserProviderSubjectProfileByIssuerRow struct {
	Subject   string
	CreatedAt time.Time
	Profile   string
}

type UserProviderUpsertByIssuerParams

type UserProviderUpsertByIssuerParams struct {
	ID              string
	UserID          string
	Issuer          string
	ProviderSlug    *string
	Subject         string
	EmailAtProvider *string
}

type UserProviderUsernameParams

type UserProviderUsernameParams struct {
	UserID       string
	ProviderSlug *string
}

type UserRenameInsertParams

type UserRenameInsertParams struct {
	UserID   string
	FromSlug string
}

type UserSetBiographyParams

type UserSetBiographyParams struct {
	ID        string
	Biography *string
}

type UserSetEmailAndUnverifyParams

type UserSetEmailAndUnverifyParams struct {
	ID    string
	Email string
}

type UserSetEmailAndVerifiedParams added in v0.54.0

type UserSetEmailAndVerifiedParams struct {
	ID    string
	Email string
}

type UserSetEmailVerifiedParams

type UserSetEmailVerifiedParams struct {
	ID            string
	EmailVerified bool
}

type UserSetLastLoginParams

type UserSetLastLoginParams struct {
	ID        string
	LastLogin *time.Time
}

type UserSetPhoneAndVerifiedParams

type UserSetPhoneAndVerifiedParams struct {
	ID            string
	PhoneNumber   *string
	PhoneVerified bool
}

type UserSetPhoneVerifiedByIDAndPhoneParams

type UserSetPhoneVerifiedByIDAndPhoneParams struct {
	ID          string
	PhoneNumber *string
}

type UserSetPhoneVerifiedByIDParams

type UserSetPhoneVerifiedByIDParams struct {
	ID            string
	PhoneVerified bool
}

type UserSetPreferredLanguageParams added in v0.54.0

type UserSetPreferredLanguageParams struct {
	ID                string
	PreferredLanguage *string
}

type UserSetReservedParams

type UserSetReservedParams struct {
	Reserved bool
	ID       string
}

type UserSetUsernameParams

type UserSetUsernameParams struct {
	ID       string
	Username *string
}

type UsersPurgeCandidatesParams

type UsersPurgeCandidatesParams struct {
	Cutoff  *time.Time
	MaxRows int64
}

Jump to

Keyboard shortcuts

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