Versions in this module Expand all Collapse all v0 v0.0.13 Dec 1, 2022 Changes in this version + var ErrAlreadyExists = errors.New("this entity already exists") + var ErrInUse = errors.New("this entity is needed for another entity") + var ErrNotFound = errors.New("the requested entry was not found") + func BootstrapListeners(store Auditor, log *zap.Logger) []events.EventListener + type ApplicationInvite struct + ApplicationID int + Scopes string + type Auditor interface + type CommonTokenDetails struct + AuthorizationId uuid.UUID + ClientID string + ExpiresAt time.Time + ID int + IssuedAt time.Time + Properties tables.MapStructure + RedeemedAt *time.Time + RevokedAt *time.Time + Token string + TokenType string + UserID uuid.UUID + func (c *CommonTokenDetails) CodeChallenge() string + func (c *CommonTokenDetails) CodeChallengeMethod() string + type DataStore struct + func NewMysqlStore(logger *zap.Logger, cfg *config.DatabaseConfiguration) (*DataStore, error) + func NewPostgrestore(logger *zap.Logger, cfg *config.DatabaseConfiguration) (*DataStore, error) + func NewSqliteStore(logger *zap.Logger, cfg *config.DatabaseConfiguration) (*DataStore, error) + func (d *DataStore) ActiveApplicationsWithUserAuthorizations(ctx context.Context, userID uuid.UUID) ([]*tables.ApplicationTable, error) + func (d *DataStore) ActiveAuthorizationByCommonToken(ctx context.Context, tokenType string, token string) (*tables.AuthorizationTable, error) + func (d *DataStore) ActiveAuthorizationByUserAndClientID(ctx context.Context, clientID string, userID uuid.UUID) (*tables.AuthorizationTable, error) + func (d *DataStore) ActiveAuthorizationsByUserID(ctx context.Context, userID uuid.UUID) ([]*tables.AuthorizationTable, error) + func (d *DataStore) AddRole(ctx context.Context, role string) (int, error) + func (d *DataStore) AddUserToRole(ctx context.Context, id uuid.UUID, role string) error + func (d *DataStore) ApplicationByClientID(ctx context.Context, clientID string) (*tables.ApplicationTable, error) + func (d *DataStore) ApplicationByID(ctx context.Context, id int) (*tables.ApplicationTable, error) + func (d *DataStore) Applications(ctx context.Context, opts ListOptions) ([]*tables.ApplicationTable, int, error) + func (d *DataStore) Auditor() Auditor + func (d *DataStore) AuthorizationByID(ctx context.Context, id uuid.UUID) (*tables.AuthorizationTable, error) + func (d *DataStore) Authorizations(ctx context.Context, opts ListOptions) ([]*tables.AuthorizationTable, int, error) + func (d *DataStore) BanUser(ctx context.Context, id uuid.UUID) error + func (d *DataStore) Close() + func (d *DataStore) CommonTokenDetails(ctx context.Context, tokenType string, token string) (*CommonTokenDetails, error) + func (d *DataStore) ConfirmTokenExists(ctx context.Context, token string) (bool, error) + func (d *DataStore) ConfirmUser(ctx context.Context, confirmToken string) (bool, uuid.UUID, error) + func (d *DataStore) ConsumeInvite(ctx context.Context, inviteCode string) error + func (d *DataStore) ConsumeRecoveryToken(ctx context.Context, id uuid.UUID, recoveryToken string) (bool, error) + func (d *DataStore) CreateApplication(ctx context.Context, appType int, clientID string, clientSecret *string, ...) (int, error) + func (d *DataStore) DeleteAllRetiredApplications(ctx context.Context) ([]string, error) + func (d *DataStore) DeleteRole(ctx context.Context, role string) error + func (d *DataStore) DisableMFA(ctx context.Context, id uuid.UUID) (bool, error) + func (d *DataStore) EnableMFA(ctx context.Context, id uuid.UUID, userSecret string, userRecoveryKey string) (bool, error) + func (d *DataStore) EnsureUsable() error + func (d *DataStore) GrantAuthorization(ctx context.Context, applicationId int, userID uuid.UUID, ...) (uuid.UUID, error) + func (d *DataStore) IDFromEmail(ctx context.Context, email string) (bool, uuid.UUID, error) + func (d *DataStore) InsertCommonToken(ctx context.Context, authorizationID uuid.UUID, tokenType string, token string, ...) (int, error) + func (d *DataStore) InsertUser(ctx context.Context, email string, passwordHash string, phone *string, ...) (uuid.UUID, error) + func (d *DataStore) InviteCodeExists(ctx context.Context, code string) (bool, error) + func (d *DataStore) InviteData(ctx context.Context, inviteCode string) (*UserInviteData, error) + func (d *DataStore) InviteUser(ctx context.Context, expires time.Time, email *string, code string, ...) error + func (d *DataStore) Invites(ctx context.Context, opts ListOptions) ([]*tables.UserInviteTable, int, error) + func (d *DataStore) IsInviteable(ctx context.Context, email string) (bool, error) + func (d *DataStore) IsRegistred(ctx context.Context, email string) (bool, error) + func (d *DataStore) IsUserInRole(ctx context.Context, id uuid.UUID, role string) (bool, error) + func (d *DataStore) LockUser(ctx context.Context, id uuid.UUID, lockTime time.Time) (bool, error) + func (d *DataStore) ManualConfirmUser(ctx context.Context, id uuid.UUID) error + func (d *DataStore) RedeemCommonToken(ctx context.Context, tokenType string, token string) error + func (d *DataStore) RemoveUserFromRole(ctx context.Context, id uuid.UUID, role string) error + func (d *DataStore) RetireApplication(ctx context.Context, id int) (int64, int64, error) + func (d *DataStore) RevokeAuthorization(ctx context.Context, id uuid.UUID) (int64, error) + func (d *DataStore) RevokeCommonToken(ctx context.Context, tokenType string, token string) error + func (d *DataStore) RevokeCommonTokensForAuthorization(ctx context.Context, authorizationID uuid.UUID) (int, error) + func (d *DataStore) Roles(ctx context.Context, opts ListOptions) ([]*tables.RoleTable, int, error) + func (d *DataStore) SetApplicationSecret(ctx context.Context, clientID string, secret string) error + func (d *DataStore) SetEmail(ctx context.Context, id uuid.UUID, email string) (bool, error) + func (d *DataStore) SetFailureCount(ctx context.Context, id uuid.UUID, count int) error + func (d *DataStore) SetInviteSent(ctx context.Context, email string, code string) error + func (d *DataStore) SetOTPPending(ctx context.Context, id uuid.UUID, pending bool) error + func (d *DataStore) SetPassword(ctx context.Context, id uuid.UUID, passwordHash string) (bool, error) + func (d *DataStore) SetRecoveryToken(ctx context.Context, id uuid.UUID, recoveryToken string) (bool, error) + func (d *DataStore) UnbanUser(ctx context.Context, id uuid.UUID) error + func (d *DataStore) UnlockUser(ctx context.Context, id uuid.UUID) (bool, error) + func (d *DataStore) UpdateApplicationProperties(ctx context.Context, clientID string, properties tables.MapStructure) error + func (d *DataStore) User(ctx context.Context, userID uuid.UUID) (*tables.UserTable, error) + func (d *DataStore) UserByEmail(ctx context.Context, email string) (*UserData, error) + func (d *DataStore) UserByID(ctx context.Context, id uuid.UUID) (*UserData, error) + func (d *DataStore) UserRoles(ctx context.Context, id uuid.UUID) ([]*tables.RoleTable, error) + func (d *DataStore) Users(ctx context.Context, opts ListOptions) ([]*tables.UserTable, int, error) + type ListOptions struct + Page int + PageSize int + Query string + Sort string + type UserAuthorization struct + ApplicationType string + ClientID string + ID uuid.UUID + Properties tables.MapStructure + RevokedAt *time.Time + type UserData struct + Authorizations []*UserAuthorization + BannedOn *time.Time + CurrentFailureCount int + Email string + EmailConfirmed *time.Time + ID uuid.UUID + LastSignIn *time.Time + LockoutTill *time.Time + OtpPending bool + PasswordHash []byte + Phone *string + PhoneConfirmed *time.Time + Roles []string + TwoFactor bool + TwoFactorSecret string + type UserInviteData struct + Expires time.Time + PreApplicationAuthorization []ApplicationInvite + Roles []string