Documentation
¶
Overview ¶
Package postgres provides a Postgres Store implementation and schema migration for Canopy.
Index ¶
- type SchemaMigration
- type Store
- func (s *Store) AcceptInvitation(ctx context.Context, invitationID string, email string, now time.Time, ...) error
- func (s *Store) AddTeamMember(ctx context.Context, member *canopy.TeamMember) error
- func (s *Store) ApplyPasswordReset(ctx context.Context, identifier string, value string, now time.Time, ...) error
- func (s *Store) CleanupExpired(ctx context.Context, now time.Time) error
- func (s *Store) ClearActiveOrganization(ctx context.Context, orgID, userID string) error
- func (s *Store) ConsumeBackupCode(ctx context.Context, userID, codeHash string) (bool, error)
- func (s *Store) ConsumeTOTPStep(ctx context.Context, userID string, counter int64) (bool, error)
- func (s *Store) ConsumeVerification(ctx context.Context, identifier, value string, now time.Time) (*canopy.Verification, error)
- func (s *Store) CreateAccount(ctx context.Context, a *canopy.Account) error
- func (s *Store) CreateInvitation(ctx context.Context, invitation *canopy.Invitation) error
- func (s *Store) CreateLinkedAccount(ctx context.Context, identifier string, value string, now time.Time, ...) error
- func (s *Store) CreateMember(ctx context.Context, member *canopy.Member) error
- func (s *Store) CreateOrganization(ctx context.Context, org *canopy.Organization) error
- func (s *Store) CreateOrganizationWithOwner(ctx context.Context, org *canopy.Organization, owner *canopy.Member) error
- func (s *Store) CreateSession(ctx context.Context, ses *canopy.Session) error
- func (s *Store) CreateTeam(ctx context.Context, team *canopy.Team) error
- func (s *Store) CreateUser(ctx context.Context, u *canopy.User) error
- func (s *Store) CreateUserAccount(ctx context.Context, u *canopy.User, a *canopy.Account) error
- func (s *Store) CreateVerification(ctx context.Context, v *canopy.Verification) error
- func (s *Store) DeleteExpiredSessions(ctx context.Context, now time.Time) error
- func (s *Store) DeleteExpiredVerifications(ctx context.Context, now time.Time) error
- func (s *Store) DeleteMember(ctx context.Context, orgID, userID string) error
- func (s *Store) DeleteOrganization(ctx context.Context, id string) error
- func (s *Store) DeleteSessionByToken(ctx context.Context, token string) error
- func (s *Store) DeleteTeam(ctx context.Context, orgID, teamID string) error
- func (s *Store) DeleteTwoFactor(ctx context.Context, userID string) error
- func (s *Store) DeleteUserSessions(ctx context.Context, userID string) error
- func (s *Store) DeleteVerificationsByIdentifier(ctx context.Context, identifier string) error
- func (s *Store) EnableTwoFactor(ctx context.Context, tf *canopy.TwoFactor, codeHashes []string) error
- func (s *Store) FindAccount(ctx context.Context, providerID, accountID string) (*canopy.Account, error)
- func (s *Store) FindAccountByUserProvider(ctx context.Context, userID, providerID string) (*canopy.Account, error)
- func (s *Store) FindInvitation(ctx context.Context, id string) (*canopy.Invitation, error)
- func (s *Store) FindMember(ctx context.Context, orgID, userID string) (*canopy.Member, error)
- func (s *Store) FindOrganizationByID(ctx context.Context, id string) (*canopy.Organization, error)
- func (s *Store) FindOrganizationBySlug(ctx context.Context, slug string) (*canopy.Organization, error)
- func (s *Store) FindSessionByToken(ctx context.Context, token string) (*canopy.SessionData, error)
- func (s *Store) FindTeamByID(ctx context.Context, id string) (*canopy.Team, error)
- func (s *Store) FindTeamMember(ctx context.Context, teamID, userID string) (*canopy.TeamMember, error)
- func (s *Store) FindUserByEmail(ctx context.Context, email string) (*canopy.User, error)
- func (s *Store) FindUserByID(ctx context.Context, id string) (*canopy.User, error)
- func (s *Store) GetTwoFactor(ctx context.Context, userID string) (*canopy.TwoFactor, error)
- func (s *Store) ListInvitationsForOrg(ctx context.Context, orgID string) ([]canopy.Invitation, error)
- func (s *Store) ListMembers(ctx context.Context, orgID string) ([]canopy.Member, error)
- func (s *Store) ListOrganizationsForUser(ctx context.Context, userID string) ([]canopy.Organization, error)
- func (s *Store) ListTeamMembers(ctx context.Context, teamID string) ([]canopy.TeamMember, error)
- func (s *Store) ListTeamsForOrg(ctx context.Context, orgID string) ([]canopy.Team, error)
- func (s *Store) ListUserSessions(ctx context.Context, userID string) ([]canopy.Session, error)
- func (s *Store) ListUsers(ctx context.Context, q canopy.UserQuery) ([]canopy.User, int, error)
- func (s *Store) Migrate(ctx context.Context) error
- func (s *Store) RemoveMemberAndClearSessions(ctx context.Context, orgID, userID string, now time.Time) error
- func (s *Store) RemoveTeamMember(ctx context.Context, teamID, userID string) error
- func (s *Store) ReplaceBackupCodes(ctx context.Context, userID string, codeHashes []string) error
- func (s *Store) ReplaceVerification(ctx context.Context, v *canopy.Verification) error
- func (s *Store) UpdateAccount(ctx context.Context, a *canopy.Account) error
- func (s *Store) UpdateInvitation(ctx context.Context, invitation *canopy.Invitation) error
- func (s *Store) UpdateMember(ctx context.Context, member *canopy.Member) error
- func (s *Store) UpdateMemberRole(ctx context.Context, member *canopy.Member, protectedRole string) error
- func (s *Store) UpdateOrganization(ctx context.Context, org *canopy.Organization) error
- func (s *Store) UpdateSession(ctx context.Context, ses *canopy.Session) error
- func (s *Store) UpdateTeam(ctx context.Context, team *canopy.Team) error
- func (s *Store) UpdateUser(ctx context.Context, u *canopy.User) error
- func (s *Store) UpsertTwoFactor(ctx context.Context, tf *canopy.TwoFactor) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SchemaMigration ¶ added in v1.0.0
SchemaMigration is one ordered Canopy database migration.
func Migrations ¶ added in v1.0.0
func Migrations() []SchemaMigration
Migrations returns the ordered schema migrations for deployments that use an external migration runner.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AcceptInvitation ¶ added in v1.0.0
func (*Store) AddTeamMember ¶ added in v1.0.0
func (*Store) ApplyPasswordReset ¶ added in v1.0.0
func (s *Store) ApplyPasswordReset( ctx context.Context, identifier string, value string, now time.Time, account *canopy.Account, ) error
ApplyPasswordReset atomically consumes one reset token, updates the account, revokes sessions, and removes every other reset token for the identifier.
func (*Store) CleanupExpired ¶ added in v1.0.0
CleanupExpired removes expired session and verification records atomically.
func (*Store) ClearActiveOrganization ¶ added in v1.0.0
func (*Store) ConsumeBackupCode ¶ added in v1.0.0
func (*Store) ConsumeTOTPStep ¶ added in v1.0.0
func (*Store) ConsumeVerification ¶
func (*Store) CreateAccount ¶
func (*Store) CreateInvitation ¶ added in v1.0.0
func (*Store) CreateLinkedAccount ¶ added in v1.0.0
func (s *Store) CreateLinkedAccount( ctx context.Context, identifier string, value string, now time.Time, account *canopy.Account, ) error
CreateLinkedAccount atomically consumes the one-time link-confirmation verification and creates the provider account in one transaction. It reuses the existing verification and account tables, so it needs no schema migration.
func (*Store) CreateMember ¶ added in v1.0.0
func (*Store) CreateOrganization ¶ added in v1.0.0
func (*Store) CreateOrganizationWithOwner ¶ added in v1.0.0
func (*Store) CreateSession ¶
func (*Store) CreateTeam ¶ added in v1.0.0
func (*Store) CreateUserAccount ¶ added in v0.1.1
func (*Store) CreateVerification ¶
func (*Store) DeleteExpiredSessions ¶ added in v1.0.0
func (*Store) DeleteExpiredVerifications ¶
func (*Store) DeleteMember ¶ added in v1.0.0
func (*Store) DeleteOrganization ¶ added in v1.0.0
func (*Store) DeleteSessionByToken ¶
func (*Store) DeleteTeam ¶ added in v1.0.0
DeleteTeam removes the team and its team memberships atomically.