Documentation
¶
Overview ¶
Package memory provides an in-process implementation of theauth.Storage backed by Go maps protected by a sync.RWMutex.
The store is intended for tests, examples, and local development; it retains state only for the lifetime of the process and offers no persistence guarantees. Production deployments should use storage/postgres or another durable backend.
Index ¶
- type Store
- func (s *Store) AddGroupMembers(_ context.Context, groupID theauth.ULID, userIDs []theauth.ULID) error
- func (s *Store) ConfirmTOTPSecret(_ context.Context, userID theauth.ULID, at time.Time) error
- func (s *Store) ConsumeMagicLink(_ context.Context, hash []byte) (*theauth.MagicLink, error)
- func (s *Store) ConsumePasswordResetToken(_ context.Context, hash []byte) (*theauth.PasswordResetToken, error)
- func (s *Store) ConsumeRecoveryCode(_ context.Context, userID theauth.ULID, code string, at time.Time) error
- func (s *Store) CountUsersWithPermissionInOrg(_ context.Context, orgID theauth.ULID, perm string) (int, error)
- func (s *Store) CreateMagicLink(_ context.Context, ml theauth.MagicLink) error
- func (s *Store) CreatePasswordResetToken(_ context.Context, t theauth.PasswordResetToken) error
- func (s *Store) CreateSession(_ context.Context, sess theauth.Session) (theauth.Session, error)
- func (s *Store) CreateSessionWithAuthLevel(_ context.Context, sess theauth.Session) (theauth.Session, error)
- func (s *Store) CreateUser(_ context.Context, u theauth.User) (theauth.User, error)
- func (s *Store) DeleteGroup(_ context.Context, id theauth.ULID) error
- func (s *Store) DeleteOrganization(_ context.Context, id theauth.ULID) error
- func (s *Store) DeleteOrganizationMember(_ context.Context, orgID, userID theauth.ULID) error
- func (s *Store) DeleteRole(_ context.Context, id theauth.ULID) error
- func (s *Store) DeleteSAMLConnection(_ context.Context, id theauth.ULID) error
- func (s *Store) DeleteTOTPSecret(_ context.Context, userID theauth.ULID) error
- func (s *Store) DeleteWebAuthnCredential(_ context.Context, id theauth.ULID, userID theauth.ULID) error
- func (s *Store) GrantUserRole(_ context.Context, ur theauth.UserRole) error
- func (s *Store) GroupByExternalIDInOrg(_ context.Context, orgID theauth.ULID, externalID string) (*theauth.Group, error)
- func (s *Store) GroupByID(_ context.Context, id theauth.ULID) (*theauth.Group, error)
- func (s *Store) GroupMembers(_ context.Context, groupID theauth.ULID) ([]theauth.ULID, error)
- func (s *Store) InsertAuditEvents(_ context.Context, events []theauth.AuditEvent) error
- func (s *Store) InsertGroup(_ context.Context, g theauth.Group) (theauth.Group, error)
- func (s *Store) InsertOrganization(_ context.Context, o theauth.Organization) (theauth.Organization, error)
- func (s *Store) InsertPermission(_ context.Context, p theauth.Permission) (theauth.Permission, error)
- func (s *Store) InsertRecoveryCodes(_ context.Context, codes []theauth.RecoveryCode) error
- func (s *Store) InsertRole(_ context.Context, r theauth.Role) (theauth.Role, error)
- func (s *Store) InsertSAMLConnection(_ context.Context, c theauth.SAMLConnection) (theauth.SAMLConnection, error)
- func (s *Store) InsertSCIMToken(_ context.Context, t theauth.SCIMToken) (theauth.SCIMToken, error)
- func (s *Store) InsertWebAuthnCredential(_ context.Context, c theauth.WebAuthnCredential) (theauth.WebAuthnCredential, error)
- func (s *Store) ListGroupsByOrganization(_ context.Context, orgID theauth.ULID, offset, limit int, ...) ([]theauth.Group, int, error)
- func (s *Store) ListPermissions(_ context.Context) ([]theauth.Permission, error)
- func (s *Store) ListUsersByOrganization(_ context.Context, orgID theauth.ULID, offset, limit int, ...) ([]theauth.User, int, error)
- func (s *Store) MarkEmailVerified(_ context.Context, userID theauth.ULID) error
- func (s *Store) OAuthAccountByProviderUserID(_ context.Context, provider, providerUserID string) (*theauth.OAuthAccount, error)
- func (s *Store) OrganizationByID(_ context.Context, id theauth.ULID) (*theauth.Organization, error)
- func (s *Store) OrganizationBySlug(_ context.Context, slug string) (*theauth.Organization, error)
- func (s *Store) OrganizationMemberRole(_ context.Context, orgID, userID theauth.ULID) (string, error)
- func (s *Store) OrganizationMembersByOrg(_ context.Context, orgID theauth.ULID) ([]theauth.OrganizationMember, error)
- func (s *Store) OrganizationsByUser(_ context.Context, userID theauth.ULID) ([]theauth.Organization, error)
- func (s *Store) PermissionByName(_ context.Context, name string) (*theauth.Permission, error)
- func (s *Store) PermissionsByRole(_ context.Context, roleID theauth.ULID) ([]string, error)
- func (s *Store) PermissionsForUser(_ context.Context, userID theauth.ULID, orgID *theauth.ULID) ([]string, error)
- func (s *Store) QueryAuditEvents(_ context.Context, q theauth.AuditQuery) ([]theauth.AuditEvent, string, error)
- func (s *Store) RemoveGroupMembers(_ context.Context, groupID theauth.ULID, userIDs []theauth.ULID) error
- func (s *Store) RevokeSCIMTokenByID(_ context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) RevokeSession(_ context.Context, id theauth.ULID) error
- func (s *Store) RevokeUserRole(_ context.Context, userID, roleID theauth.ULID) error
- func (s *Store) RevokeUserSessions(_ context.Context, userID theauth.ULID) error
- func (s *Store) RoleByID(_ context.Context, id theauth.ULID) (*theauth.Role, error)
- func (s *Store) RoleByOrgAndName(_ context.Context, orgID *theauth.ULID, name string) (*theauth.Role, error)
- func (s *Store) RolesByOrganization(_ context.Context, orgID *theauth.ULID) ([]theauth.Role, error)
- func (s *Store) RolesForUser(_ context.Context, userID theauth.ULID, orgID *theauth.ULID) ([]theauth.Role, error)
- func (s *Store) SAMLConnectionByID(_ context.Context, id theauth.ULID) (*theauth.SAMLConnection, error)
- func (s *Store) SAMLConnectionsByOrg(_ context.Context, orgID theauth.ULID) ([]theauth.SAMLConnection, error)
- func (s *Store) SAMLIdentityByConnectionAndNameID(_ context.Context, connectionID theauth.ULID, nameID string) (*theauth.SAMLIdentity, error)
- func (s *Store) SCIMTokenByHash(_ context.Context, hash []byte) (*theauth.SCIMToken, error)
- func (s *Store) SCIMTokensByOrg(_ context.Context, orgID theauth.ULID) ([]theauth.SCIMToken, error)
- func (s *Store) SessionByTokenHash(_ context.Context, hash []byte) (*theauth.Session, error)
- func (s *Store) SetGroupMembers(_ context.Context, groupID theauth.ULID, userIDs []theauth.ULID) error
- func (s *Store) SetRolePermissions(_ context.Context, roleID theauth.ULID, permissionIDs []theauth.ULID) error
- func (s *Store) SetSessionActiveOrganization(_ context.Context, sessionID theauth.ULID, orgID *theauth.ULID) error
- func (s *Store) SetUserPassword(_ context.Context, userID theauth.ULID, passwordHash string) error
- func (s *Store) TOTPSecretByUserID(_ context.Context, userID theauth.ULID) (*theauth.TOTPSecret, error)
- func (s *Store) TouchSAMLIdentityLastLogin(_ context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) TouchSCIMTokenLastUsed(_ context.Context, id theauth.ULID, at time.Time) error
- func (s *Store) UpdateGroup(_ context.Context, g theauth.Group) error
- func (s *Store) UpdateOrganization(_ context.Context, o theauth.Organization) error
- func (s *Store) UpdateRoleRow(_ context.Context, r theauth.Role) (theauth.Role, error)
- func (s *Store) UpdateSAMLConnectionRow(_ context.Context, c theauth.SAMLConnection) error
- func (s *Store) UpdateSessionAuthLevel(_ context.Context, id theauth.ULID, level string) error
- func (s *Store) UpdateUserSCIM(_ context.Context, u theauth.User) error
- func (s *Store) UpdateWebAuthnSignCount(_ context.Context, credentialID []byte, newCount uint32, usedAt time.Time) error
- func (s *Store) UpsertOAuthAccount(_ context.Context, a theauth.OAuthAccount) (theauth.OAuthAccount, error)
- func (s *Store) UpsertOrganizationMember(_ context.Context, m theauth.OrganizationMember) error
- func (s *Store) UpsertPendingTOTPSecret(_ context.Context, sec theauth.TOTPSecret) error
- func (s *Store) UpsertSAMLIdentity(_ context.Context, i theauth.SAMLIdentity) (theauth.SAMLIdentity, error)
- func (s *Store) UserByEmail(_ context.Context, email string) (*theauth.User, error)
- func (s *Store) UserByEmailWithPassword(_ context.Context, email string) (*theauth.User, string, error)
- func (s *Store) UserByExternalIDInOrg(_ context.Context, orgID theauth.ULID, externalID string) (*theauth.User, error)
- func (s *Store) UserByID(_ context.Context, id theauth.ULID) (*theauth.User, error)
- func (s *Store) WebAuthnCredentialByCredentialID(_ context.Context, credentialID []byte) (*theauth.WebAuthnCredential, error)
- func (s *Store) WebAuthnCredentialsByUserID(_ context.Context, userID theauth.ULID) ([]theauth.WebAuthnCredential, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AddGroupMembers ¶ added in v0.7.0
func (*Store) ConfirmTOTPSecret ¶ added in v0.5.0
func (*Store) ConsumeMagicLink ¶
func (*Store) ConsumePasswordResetToken ¶ added in v0.2.0
func (*Store) ConsumeRecoveryCode ¶ added in v0.5.0
func (s *Store) ConsumeRecoveryCode(_ context.Context, userID theauth.ULID, code string, at time.Time) error
ConsumeRecoveryCode walks the user's unused codes and constant-time-checks each against the supplied plaintext. The first hit is marked used and returns nil. No match returns ErrNotFound. Matches the Postgres semantics (linear scan over the per-user slice is fine because N is bounded by RecoveryCodeCount, defaulting to 10).
func (*Store) CountUsersWithPermissionInOrg ¶ added in v1.0.0
func (*Store) CreateMagicLink ¶
func (*Store) CreatePasswordResetToken ¶ added in v0.2.0
func (*Store) CreateSession ¶
func (*Store) CreateSessionWithAuthLevel ¶ added in v0.5.0
func (s *Store) CreateSessionWithAuthLevel(_ context.Context, sess theauth.Session) (theauth.Session, error)
CreateSessionWithAuthLevel is identical to CreateSession but honors the AuthLevel field explicitly (defaulting to AuthLevelFull when blank for safety). Service code uses this path when minting a pending_2fa session.
func (*Store) CreateUser ¶
func (*Store) DeleteGroup ¶ added in v0.7.0
func (*Store) DeleteOrganization ¶ added in v0.7.0
func (*Store) DeleteOrganizationMember ¶ added in v0.7.0
func (*Store) DeleteRole ¶ added in v1.0.0
func (*Store) DeleteSAMLConnection ¶ added in v0.7.0
func (*Store) DeleteTOTPSecret ¶ added in v0.5.0
func (*Store) DeleteWebAuthnCredential ¶ added in v0.5.0
func (*Store) GrantUserRole ¶ added in v1.0.0
func (*Store) GroupByExternalIDInOrg ¶ added in v0.7.0
func (*Store) GroupMembers ¶ added in v0.7.0
func (*Store) InsertAuditEvents ¶ added in v1.0.0
func (*Store) InsertGroup ¶ added in v0.7.0
func (*Store) InsertOrganization ¶ added in v0.7.0
func (s *Store) InsertOrganization(_ context.Context, o theauth.Organization) (theauth.Organization, error)
func (*Store) InsertPermission ¶ added in v1.0.0
func (s *Store) InsertPermission(_ context.Context, p theauth.Permission) (theauth.Permission, error)
func (*Store) InsertRecoveryCodes ¶ added in v0.5.0
func (*Store) InsertRole ¶ added in v1.0.0
func (*Store) InsertSAMLConnection ¶ added in v0.7.0
func (s *Store) InsertSAMLConnection(_ context.Context, c theauth.SAMLConnection) (theauth.SAMLConnection, error)
func (*Store) InsertSCIMToken ¶ added in v0.7.0
func (*Store) InsertWebAuthnCredential ¶ added in v0.5.0
func (s *Store) InsertWebAuthnCredential(_ context.Context, c theauth.WebAuthnCredential) (theauth.WebAuthnCredential, error)
func (*Store) ListGroupsByOrganization ¶ added in v0.7.0
func (*Store) ListPermissions ¶ added in v1.0.0
func (*Store) ListUsersByOrganization ¶ added in v0.7.0
func (*Store) MarkEmailVerified ¶
func (*Store) OAuthAccountByProviderUserID ¶ added in v0.3.0
func (*Store) OrganizationByID ¶ added in v0.7.0
func (*Store) OrganizationBySlug ¶ added in v0.7.0
func (*Store) OrganizationMemberRole ¶ added in v0.7.0
func (*Store) OrganizationMembersByOrg ¶ added in v0.7.0
func (*Store) OrganizationsByUser ¶ added in v0.7.0
func (*Store) PermissionByName ¶ added in v1.0.0
func (*Store) PermissionsByRole ¶ added in v1.0.0
func (*Store) PermissionsForUser ¶ added in v1.0.0
func (*Store) QueryAuditEvents ¶ added in v1.0.0
func (s *Store) QueryAuditEvents(_ context.Context, q theauth.AuditQuery) ([]theauth.AuditEvent, string, error)
func (*Store) RemoveGroupMembers ¶ added in v0.7.0
func (*Store) RevokeSCIMTokenByID ¶ added in v0.7.0
func (*Store) RevokeSession ¶
func (*Store) RevokeUserRole ¶ added in v1.0.0
func (*Store) RevokeUserSessions ¶
func (*Store) RoleByOrgAndName ¶ added in v1.0.0
func (*Store) RolesByOrganization ¶ added in v1.0.0
func (*Store) RolesForUser ¶ added in v1.0.0
func (*Store) SAMLConnectionByID ¶ added in v0.7.0
func (*Store) SAMLConnectionsByOrg ¶ added in v0.7.0
func (*Store) SAMLIdentityByConnectionAndNameID ¶ added in v0.7.0
func (*Store) SCIMTokenByHash ¶ added in v0.7.0
func (*Store) SCIMTokensByOrg ¶ added in v0.7.0
func (*Store) SessionByTokenHash ¶
func (*Store) SetGroupMembers ¶ added in v0.7.0
func (*Store) SetRolePermissions ¶ added in v1.0.0
func (*Store) SetSessionActiveOrganization ¶ added in v0.7.0
func (*Store) SetUserPassword ¶ added in v0.2.0
func (*Store) TOTPSecretByUserID ¶ added in v0.5.0
func (*Store) TouchSAMLIdentityLastLogin ¶ added in v0.7.0
func (*Store) TouchSCIMTokenLastUsed ¶ added in v0.7.0
func (*Store) UpdateGroup ¶ added in v0.7.0
func (*Store) UpdateOrganization ¶ added in v0.7.0
func (*Store) UpdateRoleRow ¶ added in v1.0.0
func (*Store) UpdateSAMLConnectionRow ¶ added in v0.7.0
func (*Store) UpdateSessionAuthLevel ¶ added in v0.5.0
UpdateSessionAuthLevel rewrites the AuthLevel column on the named session. Used to promote pending_2fa to full after a successful TOTP verify.
func (*Store) UpdateUserSCIM ¶ added in v0.7.0
func (*Store) UpdateWebAuthnSignCount ¶ added in v0.5.0
func (*Store) UpsertOAuthAccount ¶ added in v0.3.0
func (s *Store) UpsertOAuthAccount(_ context.Context, a theauth.OAuthAccount) (theauth.OAuthAccount, error)
UpsertOAuthAccount mirrors the Postgres ON CONFLICT (provider, provider_user_id) DO UPDATE behavior: if a row with the same (provider, provider_user_id) already exists, its mutable fields are refreshed in place (keeping the original ID + CreatedAt). Otherwise the supplied row is inserted as-is.
func (*Store) UpsertOrganizationMember ¶ added in v0.7.0
func (*Store) UpsertPendingTOTPSecret ¶ added in v0.5.0
func (*Store) UpsertSAMLIdentity ¶ added in v0.7.0
func (s *Store) UpsertSAMLIdentity(_ context.Context, i theauth.SAMLIdentity) (theauth.SAMLIdentity, error)