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 ¶
- Constants
- func Migrate(ctx context.Context, pool *pgxpool.Pool) error
- type MigrationStatus
- type PurgeBroadcaster
- 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) AddSessionFamilyToken(ctx context.Context, t theauth.SessionFamilyToken) error
- func (s *Store) AdvanceAppAttestCounter(ctx context.Context, id theauth.ULID, counter uint32) (bool, error)
- func (s *Store) AdvanceSessionFamily(ctx context.Context, in theauth.SessionFamilyAdvance) (bool, 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) ApplyEmailChange(ctx context.Context, tokenHash []byte, at time.Time, ...) (*theauth.EmailChangeRecord, 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) AuditProvenanceSupported() bool
- func (s *Store) BackchannelRequestByID(ctx context.Context, authReqID string) (theauth.BackchannelRequest, error)
- func (s *Store) CancelEmailChangeUndos(ctx context.Context, userID theauth.ULID, newEmail string, at time.Time) ([]theauth.EmailChangeRecord, error)
- func (s *Store) ChainSupported() bool
- func (s *Store) ClaimDeviceCode(ctx context.Context, hash []byte, now time.Time) (*theauth.DeviceCode, error)
- func (s *Store) ClaimSSODomainRecheck(ctx context.Context, id theauth.ULID, checkedBefore, at time.Time) (bool, 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) ConsumeSigninReport(ctx context.Context, tokenHash []byte, at time.Time) (*theauth.SigninReportRecord, 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) CreateEmailChange(ctx context.Context, r theauth.EmailChangeRecord) 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) CreateSSODomain(ctx context.Context, d theauth.SSODomain) error
- func (s *Store) CreateSession(ctx context.Context, sess theauth.Session) (theauth.Session, error)
- func (s *Store) CreateSessionFamily(ctx context.Context, f theauth.SessionFamilyRecord) 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) CreateSigninReport(ctx context.Context, r theauth.SigninReportRecord) 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) DeleteExpiredEmailChanges(ctx context.Context, before time.Time) (int64, error)
- func (s *Store) DeleteExpiredSigninReports(ctx context.Context, before time.Time) (int64, 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) DeletePendingEmailChanges(ctx context.Context, userID theauth.ULID) (int64, 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) DeleteSAMLConnectionInOrg(ctx context.Context, orgID, id theauth.ULID) error
- func (s *Store) DeleteSSODomain(ctx context.Context, id theauth.ULID) error
- func (s *Store) DeleteStaleKnownDevices(ctx context.Context, lastSeenBefore time.Time) (int64, 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) DeleteUserClientAuthorizationCodes(ctx context.Context, userID theauth.ULID, clientID string) (int, 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) DenyToolApproval(ctx context.Context, id, denier string, now time.Time) (bool, 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) DeviceByKeyThumbprint(ctx context.Context, thumbprint string) (*theauth.Device, error)
- func (s *Store) DeviceBySPIFFEID(ctx context.Context, spiffeID string) (*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) EmailChangeByTokenHash(ctx context.Context, tokenHash []byte) (*theauth.EmailChangeRecord, error)
- func (s *Store) EmailChangeIdentityManaged(ctx context.Context, userID theauth.ULID) (bool, error)
- func (s *Store) EmailReservedForUndo(ctx context.Context, email string, except theauth.ULID, at time.Time) (bool, error)
- func (s *Store) ExpireToolApproval(ctx context.Context, id string, now time.Time) (bool, error)
- func (s *Store) ForgetKnownDevice(ctx context.Context, userID theauth.ULID, deviceHash []byte) error
- func (s *Store) ForgetSessionFamily(ctx context.Context, id theauth.ULID, at time.Time) (bool, error)
- func (s *Store) GetToolApproval(ctx context.Context, id string) (theauth.ToolApproval, bool, 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) ListKnownDevices(ctx context.Context, userID theauth.ULID) ([]theauth.KnownDeviceRecord, error)
- func (s *Store) ListOverdueToolApprovals(ctx context.Context, now time.Time, limit int) ([]theauth.ToolApproval, error)
- func (s *Store) ListPendingDeviceCodes(ctx context.Context, f theauth.DevicePendingFilter) ([]theauth.DeviceCode, error)
- func (s *Store) ListPendingEmailChanges(ctx context.Context, userID theauth.ULID, at time.Time) ([]theauth.EmailChangeRecord, 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) ListSigninReports(ctx context.Context, userID theauth.ULID) ([]theauth.SigninReportRecord, error)
- func (s *Store) ListToolApprovals(ctx context.Context, limit int) ([]theauth.ToolApproval, error)
- func (s *Store) ListTrustedDevices(ctx context.Context, userID theauth.ULID) ([]theauth.TrustedDevice, error)
- func (s *Store) ListUserOAuthGrants(ctx context.Context, userID theauth.ULID, now time.Time) ([]theauth.OAuthGrantRow, error)
- func (s *Store) ListUserSessionFamilies(ctx context.Context, userID theauth.ULID) ([]theauth.SessionFamilyRecord, 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) MarkSSODomainVerified(ctx context.Context, id theauth.ULID, at time.Time) (theauth.SSODomain, error)
- func (s *Store) MarkSessionFamilyUsed(ctx context.Context, sessionID theauth.ULID, at time.Time) 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) OAuthGrantRevocationByUserClient(ctx context.Context, userID theauth.ULID, clientID string) (*theauth.OAuthGrantRevocation, 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) PutOAuthGrantRevocation(ctx context.Context, r theauth.OAuthGrantRevocation) error
- func (s *Store) QueryAuditEvents(ctx context.Context, q theauth.AuditQuery) ([]theauth.AuditEvent, string, error)
- func (s *Store) RebindSessionFamily(ctx context.Context, familyID, from, to theauth.ULID) (bool, 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) RecordKnownDevice(ctx context.Context, userID theauth.ULID, deviceHash []byte, at time.Time) error
- func (s *Store) RecordSSODomainFailure(ctx context.Context, id theauth.ULID, grace int) (theauth.SSODomain, bool, 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) RenameSessionFamily(ctx context.Context, id theauth.ULID, label string) 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) ResumeDevice(ctx context.Context, id theauth.ULID) (bool, error)
- func (s *Store) RevertEmailChange(ctx context.Context, tokenHash []byte, at time.Time) (*theauth.EmailChangeRecord, string, 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) RevokeOpaqueAccessTokensByJTI(ctx context.Context, clientID string, jtis []string, at time.Time) (int, 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) RevokeSCIMTokenInOrg(ctx context.Context, orgID, id theauth.ULID, at time.Time) error
- func (s *Store) RevokeSession(ctx context.Context, id theauth.ULID) error
- func (s *Store) RevokeSessionFamily(ctx context.Context, id theauth.ULID, reason string, at time.Time) (*theauth.SessionFamilyRecord, 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) RevokeUserClientRefreshTokens(ctx context.Context, userID theauth.ULID, clientID, reason string, ...) (int, error)
- func (s *Store) RevokeUserRole(ctx context.Context, userID, roleID theauth.ULID) error
- func (s *Store) RevokeUserSessionFamilies(ctx context.Context, userID, keepSession theauth.ULID, reason string, ...) ([]theauth.SessionFamilyRecord, 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) SAMLIdentitiesByUserID(ctx context.Context, userID theauth.ULID) ([]theauth.SAMLIdentity, 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) SSODomainByID(ctx context.Context, id theauth.ULID) (*theauth.SSODomain, error)
- func (s *Store) SSODomainsByConnection(ctx context.Context, connectionID theauth.ULID) ([]theauth.SSODomain, error)
- func (s *Store) SSODomainsByName(ctx context.Context, domain string) ([]theauth.SSODomain, error)
- func (s *Store) SSODomainsDueForRecheck(ctx context.Context, checkedBefore time.Time) ([]theauth.SSODomain, 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) SessionFamilyByID(ctx context.Context, id theauth.ULID) (*theauth.SessionFamilyRecord, error)
- func (s *Store) SessionFamilyBySessionID(ctx context.Context, sessionID theauth.ULID) (*theauth.SessionFamilyRecord, error)
- func (s *Store) SessionFamilyTokenGeneration(ctx context.Context, familyID theauth.ULID, verifierHash []byte) (int64, error)
- func (s *Store) SetAuditPseudonymRotation(r audit.Rotation) 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) ShredAuditPseudonyms(ctx context.Context) ([]int64, error)
- func (s *Store) SignalsStore() signals.Store
- func (s *Store) SigninReportByTokenHash(ctx context.Context, tokenHash []byte) (*theauth.SigninReportRecord, error)
- func (s *Store) SuspendDevice(ctx context.Context, id theauth.ULID) (bool, error)
- 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) TouchKnownDevice(ctx context.Context, userID theauth.ULID, deviceHash []byte, at time.Time) (bool, 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) UserClientTokenRefs(ctx context.Context, userID theauth.ULID, clientID string, ...) ([]theauth.OAuthTokenRef, error)
- func (s *Store) UserOAuthGrantEvidence(ctx context.Context, userID theauth.ULID, now, issuedAfter time.Time) ([]theauth.OAuthGrantEvidence, 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) VoteToolApproval(ctx context.Context, id, approver string, now time.Time) (theauth.ToolApprovalVote, 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 ¶
const DefaultPurgeChannel = "theauth_device_purge"
DefaultPurgeChannel is the LISTEN and NOTIFY channel PurgeBroadcaster uses when none is set.
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 PurgeBroadcaster ¶ added in v2.14.0
type PurgeBroadcaster struct {
// contains filtered or unexported fields
}
PurgeBroadcaster fans a device cache purge out to every replica over Postgres LISTEN and NOTIFY. It implements mqttauth.PurgeBroadcaster: pass it to Purger.SetBroadcaster and run Purger.Run on each replica. It needs no table and no migration.
Publish sends one NOTIFY whose payload is the device ID, empty for "everything". The payload is not a secret and a ULID is far below the 8000 byte limit. NOTIFY is delivered to the listeners that are connected when the transaction commits, so a replica that was disconnected misses it. Subscribe therefore reports an empty ID (purge all) every time it has to reconnect, which covers the gap. Subscribe holds one connection of the pool for as long as it runs.
func NewPurgeBroadcaster ¶ added in v2.14.0
func NewPurgeBroadcaster(pool *pgxpool.Pool, channel string) *PurgeBroadcaster
NewPurgeBroadcaster returns a broadcaster over pool. An empty channel means DefaultPurgeChannel. Use one channel per deployment: replicas of different environments that share a database must not share a channel.
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) AddSessionFamilyToken ¶ added in v2.14.0
AddSessionFamilyToken inserts a history row unless it already exists.
func (*Store) AdvanceAppAttestCounter ¶ added in v2.14.0
func (s *Store) AdvanceAppAttestCounter(ctx context.Context, id theauth.ULID, counter uint32) (bool, error)
AdvanceAppAttestCounter raises the App Attest counter in one conditional UPDATE.
func (*Store) AdvanceSessionFamily ¶ added in v2.14.0
func (s *Store) AdvanceSessionFamily(ctx context.Context, in theauth.SessionFamilyAdvance) (bool, error)
AdvanceSessionFamily rotates the family in one conditional UPDATE and reports whether it applied.
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) ApplyEmailChange ¶ added in v2.14.0
func (s *Store) ApplyEmailChange(ctx context.Context, tokenHash []byte, at time.Time, undo *theauth.EmailChangeRecord) (*theauth.EmailChangeRecord, error)
ApplyEmailChange spends a confirm record and moves the user to the new address in one transaction.
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) AuditProvenanceSupported ¶ added in v2.14.0
AuditProvenanceSupported declares that AuditQuery.Provenance is served.
func (*Store) BackchannelRequestByID ¶
func (*Store) CancelEmailChangeUndos ¶ added in v2.14.0
func (s *Store) CancelEmailChangeUndos(ctx context.Context, userID theauth.ULID, newEmail string, at time.Time) ([]theauth.EmailChangeRecord, error)
CancelEmailChangeUndos removes the user's live undo records leading to newEmail and returns them.
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) ClaimSSODomainRecheck ¶ added in v2.14.0
func (s *Store) ClaimSSODomainRecheck(ctx context.Context, id theauth.ULID, checkedBefore, at time.Time) (bool, error)
ClaimSSODomainRecheck takes a due claim for one checker.
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) ConsumeSigninReport ¶ added in v2.14.0
func (s *Store) ConsumeSigninReport(ctx context.Context, tokenHash []byte, at time.Time) (*theauth.SigninReportRecord, error)
ConsumeSigninReport spends an unused, unexpired report in one conditional update.
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) CreateEmailChange ¶ added in v2.14.0
CreateEmailChange replaces the user's pending change.
func (*Store) CreateMagicLink ¶
func (*Store) CreatePasswordResetToken ¶
func (*Store) CreateSSODomain ¶ added in v2.14.0
CreateSSODomain stores a claim on an existing connection.
func (*Store) CreateSession ¶
CreateSession inserts a session with the default full auth level.
func (*Store) CreateSessionFamily ¶ added in v2.14.0
CreateSessionFamily stores a family and its first token history row in one transaction.
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) CreateSigninReport ¶ added in v2.14.0
CreateSigninReport stores a report link by its token hash.
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) DeleteExpiredEmailChanges ¶ added in v2.14.0
DeleteExpiredEmailChanges removes records expired at or before the given time.
func (*Store) DeleteExpiredSigninReports ¶ added in v2.14.0
DeleteExpiredSigninReports removes reports expired at or before the given time.
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) DeletePendingEmailChanges ¶ added in v2.14.0
DeletePendingEmailChanges removes the user's confirm records.
func (*Store) DeleteSAMLConnection ¶
func (*Store) DeleteSAMLConnectionInOrg ¶ added in v2.14.1
DeleteSAMLConnectionInOrg removes the connection only when it belongs to orgID.
func (*Store) DeleteSSODomain ¶ added in v2.14.0
DeleteSSODomain removes a claim.
func (*Store) DeleteStaleKnownDevices ¶ added in v2.14.0
func (s *Store) DeleteStaleKnownDevices(ctx context.Context, lastSeenBefore time.Time) (int64, error)
DeleteStaleKnownDevices removes devices last seen before the given time.
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) DeleteUserClientAuthorizationCodes ¶ added in v2.14.0
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) DenyToolApproval ¶ added in v2.14.0
func (s *Store) DenyToolApproval(ctx context.Context, id, denier string, now time.Time) (bool, error)
DenyToolApproval implements theauth.ToolApprovalAdminStorage. The conditional UPDATE decides the winner, so a concurrent approve and deny produce exactly one success.
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) DeviceByKeyThumbprint ¶ added in v2.14.0
func (*Store) DeviceBySPIFFEID ¶ added in v2.14.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) EmailChangeByTokenHash ¶ added in v2.14.0
func (s *Store) EmailChangeByTokenHash(ctx context.Context, tokenHash []byte) (*theauth.EmailChangeRecord, error)
EmailChangeByTokenHash returns the record in any state.
func (*Store) EmailChangeIdentityManaged ¶ added in v2.14.0
EmailChangeIdentityManaged reports whether SAML or SCIM owns the user's address.
func (*Store) EmailReservedForUndo ¶ added in v2.14.0
func (s *Store) EmailReservedForUndo(ctx context.Context, email string, except theauth.ULID, at time.Time) (bool, error)
EmailReservedForUndo reports whether a live undo record of another user holds the address.
func (*Store) ExpireToolApproval ¶ added in v2.14.0
ExpireToolApproval implements theauth.ToolApprovalExpiryStorage.
func (*Store) ForgetKnownDevice ¶ added in v2.14.0
func (s *Store) ForgetKnownDevice(ctx context.Context, userID theauth.ULID, deviceHash []byte) error
ForgetKnownDevice removes one device of the user.
func (*Store) ForgetSessionFamily ¶ added in v2.14.0
func (s *Store) ForgetSessionFamily(ctx context.Context, id theauth.ULID, at time.Time) (bool, error)
ForgetSessionFamily sets ForgottenAt on an unrevoked family.
func (*Store) GetToolApproval ¶ added in v2.14.0
GetToolApproval implements theauth.ToolApprovalAdminStorage.
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) ListKnownDevices ¶ added in v2.14.0
func (s *Store) ListKnownDevices(ctx context.Context, userID theauth.ULID) ([]theauth.KnownDeviceRecord, error)
ListKnownDevices returns the user's known devices, oldest first.
func (*Store) ListOverdueToolApprovals ¶ added in v2.14.0
func (s *Store) ListOverdueToolApprovals(ctx context.Context, now time.Time, limit int) ([]theauth.ToolApproval, error)
ListOverdueToolApprovals implements theauth.ToolApprovalExpiryStorage.
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) ListPendingEmailChanges ¶ added in v2.14.0
func (s *Store) ListPendingEmailChanges(ctx context.Context, userID theauth.ULID, at time.Time) ([]theauth.EmailChangeRecord, error)
ListPendingEmailChanges returns the user's live confirm records without their hashes.
func (*Store) ListPermissions ¶
func (*Store) ListRegistrationTokens ¶ added in v2.8.0
func (*Store) ListSigninReports ¶ added in v2.14.0
func (s *Store) ListSigninReports(ctx context.Context, userID theauth.ULID) ([]theauth.SigninReportRecord, error)
ListSigninReports returns the user's report links without their hashes, oldest first.
func (*Store) ListToolApprovals ¶ added in v2.14.0
ListToolApprovals implements theauth.ToolApprovalAdminStorage.
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) ListUserOAuthGrants ¶ added in v2.14.0
func (*Store) ListUserSessionFamilies ¶ added in v2.14.0
func (s *Store) ListUserSessionFamilies(ctx context.Context, userID theauth.ULID) ([]theauth.SessionFamilyRecord, error)
ListUserSessionFamilies returns the user's unrevoked families, 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) MarkSSODomainVerified ¶ added in v2.14.0
func (s *Store) MarkSSODomainVerified(ctx context.Context, id theauth.ULID, at time.Time) (theauth.SSODomain, error)
MarkSSODomainVerified records a successful proof.
func (*Store) MarkSessionFamilyUsed ¶ added in v2.14.0
func (s *Store) MarkSessionFamilyUsed(ctx context.Context, sessionID theauth.ULID, at time.Time) error
MarkSessionFamilyUsed records the first use of the current generation.
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) OAuthGrantRevocationByUserClient ¶ added in v2.14.0
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) PutOAuthGrantRevocation ¶ added in v2.14.0
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) RebindSessionFamily ¶ added in v2.14.0
func (s *Store) RebindSessionFamily(ctx context.Context, familyID, from, to theauth.ULID) (bool, error)
RebindSessionFamily moves an unrevoked family from session from to session to.
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) RecordKnownDevice ¶ added in v2.14.0
func (s *Store) RecordKnownDevice(ctx context.Context, userID theauth.ULID, deviceHash []byte, at time.Time) error
RecordKnownDevice stores the device, or moves its last seen time when already stored.
func (*Store) RecordSSODomainFailure ¶ added in v2.14.0
func (s *Store) RecordSSODomainFailure(ctx context.Context, id theauth.ULID, grace int) (theauth.SSODomain, bool, error)
RecordSSODomainFailure counts a failed recheck and clears verification at grace.
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) RenameSessionFamily ¶ added in v2.14.0
RenameSessionFamily sets the family's label.
func (*Store) RenameWebAuthnCredential ¶
func (*Store) ReplaceRecoveryCodes ¶
func (*Store) ResumeDevice ¶ added in v2.14.0
func (*Store) RevertEmailChange ¶ added in v2.14.0
func (s *Store) RevertEmailChange(ctx context.Context, tokenHash []byte, at time.Time) (*theauth.EmailChangeRecord, string, error)
RevertEmailChange spends an undo record and restores the old address in one transaction.
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) RevokeOpaqueAccessTokensByJTI ¶ added in v2.14.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) RevokeSCIMTokenInOrg ¶ added in v2.14.1
func (s *Store) RevokeSCIMTokenInOrg(ctx context.Context, orgID, id theauth.ULID, at time.Time) error
RevokeSCIMTokenInOrg revokes the token only when it belongs to orgID.
func (*Store) RevokeSession ¶
func (*Store) RevokeSessionFamily ¶ added in v2.14.0
func (s *Store) RevokeSessionFamily(ctx context.Context, id theauth.ULID, reason string, at time.Time) (*theauth.SessionFamilyRecord, error)
RevokeSessionFamily revokes the family, keeping any earlier revocation, and returns the row.
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) RevokeUserClientRefreshTokens ¶ added in v2.14.0
func (*Store) RevokeUserRole ¶
func (*Store) RevokeUserSessionFamilies ¶ added in v2.14.0
func (s *Store) RevokeUserSessionFamilies(ctx context.Context, userID, keepSession theauth.ULID, reason string, at time.Time) ([]theauth.SessionFamilyRecord, error)
RevokeUserSessionFamilies revokes the user's families except keepSession's and returns those rows.
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) SAMLIdentitiesByUserID ¶ added in v2.14.0
func (s *Store) SAMLIdentitiesByUserID(ctx context.Context, userID theauth.ULID) ([]theauth.SAMLIdentity, error)
SAMLIdentitiesByUserID returns the user's SAML identities, oldest first.
func (*Store) SAMLIdentityByConnectionAndNameID ¶
func (*Store) SCIMTokenByHash ¶
func (*Store) SCIMTokensByOrg ¶
func (*Store) SSODomainByID ¶ added in v2.14.0
SSODomainByID returns one claim.
func (*Store) SSODomainsByConnection ¶ added in v2.14.0
func (s *Store) SSODomainsByConnection(ctx context.Context, connectionID theauth.ULID) ([]theauth.SSODomain, error)
SSODomainsByConnection returns the connection's claims ordered by domain.
func (*Store) SSODomainsByName ¶ added in v2.14.0
SSODomainsByName returns every claim on a domain, the verified one first.
func (*Store) SSODomainsDueForRecheck ¶ added in v2.14.0
func (s *Store) SSODomainsDueForRecheck(ctx context.Context, checkedBefore time.Time) ([]theauth.SSODomain, error)
SSODomainsDueForRecheck returns the verified claims last checked at or before checkedBefore.
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) SessionFamilyByID ¶ added in v2.14.0
func (s *Store) SessionFamilyByID(ctx context.Context, id theauth.ULID) (*theauth.SessionFamilyRecord, error)
SessionFamilyByID returns the family with the given ID.
func (*Store) SessionFamilyBySessionID ¶ added in v2.14.0
func (s *Store) SessionFamilyBySessionID(ctx context.Context, sessionID theauth.ULID) (*theauth.SessionFamilyRecord, error)
SessionFamilyBySessionID returns the family whose current session is sessionID.
func (*Store) SessionFamilyTokenGeneration ¶ added in v2.14.0
func (s *Store) SessionFamilyTokenGeneration(ctx context.Context, familyID theauth.ULID, verifierHash []byte) (int64, error)
SessionFamilyTokenGeneration returns the generation of a hash in the family's history.
func (*Store) SetAuditPseudonymRotation ¶ added in v2.14.0
SetAuditPseudonymRotation turns on rotating audit pseudonyms (theauth.AuditPseudonymRotator). It needs migration 0035. Rows written before keep their stable pseudonym and still verify.
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) ShredAuditPseudonyms ¶ added in v2.14.0
ShredAuditPseudonyms deletes the period secrets outside the retention window and returns the periods removed (theauth.AuditPseudonymRotator).
func (*Store) SignalsStore ¶ added in v2.10.0
SignalsStore returns a signals.Store backed by this database. Pass it as SharedSignalsConfig.Store.
func (*Store) SigninReportByTokenHash ¶ added in v2.14.0
func (s *Store) SigninReportByTokenHash(ctx context.Context, tokenHash []byte) (*theauth.SigninReportRecord, error)
SigninReportByTokenHash returns the report in any state.
func (*Store) SuspendDevice ¶ added in v2.14.0
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) TouchKnownDevice ¶ added in v2.14.0
func (s *Store) TouchKnownDevice(ctx context.Context, userID theauth.ULID, deviceHash []byte, at time.Time) (bool, error)
TouchKnownDevice reports whether the user knows the device and moves its last seen time.
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) UserClientTokenRefs ¶ added in v2.14.0
func (*Store) UserOAuthGrantEvidence ¶ added in v2.14.0
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) VoteToolApproval ¶ added in v2.14.0
func (s *Store) VoteToolApproval(ctx context.Context, id, approver string, now time.Time) (theauth.ToolApprovalVote, error)
VoteToolApproval implements theauth.ToolApprovalQuorumStorage with two conditional statements. The INSERT only lands while the request is live, undecided and not opened by the approver, and the primary key refuses a second vote from the same approver. The UPDATE approves the request only when the vote count has reached required_approvals, so one caller completes the quorum.
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
- audit_rotation.go
- device_attestation_claims.go
- doc.go
- migrate.go
- migrate_status.go
- postgres.go
- postgres_apitokens.go
- postgres_audit.go
- postgres_ciba.go
- postgres_connected_apps.go
- postgres_data_export.go
- postgres_device.go
- postgres_email_change.go
- postgres_hardening.go
- postgres_identitylink.go
- postgres_iotdevice.go
- postgres_lifecycle.go
- postgres_opaque.go
- postgres_par.go
- postgres_session_families.go
- postgres_sessions.go
- postgres_signals.go
- postgres_signin_notices.go
- postgres_sso_domains.go
- postgres_toolapproval_quorum.go
- postgres_toolapprovals.go
- postgres_toolapprovals_admin.go
- postgres_v07.go
- postgres_v10.go
- postgres_v20.go
- postgres_v20_agents.go
- postgres_v20_helpers.go
- purge_broadcast.go