Documentation
¶
Overview ¶
Package postgres provides a production-grade implementation of theauth.Storage backed by PostgreSQL through pgx and sqlc-generated query bindings.
Migrations live under migrations/ and are append-only: a renamed column ships as a new migration. Use the in-package New constructor with a pgxpool.Pool. See https://docs.theauth.dev/go/reference/stability for the rules that govern future schema and query changes.
Package postgres: migrate.go applies the embedded SQL migrations at boot, before theauth.New. Migrate is safe across replicas (transaction-scoped advisory lock) and reruns are no-ops.
Package postgres provides a Postgres-backed storage.Storage implementation built on top of sqlc-generated queries and pgx/v5.
Index ¶
- func Migrate(ctx context.Context, pool *pgxpool.Pool) error
- type MigrationStatus
- type Store
- func (s *Store) APITokenByHash(ctx context.Context, hash []byte) (*theauth.APIToken, error)
- func (s *Store) APITokenByID(ctx context.Context, id theauth.ULID) (*theauth.APIToken, error)
- func (s *Store) APITokensByAgentID(ctx context.Context, agentID theauth.ULID) ([]theauth.APIToken, error)
- func (s *Store) APITokensByOwner(ctx context.Context, ownerID theauth.ULID) ([]theauth.APIToken, error)
- func (s *Store) AccountStateByUserID(ctx context.Context, userID theauth.ULID) (theauth.AccountState, error)
- func (s *Store) AddGroupMembers(ctx context.Context, groupID theauth.ULID, userIDs []theauth.ULID) error
- func (s *Store) AdvanceTOTPStep(ctx context.Context, userID theauth.ULID, step int64) (bool, error)
- func (s *Store) AgentByClientID(ctx context.Context, clientID string) (*theauth.Agent, error)
- func (s *Store) AgentByID(ctx context.Context, id theauth.ULID) (*theauth.Agent, error)
- func (s *Store) AgentCredentialsByAgentID(ctx context.Context, agentID theauth.ULID) ([]theauth.AgentCredential, error)
- func (s *Store) AgentsByOwner(ctx context.Context, owner theauth.AgentOwner) ([]theauth.Agent, error)
- func (s *Store) AppendSessionAuthMethods(ctx context.Context, id theauth.ULID, methods []string, at time.Time) ([]string, time.Time, error)
- func (s *Store) ApproveToolApproval(ctx context.Context, id, approver string, now time.Time) (bool, error)
- func (s *Store) AtomicRotateJWKS(ctx context.Context, retireKIDs []string, demoteKID, promoteKID string, ...) error
- func (s *Store) AuditOrderSupported() bool
- func (s *Store) BackchannelRequestByID(ctx context.Context, authReqID string) (theauth.BackchannelRequest, error)
- func (s *Store) ChainSupported() bool
- func (s *Store) ClaimDeviceCode(ctx context.Context, hash []byte, now time.Time) (*theauth.DeviceCode, error)
- func (s *Store) ConfirmTOTPSecret(ctx context.Context, userID theauth.ULID, at time.Time) error
- func (s *Store) ConsumeAuthorizationCode(ctx context.Context, code string) (*theauth.AuthorizationCode, error)
- func (s *Store) ConsumeDeviceAuthorization(ctx context.Context, id theauth.ULID, now time.Time) (bool, 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) ConsumePushedRequest(ctx context.Context, requestURI string) ([]byte, error)
- func (s *Store) ConsumeRecoveryCode(ctx context.Context, userID theauth.ULID, code string, at time.Time) error
- func (s *Store) ConsumeSessionLink(ctx context.Context, tokenHash []byte, now time.Time) (*theauth.SessionLink, error)
- func (s *Store) ConsumeToolApproval(ctx context.Context, id, agentID, action, resource string, now time.Time) (bool, error)
- func (s *Store) CountUnusedRecoveryCodes(ctx context.Context, userID theauth.ULID) (int, error)
- func (s *Store) CountUsers(ctx context.Context) (int, error)
- func (s *Store) CountUsersWithPermissionInOrg(ctx context.Context, orgID theauth.ULID, perm string) (int, 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) CreateSessionLink(ctx context.Context, l theauth.SessionLink) 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) DecideDeviceAuthorization(ctx context.Context, id theauth.ULID, status string, userID theauth.ULID, ...) (bool, error)
- func (s *Store) DecideDeviceCode(ctx context.Context, userCode string, d theauth.DeviceDecision, now time.Time) error
- func (s *Store) DelegationGrantByID(ctx context.Context, id theauth.ULID) (*theauth.DelegationGrant, error)
- func (s *Store) DelegationGrantByUserAgentResource(ctx context.Context, userID, agentID theauth.ULID, resource string) (*theauth.DelegationGrant, error)
- func (s *Store) DelegationGrantsByAgentID(ctx context.Context, agentID theauth.ULID) ([]theauth.DelegationGrant, error)
- func (s *Store) DelegationGrantsByUserID(ctx context.Context, userID theauth.ULID) ([]theauth.DelegationGrant, error)
- func (s *Store) DeleteBackchannelRequest(ctx context.Context, authReqID string) error
- func (s *Store) DeleteExpiredDeviceAuthorizations(ctx context.Context, before time.Time) (int64, error)
- func (s *Store) DeleteExpiredDeviceCodes(ctx context.Context, before time.Time) (int, error)
- func (s *Store) DeleteGroup(ctx context.Context, id theauth.ULID) error
- func (s *Store) DeleteOAuthAccountByProvider(ctx context.Context, userID theauth.ULID, provider string) error
- func (s *Store) DeleteOAuthClient(ctx context.Context, clientID string) error
- func (s *Store) DeleteOrganization(ctx context.Context, id theauth.ULID) error
- func (s *Store) DeleteOrganizationMember(ctx context.Context, orgID, userID theauth.ULID) error
- func (s *Store) DeleteRole(ctx context.Context, id theauth.ULID) error
- func (s *Store) DeleteSAMLConnection(ctx context.Context, id theauth.ULID) error
- func (s *Store) DeleteTOTPSecret(ctx context.Context, userID theauth.ULID) error
- func (s *Store) DeleteUserCascade(ctx context.Context, userID theauth.ULID) error
- func (s *Store) DeleteWebAuthnCredential(ctx context.Context, id theauth.ULID, userID theauth.ULID) error
- func (s *Store) DenyAccessToken(ctx context.Context, jti string, expiresAt time.Time) error
- func (s *Store) DeviceAuthorizationByDeviceCodeHash(ctx context.Context, hash []byte) (*theauth.DeviceAuthorization, error)
- func (s *Store) DeviceAuthorizationByUserCodeHash(ctx context.Context, hash []byte) (*theauth.DeviceAuthorization, error)
- func (s *Store) DeviceByID(ctx context.Context, id theauth.ULID) (*theauth.Device, error)
- func (s *Store) DeviceCodeByHash(ctx context.Context, hash []byte) (*theauth.DeviceCode, error)
- func (s *Store) DeviceCodeByUserCode(ctx context.Context, userCode string) (*theauth.DeviceCode, error)
- func (s *Store) DeviceJoinTokenByHash(ctx context.Context, hash []byte) (*theauth.DeviceJoinToken, error)
- func (s *Store) DeviceJoinTokenByID(ctx context.Context, id theauth.ULID) (*theauth.DeviceJoinToken, error)
- func (s *Store) GrantUserRole(ctx context.Context, ur theauth.UserRole) error
- func (s *Store) GroupByExternalIDInOrg(ctx context.Context, orgID theauth.ULID, externalID string) (*theauth.Group, error)
- func (s *Store) GroupByID(ctx context.Context, id theauth.ULID) (*theauth.Group, error)
- func (s *Store) GroupMembers(ctx context.Context, groupID theauth.ULID) ([]theauth.ULID, error)
- func (s *Store) InsertAPIToken(ctx context.Context, t theauth.APIToken) (theauth.APIToken, error)
- func (s *Store) InsertAgent(ctx context.Context, a theauth.Agent) (theauth.Agent, error)
- func (s *Store) InsertAgentCredential(ctx context.Context, c theauth.AgentCredential) error
- func (s *Store) InsertAuditEvents(ctx context.Context, events []theauth.AuditEvent) error
- func (s *Store) InsertAuthorizationCode(ctx context.Context, c theauth.AuthorizationCode) error
- func (s *Store) InsertBackchannelRequest(ctx context.Context, req theauth.BackchannelRequest) error
- func (s *Store) InsertDelegationGrant(ctx context.Context, g theauth.DelegationGrant) (theauth.DelegationGrant, error)
- func (s *Store) InsertDevice(ctx context.Context, d theauth.Device) error
- func (s *Store) InsertDeviceAuthorization(ctx context.Context, d theauth.DeviceAuthorization) error
- func (s *Store) InsertDeviceCode(ctx context.Context, d theauth.DeviceCode) error
- func (s *Store) InsertDeviceJoinToken(ctx context.Context, t theauth.DeviceJoinToken) error
- func (s *Store) InsertGroup(ctx context.Context, g theauth.Group) (theauth.Group, error)
- func (s *Store) InsertJWKSKey(ctx context.Context, k theauth.JWKSKey) error
- func (s *Store) InsertOAuthClient(ctx context.Context, c theauth.OAuthClient) (theauth.OAuthClient, error)
- func (s *Store) InsertOpaqueAccessToken(ctx context.Context, t theauth.OpaqueAccessToken) error
- func (s *Store) InsertOrganization(ctx context.Context, o theauth.Organization) (theauth.Organization, error)
- func (s *Store) InsertPermission(ctx context.Context, p theauth.Permission) (theauth.Permission, error)
- func (s *Store) InsertPushedRequest(ctx context.Context, requestURI string, payload []byte, expiresAt time.Time) error
- func (s *Store) InsertRecoveryCodes(ctx context.Context, codes []theauth.RecoveryCode) error
- func (s *Store) InsertRefreshToken(ctx context.Context, t theauth.RefreshToken) error
- func (s *Store) InsertRegistrationToken(ctx context.Context, t theauth.RegistrationToken) error
- func (s *Store) InsertRole(ctx context.Context, r theauth.Role) (theauth.Role, error)
- func (s *Store) InsertSAMLConnection(ctx context.Context, c theauth.SAMLConnection) (theauth.SAMLConnection, error)
- func (s *Store) InsertSCIMToken(ctx context.Context, t theauth.SCIMToken) (theauth.SCIMToken, error)
- func (s *Store) InsertTrustedDevice(ctx context.Context, d theauth.TrustedDevice) error
- func (s *Store) InsertWebAuthnCredential(ctx context.Context, c theauth.WebAuthnCredential) (theauth.WebAuthnCredential, error)
- func (s *Store) IsAccessTokenDenied(ctx context.Context, jti string) (bool, error)
- func (s *Store) JWKSKeyByKID(ctx context.Context, kid string) (*theauth.JWKSKey, error)
- func (s *Store) JWKSKeysAll(ctx context.Context) ([]theauth.JWKSKey, error)
- func (s *Store) ListAPITokens(ctx context.Context) ([]theauth.APIToken, error)
- func (s *Store) ListDevices(ctx context.Context, orgID *theauth.ULID) ([]theauth.Device, error)
- func (s *Store) ListGroupsByOrganization(ctx context.Context, orgID theauth.ULID, offset, limit int, ...) ([]theauth.Group, int, error)
- func (s *Store) ListPendingDeviceCodes(ctx context.Context, f theauth.DevicePendingFilter) ([]theauth.DeviceCode, error)
- func (s *Store) ListPermissions(ctx context.Context) ([]theauth.Permission, error)
- func (s *Store) ListRegistrationTokens(ctx context.Context, orgID *theauth.ULID) ([]theauth.RegistrationToken, error)
- func (s *Store) ListTrustedDevices(ctx context.Context, userID theauth.ULID) ([]theauth.TrustedDevice, error)
- func (s *Store) ListUserSessions(ctx context.Context, userID theauth.ULID) ([]theauth.Session, error)
- func (s *Store) ListUsersByOrganization(ctx context.Context, orgID theauth.ULID, offset, limit int, ...) ([]theauth.User, int, error)
- func (s *Store) MarkEmailVerified(ctx context.Context, userID theauth.ULID) error
- func (s *Store) MoveOAuthAccount(ctx context.Context, provider, providerUserID string, newUserID theauth.ULID) error
- func (s *Store) MovePasswordHash(ctx context.Context, primaryID, secondaryID theauth.ULID) error
- func (s *Store) MoveTOTPSecret(ctx context.Context, primaryID, secondaryID theauth.ULID) error
- func (s *Store) MoveWebAuthnCredentials(ctx context.Context, primaryID, secondaryID theauth.ULID) error
- func (s *Store) OAuthAccountByProviderUserID(ctx context.Context, provider, providerUserID string) (*theauth.OAuthAccount, error)
- func (s *Store) OAuthAccountsByUserID(ctx context.Context, userID theauth.ULID) ([]theauth.OAuthAccount, error)
- func (s *Store) OAuthClientByClientID(ctx context.Context, clientID string) (*theauth.OAuthClient, error)
- func (s *Store) OpaqueAccessTokenByHash(ctx context.Context, hash []byte) (*theauth.OpaqueAccessToken, error)
- func (s *Store) OpenToolApproval(ctx context.Context, a theauth.ToolApproval) error
- func (s *Store) OrganizationByID(ctx context.Context, id theauth.ULID) (*theauth.Organization, error)
- func (s *Store) OrganizationBySlug(ctx context.Context, slug string) (*theauth.Organization, error)
- func (s *Store) OrganizationMemberRole(ctx context.Context, orgID, userID theauth.ULID) (string, error)
- func (s *Store) OrganizationMembersByOrg(ctx context.Context, orgID theauth.ULID) ([]theauth.OrganizationMember, error)
- func (s *Store) OrganizationsByUser(ctx context.Context, userID theauth.ULID) ([]theauth.Organization, error)
- func (s *Store) PermissionByName(ctx context.Context, name string) (*theauth.Permission, error)
- func (s *Store) PermissionsByRole(ctx context.Context, roleID theauth.ULID) ([]string, error)
- func (s *Store) PermissionsForUser(ctx context.Context, userID theauth.ULID, orgID *theauth.ULID) ([]string, error)
- func (s *Store) QueryAuditEvents(ctx context.Context, q theauth.AuditQuery) ([]theauth.AuditEvent, string, error)
- func (s *Store) RecordDeviceAuthorizationPoll(ctx context.Context, id theauth.ULID, polledAt time.Time, intervalSeconds int) error
- func (s *Store) RecordDevicePoll(ctx context.Context, hash []byte, at time.Time, intervalSeconds int) error
- func (s *Store) RedeemBackchannelRequest(ctx context.Context, authReqID string, now time.Time) (theauth.BackchannelRequest, bool, error)
- func (s *Store) RedeemDeviceJoinToken(ctx context.Context, id, deviceID theauth.ULID, now time.Time) (bool, error)
- func (s *Store) RedeemRegistrationToken(ctx context.Context, id theauth.ULID, now time.Time) (bool, error)
- func (s *Store) RefreshTokenByHash(ctx context.Context, hash []byte) (*theauth.RefreshToken, error)
- func (s *Store) RefundDeviceJoinToken(ctx context.Context, id theauth.ULID) error
- func (s *Store) RefundRegistrationToken(ctx context.Context, id theauth.ULID) error
- func (s *Store) RegistrationTokenByHash(ctx context.Context, hash []byte) (*theauth.RegistrationToken, error)
- func (s *Store) RegistrationTokenByID(ctx context.Context, id theauth.ULID) (*theauth.RegistrationToken, error)
- func (s *Store) RemoveGroupMembers(ctx context.Context, groupID theauth.ULID, userIDs []theauth.ULID) error
- func (s *Store) RenameWebAuthnCredential(ctx context.Context, id, userID theauth.ULID, name string) error
- func (s *Store) ReplaceRecoveryCodes(ctx context.Context, userID theauth.ULID, codes []theauth.RecoveryCode) error
- func (s *Store) RevokeAPIToken(ctx context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) RevokeAPITokensByOwner(ctx context.Context, ownerID theauth.ULID, at time.Time) (int, error)
- func (s *Store) RevokeAgentCredential(ctx context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) RevokeDelegationGrant(ctx context.Context, id theauth.ULID, at time.Time, reason string) error
- func (s *Store) RevokeDevice(ctx context.Context, id theauth.ULID, at time.Time) (bool, error)
- func (s *Store) RevokeDeviceJoinToken(ctx context.Context, id theauth.ULID, at time.Time) (bool, error)
- func (s *Store) RevokeOpaqueAccessToken(ctx context.Context, hash []byte) error
- func (s *Store) RevokeOtherUserSessions(ctx context.Context, userID, keep theauth.ULID) (int, error)
- func (s *Store) RevokeRefreshToken(ctx context.Context, hash []byte, reason string) error
- func (s *Store) RevokeRefreshTokenFamily(ctx context.Context, familyID theauth.ULID, reason string) error
- func (s *Store) RevokeRefreshTokensByAuthCode(ctx context.Context, codeHash, reason string) ([]string, error)
- func (s *Store) RevokeRegistrationToken(ctx context.Context, id theauth.ULID, at time.Time) (bool, error)
- func (s *Store) RevokeSCIMTokenByID(ctx context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) RevokeSession(ctx context.Context, id theauth.ULID) error
- func (s *Store) RevokeSessionsByCredential(ctx context.Context, credentialID string) (int, error)
- func (s *Store) RevokeTrustedDevice(ctx context.Context, userID, id theauth.ULID) error
- func (s *Store) RevokeUserRole(ctx context.Context, userID, roleID theauth.ULID) error
- func (s *Store) RevokeUserSessions(ctx context.Context, userID theauth.ULID) error
- func (s *Store) RevokeUserTrustedDevices(ctx context.Context, userID theauth.ULID) (int, error)
- func (s *Store) RoleByID(ctx context.Context, id theauth.ULID) (*theauth.Role, error)
- func (s *Store) RoleByOrgAndName(ctx context.Context, orgID *theauth.ULID, name string) (*theauth.Role, error)
- func (s *Store) RolesByOrganization(ctx context.Context, orgID *theauth.ULID) ([]theauth.Role, error)
- func (s *Store) RolesForUser(ctx context.Context, userID theauth.ULID, orgID *theauth.ULID) ([]theauth.Role, error)
- func (s *Store) SAMLConnectionByID(ctx context.Context, id theauth.ULID) (*theauth.SAMLConnection, error)
- func (s *Store) SAMLConnectionsByOrg(ctx context.Context, orgID theauth.ULID) ([]theauth.SAMLConnection, error)
- func (s *Store) SAMLIdentityByConnectionAndNameID(ctx context.Context, connectionID theauth.ULID, nameID string) (*theauth.SAMLIdentity, error)
- func (s *Store) SCIMTokenByHash(ctx context.Context, hash []byte) (*theauth.SCIMToken, error)
- func (s *Store) SCIMTokensByOrg(ctx context.Context, orgID theauth.ULID) ([]theauth.SCIMToken, error)
- func (s *Store) SessionAndUserByTokenHash(ctx context.Context, hash []byte) (*theauth.Session, *theauth.User, error)
- func (s *Store) SessionByID(ctx context.Context, id theauth.ULID) (*theauth.Session, error)
- func (s *Store) SessionByTokenHash(ctx context.Context, hash []byte) (*theauth.Session, error)
- func (s *Store) SetGroupMembers(ctx context.Context, groupID theauth.ULID, userIDs []theauth.ULID) error
- func (s *Store) SetMustChangePassword(ctx context.Context, userID theauth.ULID, required bool) error
- func (s *Store) SetRolePermissions(ctx context.Context, roleID theauth.ULID, permissionIDs []theauth.ULID) error
- func (s *Store) SetSessionActiveOrganization(ctx context.Context, sessionID theauth.ULID, orgID *theauth.ULID) error
- func (s *Store) SetSessionElevatedUntil(ctx context.Context, id theauth.ULID, until *time.Time) error
- func (s *Store) SetUserDisabledAt(ctx context.Context, userID theauth.ULID, at *time.Time) error
- func (s *Store) SetUserPassword(ctx context.Context, userID theauth.ULID, passwordHash string) error
- func (s *Store) SignalsStore() signals.Store
- func (s *Store) TOTPSecretByUserID(ctx context.Context, userID theauth.ULID) (*theauth.TOTPSecret, error)
- func (s *Store) ThrottleStore() *ThrottleStore
- func (s *Store) TouchAPITokenLastUsed(ctx context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) TouchBackchannelPoll(ctx context.Context, authReqID string, now time.Time, newInterval int) (theauth.BackchannelRequest, error)
- func (s *Store) TouchDevice(ctx context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) TouchSAMLIdentityLastLogin(ctx context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) TouchSCIMTokenLastUsed(ctx context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) TouchSession(ctx context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) TouchTrustedDevice(ctx context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) TrustedDeviceByTokenHash(ctx context.Context, userID theauth.ULID, hash []byte) (*theauth.TrustedDevice, error)
- func (s *Store) UpdateAgentCredentialLastUsed(ctx context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) UpdateAgentExpiry(ctx context.Context, id theauth.ULID, expiresAt *time.Time) error
- func (s *Store) UpdateAgentLastActive(ctx context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) UpdateAgentStatus(ctx context.Context, id theauth.ULID, status string, _ time.Time) error
- func (s *Store) UpdateBackchannelRequest(ctx context.Context, req theauth.BackchannelRequest) error
- func (s *Store) UpdateGroup(ctx context.Context, g theauth.Group) error
- func (s *Store) UpdateJWKSKeyState(ctx context.Context, kid, state string, at time.Time) error
- func (s *Store) UpdateOAuthClient(ctx context.Context, c theauth.OAuthClient) (theauth.OAuthClient, error)
- func (s *Store) UpdateOrganization(ctx context.Context, o theauth.Organization) error
- func (s *Store) UpdateRoleRow(ctx context.Context, r theauth.Role) (theauth.Role, error)
- func (s *Store) UpdateSAMLConnectionRow(ctx context.Context, c theauth.SAMLConnection) error
- func (s *Store) UpdateSessionAuthLevel(ctx context.Context, id theauth.ULID, level string) error
- func (s *Store) UpdateUserSCIM(ctx context.Context, u theauth.User) error
- func (s *Store) UpdateWebAuthnBackupFlags(ctx context.Context, credentialID []byte, backupEligible, backupState bool) 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) UpsertOrganizationMember(ctx context.Context, m theauth.OrganizationMember) error
- func (s *Store) UpsertPendingTOTPSecret(ctx context.Context, sec theauth.TOTPSecret) error
- func (s *Store) UpsertSAMLIdentity(ctx context.Context, i theauth.SAMLIdentity) (theauth.SAMLIdentity, 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) UserByExternalIDInOrg(ctx context.Context, orgID theauth.ULID, externalID string) (*theauth.User, error)
- func (s *Store) UserByID(ctx context.Context, id theauth.ULID) (*theauth.User, error)
- func (s *Store) UserPasswordHashByID(ctx context.Context, userID theauth.ULID) (string, error)
- func (s *Store) VerifyAuditChain(ctx context.Context) (theauth.AuditChainResult, 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)
- type ThrottleStore
- func (t *ThrottleStore) CompareAndSwap(ctx context.Context, key string, prev theauth.LoginThrottleEntry, ...) (bool, error)
- func (t *ThrottleStore) Delete(ctx context.Context, key string) error
- func (t *ThrottleStore) DeleteLoginEntries(ctx context.Context, ident string) error
- func (t *ThrottleStore) Get(ctx context.Context, key string) (theauth.LoginThrottleEntry, bool, error)
- func (t *ThrottleStore) Set(ctx context.Context, key string, e theauth.LoginThrottleEntry) error
- func (t *ThrottleStore) SweepExpired(ctx context.Context, now time.Time) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MigrationStatus ¶ added in v2.12.0
type MigrationStatus struct {
// Version is the migration id, for example "0001_init".
Version string
// Applied reports whether the version is recorded in theauth_schema_migrations.
Applied bool
// AppliedAt is the ledger timestamp; zero when not applied.
AppliedAt time.Time
// SQL is the embedded up migration body.
SQL string
}
MigrationStatus describes one embedded migration and whether the ledger has it.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the Postgres-backed storage adapter.
func (*Store) APITokenByHash ¶
APITokenByHash returns the token with the given secret hash, else ErrNotFound.
func (*Store) APITokenByID ¶
APITokenByID returns the token with the given ID, else ErrNotFound.
func (*Store) APITokensByAgentID ¶ added in v2.11.0
func (s *Store) APITokensByAgentID(ctx context.Context, agentID theauth.ULID) ([]theauth.APIToken, error)
APITokensByAgentID returns every token minted for the agent, newest first.
func (*Store) APITokensByOwner ¶
func (s *Store) APITokensByOwner(ctx context.Context, ownerID theauth.ULID) ([]theauth.APIToken, error)
APITokensByOwner returns every token of the owner, newest first.
func (*Store) AccountStateByUserID ¶ added in v2.10.0
func (s *Store) AccountStateByUserID(ctx context.Context, userID theauth.ULID) (theauth.AccountState, error)
AccountStateByUserID returns the user's lifecycle flags; a user without a row yields the zero state.
func (*Store) AddGroupMembers ¶
func (*Store) AdvanceTOTPStep ¶
AdvanceTOTPStep records step as the user's last used TOTP step, returning false when it is not strictly newer.
func (*Store) AgentByClientID ¶
func (*Store) AgentCredentialsByAgentID ¶
func (*Store) AgentsByOwner ¶
func (*Store) AppendSessionAuthMethods ¶ added in v2.11.0
func (s *Store) AppendSessionAuthMethods(ctx context.Context, id theauth.ULID, methods []string, at time.Time) ([]string, time.Time, error)
AppendSessionAuthMethods merges methods and advances auth_time under a FOR UPDATE row lock, so concurrent appends never lose methods.
func (*Store) ApproveToolApproval ¶ added in v2.11.0
func (*Store) AtomicRotateJWKS ¶
func (s *Store) AtomicRotateJWKS(ctx context.Context, retireKIDs []string, demoteKID, promoteKID string, freshKey theauth.JWKSKey, now time.Time) error
AtomicRotateJWKS implements as.JWKSAtomicRotator in one serializable transaction, so concurrent callers cannot leave two rows with state = current. The theauth_jwks_one_current partial unique index (migration 0015) enforces the same invariant in the database.
func (*Store) AuditOrderSupported ¶ added in v2.12.0
AuditOrderSupported declares write order support (storagetest.AuditOrderCapable).
func (*Store) BackchannelRequestByID ¶
func (*Store) ChainSupported ¶ added in v2.11.0
ChainSupported reports that this backend keeps the tamper-evident audit hash chain.
func (*Store) ClaimDeviceCode ¶
func (s *Store) ClaimDeviceCode(ctx context.Context, hash []byte, now time.Time) (*theauth.DeviceCode, error)
ClaimDeviceCode atomically moves an approved, unexpired request to redeemed; one concurrent caller wins.
func (*Store) ConfirmTOTPSecret ¶
func (*Store) ConsumeAuthorizationCode ¶
func (s *Store) ConsumeAuthorizationCode(ctx context.Context, code string) (*theauth.AuthorizationCode, error)
ConsumeAuthorizationCode uses DELETE ... RETURNING for atomicity: exactly one of N concurrent callers wins per code.
func (*Store) ConsumeDeviceAuthorization ¶ added in v2.8.0
func (*Store) ConsumeMagicLink ¶
func (*Store) ConsumePasswordResetToken ¶
func (*Store) ConsumePushedRequest ¶
ConsumePushedRequest atomically marks the row as consumed and returns the payload. Returns ErrNotFound when:
- the request_uri does not exist
- the row has already been consumed (consumed_at IS NOT NULL)
- the row is expired (expires_at <= now)
func (*Store) ConsumeRecoveryCode ¶
func (*Store) ConsumeSessionLink ¶
func (s *Store) ConsumeSessionLink(ctx context.Context, tokenHash []byte, now time.Time) (*theauth.SessionLink, error)
ConsumeSessionLink atomically marks an unused, unexpired link used and returns it, else ErrNotFound.
func (*Store) ConsumeToolApproval ¶ added in v2.11.0
func (s *Store) ConsumeToolApproval(ctx context.Context, id, agentID, action, resource string, now time.Time) (bool, error)
ConsumeToolApproval implements theauth.ToolApprovalStorage. The conditional UPDATE is the single winner check: only one caller sees one affected row.
func (*Store) CountUnusedRecoveryCodes ¶
func (*Store) CountUsers ¶
CountUsers returns the number of user rows.
func (*Store) CountUsersWithPermissionInOrg ¶
func (*Store) CreateMagicLink ¶
func (*Store) CreatePasswordResetToken ¶
func (*Store) CreateSession ¶
CreateSession inserts a session with the default full auth level.
func (*Store) CreateSessionLink ¶
CreateSessionLink stores a single-use session link.
func (*Store) CreateSessionWithAuthLevel ¶
func (s *Store) CreateSessionWithAuthLevel(ctx context.Context, sess theauth.Session) (theauth.Session, error)
CreateSessionWithAuthLevel inserts a session with its own auth level.
func (*Store) CreateUser ¶
func (*Store) DecideDeviceAuthorization ¶ added in v2.8.0
func (*Store) DecideDeviceCode ¶
func (s *Store) DecideDeviceCode(ctx context.Context, userCode string, d theauth.DeviceDecision, now time.Time) error
DecideDeviceCode moves a pending, unexpired request to approved or denied in one statement.
func (*Store) DelegationGrantByID ¶
func (*Store) DelegationGrantByUserAgentResource ¶
func (*Store) DelegationGrantsByAgentID ¶
func (*Store) DelegationGrantsByUserID ¶
func (*Store) DeleteBackchannelRequest ¶
func (*Store) DeleteExpiredDeviceAuthorizations ¶ added in v2.8.0
func (*Store) DeleteExpiredDeviceCodes ¶
DeleteExpiredDeviceCodes removes requests that expired before the cutoff.
func (*Store) DeleteOAuthAccountByProvider ¶
func (s *Store) DeleteOAuthAccountByProvider(ctx context.Context, userID theauth.ULID, provider string) error
DeleteOAuthAccountByProvider removes the row for (userID, provider).
func (*Store) DeleteOAuthClient ¶
func (*Store) DeleteOrganization ¶
func (*Store) DeleteOrganizationMember ¶
func (*Store) DeleteSAMLConnection ¶
func (*Store) DeleteTOTPSecret ¶
func (*Store) DeleteUserCascade ¶ added in v2.10.0
DeleteUserCascade removes the user and its rows in one transaction. Foreign keys cascade everything except API tokens and magic links, which have no user foreign key.
func (*Store) DeleteWebAuthnCredential ¶
func (*Store) DenyAccessToken ¶ added in v2.8.0
DenyAccessToken records jti as revoked until expiresAt (opt-in access token revocation).
func (*Store) DeviceAuthorizationByDeviceCodeHash ¶ added in v2.8.0
func (*Store) DeviceAuthorizationByUserCodeHash ¶ added in v2.8.0
func (*Store) DeviceByID ¶ added in v2.10.0
func (*Store) DeviceCodeByHash ¶
DeviceCodeByHash returns the request with the given device code hash, else ErrNotFound.
func (*Store) DeviceCodeByUserCode ¶
func (s *Store) DeviceCodeByUserCode(ctx context.Context, userCode string) (*theauth.DeviceCode, error)
DeviceCodeByUserCode returns the request with the given user code, else ErrNotFound.
func (*Store) DeviceJoinTokenByHash ¶ added in v2.10.0
func (*Store) DeviceJoinTokenByID ¶ added in v2.10.0
func (*Store) GrantUserRole ¶
func (*Store) GroupByExternalIDInOrg ¶
func (*Store) GroupMembers ¶
func (*Store) InsertAPIToken ¶
InsertAPIToken stores a token and returns the stored row.
func (*Store) InsertAgent ¶
func (*Store) InsertAgentCredential ¶
func (*Store) InsertAuditEvents ¶
InsertAuditEvents appends a batch in one transaction. Rows are linked into a per-organization hash chain (see VerifyAuditChain); concurrent writers are serialized per chain by a row lock on the chain head (see lockChainHeads).
func (*Store) InsertAuthorizationCode ¶
func (*Store) InsertBackchannelRequest ¶
func (*Store) InsertDelegationGrant ¶
func (s *Store) InsertDelegationGrant(ctx context.Context, g theauth.DelegationGrant) (theauth.DelegationGrant, error)
func (*Store) InsertDevice ¶ added in v2.10.0
func (*Store) InsertDeviceAuthorization ¶ added in v2.8.0
func (*Store) InsertDeviceCode ¶
InsertDeviceCode stores a request, returning ErrDeviceUserCodeTaken on a user code collision.
func (*Store) InsertDeviceJoinToken ¶ added in v2.10.0
func (*Store) InsertGroup ¶
func (*Store) InsertJWKSKey ¶
func (*Store) InsertOAuthClient ¶
func (s *Store) InsertOAuthClient(ctx context.Context, c theauth.OAuthClient) (theauth.OAuthClient, error)
func (*Store) InsertOpaqueAccessToken ¶ added in v2.8.0
func (*Store) InsertOrganization ¶
func (s *Store) InsertOrganization(ctx context.Context, o theauth.Organization) (theauth.Organization, error)
func (*Store) InsertPermission ¶
func (s *Store) InsertPermission(ctx context.Context, p theauth.Permission) (theauth.Permission, error)
func (*Store) InsertPushedRequest ¶
func (s *Store) InsertPushedRequest(ctx context.Context, requestURI string, payload []byte, expiresAt time.Time) error
InsertPushedRequest stores a pushed authorization request. The requestURI is the full urn: string; payload is the JSON-encoded AuthorizeRequest; expiresAt is the absolute expiry timestamp.
func (*Store) InsertRecoveryCodes ¶
func (*Store) InsertRefreshToken ¶
func (*Store) InsertRegistrationToken ¶ added in v2.8.0
func (*Store) InsertRole ¶
func (*Store) InsertSAMLConnection ¶
func (s *Store) InsertSAMLConnection(ctx context.Context, c theauth.SAMLConnection) (theauth.SAMLConnection, error)
func (*Store) InsertSCIMToken ¶
func (*Store) InsertTrustedDevice ¶ added in v2.10.0
InsertTrustedDevice stores a remember-this-device record.
func (*Store) InsertWebAuthnCredential ¶
func (s *Store) InsertWebAuthnCredential(ctx context.Context, c theauth.WebAuthnCredential) (theauth.WebAuthnCredential, error)
func (*Store) IsAccessTokenDenied ¶ added in v2.8.0
IsAccessTokenDenied reports whether jti is on the unexpired denylist.
func (*Store) JWKSKeyByKID ¶
func (*Store) JWKSKeysAll ¶
func (*Store) ListAPITokens ¶
ListAPITokens returns every token, newest first.
func (*Store) ListDevices ¶ added in v2.10.0
func (*Store) ListGroupsByOrganization ¶
func (*Store) ListPendingDeviceCodes ¶
func (s *Store) ListPendingDeviceCodes(ctx context.Context, f theauth.DevicePendingFilter) ([]theauth.DeviceCode, error)
ListPendingDeviceCodes returns pending, unexpired requests newest first without device code hashes.
func (*Store) ListPermissions ¶
func (*Store) ListRegistrationTokens ¶ added in v2.8.0
func (*Store) ListTrustedDevices ¶ added in v2.10.0
func (s *Store) ListTrustedDevices(ctx context.Context, userID theauth.ULID) ([]theauth.TrustedDevice, error)
ListTrustedDevices returns the user's unrevoked, unexpired devices, newest first.
func (*Store) ListUserSessions ¶
func (s *Store) ListUserSessions(ctx context.Context, userID theauth.ULID) ([]theauth.Session, error)
ListUserSessions returns the user's live sessions, newest first.
func (*Store) ListUsersByOrganization ¶
func (*Store) MarkEmailVerified ¶
func (*Store) MoveOAuthAccount ¶
func (s *Store) MoveOAuthAccount(ctx context.Context, provider, providerUserID string, newUserID theauth.ULID) error
MoveOAuthAccount reassigns the row keyed by (provider, providerUserID) to newUserID.
func (*Store) MovePasswordHash ¶
MovePasswordHash copies the Argon2id hash from secondaryID to primaryID, overwriting any existing primary hash, then clears secondaryID's row. A no-op when secondaryID has no password row.
func (*Store) MoveTOTPSecret ¶
MoveTOTPSecret reassigns the TOTP secret. A confirmed primary secret wins; the secondary row is dropped without overwriting it.
func (*Store) MoveWebAuthnCredentials ¶
func (s *Store) MoveWebAuthnCredentials(ctx context.Context, primaryID, secondaryID theauth.ULID) error
MoveWebAuthnCredentials reassigns every WebAuthn credential row from secondaryID to primaryID.
func (*Store) OAuthAccountByProviderUserID ¶
func (*Store) OAuthAccountsByUserID ¶
func (s *Store) OAuthAccountsByUserID(ctx context.Context, userID theauth.ULID) ([]theauth.OAuthAccount, error)
OAuthAccountsByUserID returns every oauth_accounts row linked to userID.
func (*Store) OAuthClientByClientID ¶
func (*Store) OpaqueAccessTokenByHash ¶ added in v2.8.0
func (*Store) OpenToolApproval ¶ added in v2.11.0
func (*Store) OrganizationByID ¶
func (*Store) OrganizationBySlug ¶
func (*Store) OrganizationMemberRole ¶
func (*Store) OrganizationMembersByOrg ¶
func (*Store) OrganizationsByUser ¶
func (*Store) PermissionByName ¶
func (*Store) PermissionsByRole ¶
func (*Store) PermissionsForUser ¶
func (*Store) QueryAuditEvents ¶
func (s *Store) QueryAuditEvents(ctx context.Context, q theauth.AuditQuery) ([]theauth.AuditEvent, string, error)
QueryAuditEvents is hand-built because the filter combinations vary too much for a fixed sqlc query. Rows are ordered by (recorded_at_us, id) in q.Order (default desc) and paged with a "c1." keyset cursor. A cursor from before write order existed keeps the old (created_at DESC, id DESC) keyset, for descending reads only.
func (*Store) RecordDeviceAuthorizationPoll ¶ added in v2.8.0
func (*Store) RecordDevicePoll ¶
func (s *Store) RecordDevicePoll(ctx context.Context, hash []byte, at time.Time, intervalSeconds int) error
RecordDevicePoll stores the last poll time and the current polling interval.
func (*Store) RedeemBackchannelRequest ¶ added in v2.11.0
func (s *Store) RedeemBackchannelRequest(ctx context.Context, authReqID string, now time.Time) (theauth.BackchannelRequest, bool, error)
RedeemBackchannelRequest implements theauth.BackchannelRedeemer. One conditional UPDATE moves an approved, unexpired request to consumed and returns it, so exactly one concurrent caller wins. Any other state (pending, denied, expired, consumed, unknown) returns ok == false.
func (*Store) RedeemDeviceJoinToken ¶ added in v2.10.0
func (*Store) RedeemRegistrationToken ¶ added in v2.8.0
func (*Store) RefreshTokenByHash ¶
func (*Store) RefundDeviceJoinToken ¶ added in v2.10.0
func (*Store) RefundRegistrationToken ¶ added in v2.8.0
func (*Store) RegistrationTokenByHash ¶ added in v2.8.0
func (*Store) RegistrationTokenByID ¶ added in v2.8.0
func (*Store) RemoveGroupMembers ¶
func (*Store) RenameWebAuthnCredential ¶
func (*Store) ReplaceRecoveryCodes ¶
func (*Store) RevokeAPIToken ¶
RevokeAPIToken revokes a token, keeping the first revocation time on repeat calls.
func (*Store) RevokeAPITokensByOwner ¶
func (s *Store) RevokeAPITokensByOwner(ctx context.Context, ownerID theauth.ULID, at time.Time) (int, error)
RevokeAPITokensByOwner revokes the owner's live tokens and returns how many it changed.
func (*Store) RevokeAgentCredential ¶
func (*Store) RevokeDelegationGrant ¶
func (*Store) RevokeDevice ¶ added in v2.10.0
func (*Store) RevokeDeviceJoinToken ¶ added in v2.10.0
func (*Store) RevokeOpaqueAccessToken ¶ added in v2.8.0
func (*Store) RevokeOtherUserSessions ¶
func (s *Store) RevokeOtherUserSessions(ctx context.Context, userID, keep theauth.ULID) (int, error)
RevokeOtherUserSessions revokes the user's live sessions except keep and returns the count.
func (*Store) RevokeRefreshToken ¶
func (*Store) RevokeRefreshTokenFamily ¶
func (*Store) RevokeRefreshTokensByAuthCode ¶ added in v2.8.0
func (s *Store) RevokeRefreshTokensByAuthCode(ctx context.Context, codeHash, reason string) ([]string, error)
RevokeRefreshTokensByAuthCode revokes the rotation families of the code under codeHash and returns the revoked access-token jtis.
func (*Store) RevokeRegistrationToken ¶ added in v2.8.0
func (*Store) RevokeSCIMTokenByID ¶
func (*Store) RevokeSession ¶
func (*Store) RevokeSessionsByCredential ¶
RevokeSessionsByCredential revokes every live session bound to credentialID and returns the count.
func (*Store) RevokeTrustedDevice ¶ added in v2.10.0
RevokeTrustedDevice revokes one live device owned by userID.
func (*Store) RevokeUserRole ¶
func (*Store) RevokeUserSessions ¶
func (*Store) RevokeUserTrustedDevices ¶ added in v2.10.0
RevokeUserTrustedDevices revokes every live device of userID and returns how many it revoked.
func (*Store) RoleByOrgAndName ¶
func (*Store) RolesByOrganization ¶
func (*Store) RolesForUser ¶
func (*Store) SAMLConnectionByID ¶
func (*Store) SAMLConnectionsByOrg ¶
func (*Store) SAMLIdentityByConnectionAndNameID ¶
func (*Store) SCIMTokenByHash ¶
func (*Store) SCIMTokensByOrg ¶
func (*Store) SessionAndUserByTokenHash ¶ added in v2.8.0
func (s *Store) SessionAndUserByTokenHash(ctx context.Context, hash []byte) (*theauth.Session, *theauth.User, error)
SessionAndUserByTokenHash returns a session and its user in one round trip.
func (*Store) SessionByID ¶
SessionByID returns the session with the given ID.
func (*Store) SessionByTokenHash ¶
SessionByTokenHash returns the session with the given token hash.
func (*Store) SetGroupMembers ¶
func (*Store) SetMustChangePassword ¶ added in v2.10.0
func (s *Store) SetMustChangePassword(ctx context.Context, userID theauth.ULID, required bool) error
SetMustChangePassword sets or clears the forced password change flag.
func (*Store) SetRolePermissions ¶
func (*Store) SetSessionActiveOrganization ¶
func (*Store) SetSessionElevatedUntil ¶
func (s *Store) SetSessionElevatedUntil(ctx context.Context, id theauth.ULID, until *time.Time) error
SetSessionElevatedUntil sets or clears the step-up window of one session.
func (*Store) SetUserDisabledAt ¶ added in v2.10.0
SetUserDisabledAt disables the user at the given time, or re-enables it when at is nil.
func (*Store) SetUserPassword ¶
func (*Store) SignalsStore ¶ added in v2.10.0
SignalsStore returns a signals.Store backed by this database. Pass it as SharedSignalsConfig.Store.
func (*Store) TOTPSecretByUserID ¶
func (*Store) ThrottleStore ¶
func (s *Store) ThrottleStore() *ThrottleStore
ThrottleStore returns a login throttle store backed by the same database.
func (*Store) TouchAPITokenLastUsed ¶
TouchAPITokenLastUsed records the last use time of a token.
func (*Store) TouchBackchannelPoll ¶
func (s *Store) TouchBackchannelPoll(ctx context.Context, authReqID string, now time.Time, newInterval int) (theauth.BackchannelRequest, error)
TouchBackchannelPoll satisfies CIBAStorage. Updates last_poll_at and poll_interval atomically and returns the updated row.
func (*Store) TouchDevice ¶ added in v2.10.0
func (*Store) TouchSAMLIdentityLastLogin ¶
func (*Store) TouchSCIMTokenLastUsed ¶
func (*Store) TouchSession ¶
TouchSession advances last-seen time and never moves it backwards.
func (*Store) TouchTrustedDevice ¶ added in v2.10.0
TouchTrustedDevice sets LastUsedAt.
func (*Store) TrustedDeviceByTokenHash ¶ added in v2.10.0
func (s *Store) TrustedDeviceByTokenHash(ctx context.Context, userID theauth.ULID, hash []byte) (*theauth.TrustedDevice, error)
TrustedDeviceByTokenHash returns the record for userID and hash, revoked or expired rows included.
func (*Store) UpdateAgentCredentialLastUsed ¶
func (*Store) UpdateAgentExpiry ¶ added in v2.12.0
func (*Store) UpdateAgentLastActive ¶
func (*Store) UpdateAgentStatus ¶
func (*Store) UpdateBackchannelRequest ¶
UpdateBackchannelRequest satisfies CIBAStorage. Writes all mutable fields.
func (*Store) UpdateJWKSKeyState ¶
func (*Store) UpdateOAuthClient ¶
func (s *Store) UpdateOAuthClient(ctx context.Context, c theauth.OAuthClient) (theauth.OAuthClient, error)
func (*Store) UpdateOrganization ¶
func (*Store) UpdateRoleRow ¶
func (*Store) UpdateSAMLConnectionRow ¶
func (*Store) UpdateSessionAuthLevel ¶
func (*Store) UpdateUserSCIM ¶
func (*Store) UpdateWebAuthnBackupFlags ¶
func (s *Store) UpdateWebAuthnBackupFlags(ctx context.Context, credentialID []byte, backupEligible, backupState bool) error
UpdateWebAuthnBackupFlags reconciles BE/BS flags for legacy synced passkeys (trust-on-first-use). A missing credential returns nil: the caller treats this as best-effort.
func (*Store) UpdateWebAuthnSignCount ¶
func (s *Store) UpdateWebAuthnSignCount(ctx context.Context, credentialID []byte, newCount uint32, usedAt time.Time) error
UpdateWebAuthnSignCount requires a strictly greater count. On a miss it runs a follow-up SELECT to tell a missing credential from a replay, keeping the happy path to one round-trip.
func (*Store) UpsertOAuthAccount ¶
func (s *Store) UpsertOAuthAccount(ctx context.Context, a theauth.OAuthAccount) (theauth.OAuthAccount, error)
func (*Store) UpsertOrganizationMember ¶
func (*Store) UpsertPendingTOTPSecret ¶
func (*Store) UpsertSAMLIdentity ¶
func (s *Store) UpsertSAMLIdentity(ctx context.Context, i theauth.SAMLIdentity) (theauth.SAMLIdentity, error)
func (*Store) UserByEmail ¶
func (*Store) UserByEmailWithPassword ¶
func (*Store) UserByExternalIDInOrg ¶
func (*Store) UserPasswordHashByID ¶
UserPasswordHashByID returns the stored Argon2id PHC string for the user, or "" when the user has no password (or does not exist). Hashes live in users.password_hash.
func (*Store) VerifyAuditChain ¶ added in v2.11.0
VerifyAuditChain walks every chain in seq order and reports the first mismatched row. Pre-0028 rows count as Unchained; erased rows verify via their pseudonyms and count as Erased.
func (*Store) WebAuthnCredentialByCredentialID ¶
func (*Store) WebAuthnCredentialsByUserID ¶
type ThrottleStore ¶
type ThrottleStore struct {
// contains filtered or unexported fields
}
ThrottleStore is a Postgres-backed theauth.LoginThrottleStore shared by every process using the database.
func (*ThrottleStore) CompareAndSwap ¶
func (t *ThrottleStore) CompareAndSwap(ctx context.Context, key string, prev theauth.LoginThrottleEntry, prevExists bool, next theauth.LoginThrottleEntry) (bool, error)
CompareAndSwap writes next only when the stored entry still equals prev, or is absent when prevExists is false.
func (*ThrottleStore) Delete ¶
func (t *ThrottleStore) Delete(ctx context.Context, key string) error
Delete removes key.
func (*ThrottleStore) DeleteLoginEntries ¶ added in v2.7.0
func (t *ThrottleStore) DeleteLoginEntries(ctx context.Context, ident string) error
DeleteLoginEntries removes every login backoff entry for ident across all client IPs.
func (*ThrottleStore) Get ¶
func (t *ThrottleStore) Get(ctx context.Context, key string) (theauth.LoginThrottleEntry, bool, error)
Get returns the entry for key.
func (*ThrottleStore) Set ¶
func (t *ThrottleStore) Set(ctx context.Context, key string, e theauth.LoginThrottleEntry) error
Set stores e under key unconditionally.
func (*ThrottleStore) SweepExpired ¶
SweepExpired deletes entries whose ExpiresAt is at or before now and returns how many it removed.
Source Files
¶
- audit_chain.go
- audit_chain_scan.go
- doc.go
- migrate.go
- migrate_status.go
- postgres.go
- postgres_apitokens.go
- postgres_audit.go
- postgres_ciba.go
- postgres_device.go
- postgres_hardening.go
- postgres_identitylink.go
- postgres_iotdevice.go
- postgres_lifecycle.go
- postgres_opaque.go
- postgres_par.go
- postgres_sessions.go
- postgres_signals.go
- postgres_toolapprovals.go
- postgres_v07.go
- postgres_v10.go
- postgres_v20.go
- postgres_v20_agents.go
- postgres_v20_helpers.go