Documentation ¶
Index ¶
- Constants
- Variables
- func AddClaimToSession(tx *storage.Connection, sessionId uuid.UUID, ...) error
- func ClearAllOneTimeTokensForUser(tx *storage.Connection, userID uuid.UUID) error
- func ClearOneTimeTokenForUser(tx *storage.Connection, userID uuid.UUID, tokenType OneTimeTokenType) error
- func CountOtherUsers(tx *storage.Connection, id uuid.UUID) (int, error)
- func CreateOneTimeToken(tx *storage.Connection, userID uuid.UUID, relatesTo, tokenHash string, ...) error
- func DeleteExpiredFactors(tx *storage.Connection, validityDuration time.Duration) error
- func DeleteFactorsByUserId(tx *storage.Connection, userId uuid.UUID) error
- func DeleteUnverifiedFactors(tx *storage.Connection, user *User, factorType string) error
- func FindProvidersByUser(tx *storage.Connection, user *User) ([]string, error)
- func FindUserWithRefreshToken(tx *storage.Connection, token string, forUpdate bool) (*User, *RefreshToken, *Session, error)
- func GetAccountLinkingDomain(provider string) string
- func InvalidateSessionsWithAALLessThan(tx *storage.Connection, userID uuid.UUID, level string) error
- func IsDuplicatedPhone(tx *storage.Connection, phone, aud string) (bool, error)
- func IsNotFoundError(err error) bool
- func IsUniqueConstraintViolatedError(err error) bool
- func Logout(tx *storage.Connection, userId uuid.UUID) error
- func LogoutAllExceptMe(tx *storage.Connection, sessionId uuid.UUID, userID uuid.UUID) error
- func LogoutSession(tx *storage.Connection, sessionId uuid.UUID) error
- func NewAuditLogEntry(r *http.Request, tx *storage.Connection, actor *User, action AuditAction, ...) error
- func RevokeTokenFamily(tx *storage.Connection, token *RefreshToken) error
- func TruncateAll(conn *storage.Connection) error
- type AMRClaim
- type AMREntry
- type AccountLinkingDecision
- type AccountLinkingResult
- type AuditAction
- type AuditLogEntry
- type AuthenticationMethod
- type AuthenticatorAssuranceLevel
- type Challenge
- func (c *Challenge) GetExpiryTime(expiryDuration float64) time.Time
- func (c *Challenge) GetOtpCode(decryptionKeys map[string]string, encrypt bool, encryptionKeyID string) (string, bool, error)
- func (c *Challenge) HasExpired(expiryDuration float64) bool
- func (c *Challenge) SetOtpCode(otpCode string, encrypt bool, encryptionKeyID, encryptionKey string) error
- func (Challenge) TableName() string
- func (c *Challenge) Verify(tx *storage.Connection) error
- type ChallengeNotFoundError
- type Cleanup
- type CodeChallengeMethod
- type ConfirmationOrRecoveryTokenNotFoundError
- type ConfirmationTokenNotFoundError
- type Factor
- func FindFactorByFactorID(conn *storage.Connection, factorID uuid.UUID) (*Factor, error)
- func NewFactor(user *User, friendlyName string, factorType string, state FactorState) *Factor
- func NewPhoneFactor(user *User, phone, friendlyName string) *Factor
- func NewTOTPFactor(user *User, friendlyName string) *Factor
- func NewWebAuthnFactor(user *User, friendlyName string) *Factor
- func (f *Factor) CreateChallenge(ipAddress string) *Challenge
- func (f *Factor) CreatePhoneChallenge(ipAddress string, otpCode string, encrypt bool, ...) (*Challenge, error)
- func (f *Factor) DowngradeSessionsToAAL1(tx *storage.Connection) error
- func (f *Factor) FindChallengeByID(conn *storage.Connection, challengeID uuid.UUID) (*Challenge, error)
- func (f *Factor) FindLatestUnexpiredChallenge(tx *storage.Connection, expiryDuration float64) (*Challenge, error)
- func (f *Factor) GetSecret(decryptionKeys map[string]string, encrypt bool, encryptionKeyID string) (string, bool, error)
- func (f *Factor) IsPhoneFactor() bool
- func (f *Factor) IsUnverified() bool
- func (f *Factor) IsVerified() bool
- func (f *Factor) SaveWebAuthnCredential(tx *storage.Connection, credential *webauthn.Credential) error
- func (f *Factor) SetSecret(secret string, encrypt bool, encryptionKeyID, encryptionKey string) error
- func (Factor) TableName() string
- func (f *Factor) UpdateFriendlyName(tx *storage.Connection, friendlyName string) error
- func (f *Factor) UpdatePhone(tx *storage.Connection, phone string) error
- func (f *Factor) UpdateStatus(tx *storage.Connection, state FactorState) error
- func (f *Factor) WriteChallengeToDatabase(tx *storage.Connection, challenge *Challenge) error
- type FactorNotFoundError
- type FactorState
- type FlowState
- func FindFlowStateByAuthCode(tx *storage.Connection, authCode string) (*FlowState, error)
- func FindFlowStateByID(tx *storage.Connection, id string) (*FlowState, error)
- func FindFlowStateByUserID(tx *storage.Connection, id string, authenticationMethod AuthenticationMethod) (*FlowState, error)
- func NewFlowState(providerType, codeChallenge string, codeChallengeMethod CodeChallengeMethod, ...) *FlowState
- type FlowStateNotFoundError
- type FlowType
- type GrantParams
- type Identity
- func (i *Identity) BeforeCreate(tx *pop.Connection) error
- func (i *Identity) BeforeUpdate(tx *pop.Connection) error
- func (i *Identity) GetEmail() string
- func (i *Identity) IsForSSOProvider() bool
- func (Identity) TableName() string
- func (i *Identity) UpdateIdentityData(tx *storage.Connection, updates map[string]interface{}) error
- type IdentityNotFoundError
- type JSONMap
- type OneTimeToken
- type OneTimeTokenNotFoundError
- type OneTimeTokenType
- type Pagination
- type RefreshToken
- func FindTokenBySessionID(tx *storage.Connection, sessionId *uuid.UUID) (*RefreshToken, error)
- func GrantAuthenticatedUser(tx *storage.Connection, user *User, params GrantParams) (*RefreshToken, error)
- func GrantRefreshTokenSwap(r *http.Request, tx *storage.Connection, user *User, token *RefreshToken) (*RefreshToken, error)
- type RefreshTokenNotFoundError
- type SAMLAttribute
- type SAMLAttributeMapping
- type SAMLProvider
- type SAMLRelayState
- type SAMLRelayStateNotFoundError
- type SSODomain
- type SSOProvider
- func FindAllSAMLProviders(tx *storage.Connection) ([]SSOProvider, error)
- func FindSAMLProviderByEntityID(tx *storage.Connection, entityId string) (*SSOProvider, error)
- func FindSSOProviderByDomain(tx *storage.Connection, domain string) (*SSOProvider, error)
- func FindSSOProviderByID(tx *storage.Connection, id uuid.UUID) (*SSOProvider, error)
- func FindSSOProviderForEmailAddress(tx *storage.Connection, emailAddress string) (*SSOProvider, error)
- type SSOProviderNotFoundError
- type Session
- func FindAllSessionsForUser(tx *storage.Connection, userId uuid.UUID, forUpdate bool) ([]*Session, error)
- func FindSessionByID(tx *storage.Connection, id uuid.UUID, forUpdate bool) (*Session, error)
- func FindSessionByUserID(tx *storage.Connection, userId uuid.UUID) (*Session, error)
- func FindSessionsByFactorID(tx *storage.Connection, factorID uuid.UUID) ([]*Session, error)
- func NewSession(userID uuid.UUID, factorID *uuid.UUID) (*Session, error)
- func (s *Session) CalculateAALAndAMR(user *User) (aal AuthenticatorAssuranceLevel, amr []AMREntry, err error)
- func (s *Session) CheckValidity(now time.Time, refreshTokenTime *time.Time, ...) SessionValidityReason
- func (s *Session) DetermineTag(tags []string) string
- func (s *Session) FindCurrentlyActiveRefreshToken(tx *storage.Connection) (*RefreshToken, error)
- func (s *Session) GetAAL() string
- func (s *Session) IsAAL2() bool
- func (s *Session) LastRefreshedAt(refreshTokenTime *time.Time) time.Time
- func (Session) TableName() string
- func (s *Session) UpdateAALAndAssociatedFactor(tx *storage.Connection, aal AuthenticatorAssuranceLevel, factorID *uuid.UUID) error
- func (s *Session) UpdateOnlyRefreshInfo(tx *storage.Connection) error
- type SessionNotFoundError
- type SessionValidityReason
- type SortDirection
- type SortField
- type SortParams
- type User
- func FindUserByConfirmationOrRecoveryToken(tx *storage.Connection, token string) (*User, error)
- func FindUserByConfirmationToken(tx *storage.Connection, token string) (*User, error)
- func FindUserByEmailAndAudience(tx *storage.Connection, email, aud string) (*User, error)
- func FindUserByEmailChangeCurrentAndAudience(tx *storage.Connection, email, token, aud string) (*User, error)
- func FindUserByEmailChangeNewAndAudience(tx *storage.Connection, email, token, aud string) (*User, error)
- func FindUserByEmailChangeToken(tx *storage.Connection, token string) (*User, error)
- func FindUserByID(tx *storage.Connection, id uuid.UUID) (*User, error)
- func FindUserByPhoneAndAudience(tx *storage.Connection, phone, aud string) (*User, error)
- func FindUserByPhoneChangeAndAudience(tx *storage.Connection, phone, aud string) (*User, error)
- func FindUserByRecoveryToken(tx *storage.Connection, token string) (*User, error)
- func FindUserForEmailChange(tx *storage.Connection, email, token, aud string, ...) (*User, error)
- func FindUsersInAudience(tx *storage.Connection, aud string, pageParams *Pagination, ...) ([]*User, error)
- func IsDuplicatedEmail(tx *storage.Connection, email, aud string, currentUser *User) (*User, error)
- func NewUser(phone, email, password, aud string, userData map[string]interface{}) (*User, error)
- func NewUserWithPasswordHash(phone, email, passwordHash, aud string, userData map[string]interface{}) (*User, error)
- func (u *User) Authenticate(ctx context.Context, tx *storage.Connection, password string, ...) (bool, bool, error)
- func (u *User) Ban(tx *storage.Connection, duration time.Duration) error
- func (u *User) BeforeSave(tx *pop.Connection) error
- func (u *User) Confirm(tx *storage.Connection) error
- func (u *User) ConfirmEmailChange(tx *storage.Connection, status int) error
- func (u *User) ConfirmPhone(tx *storage.Connection) error
- func (u *User) ConfirmPhoneChange(tx *storage.Connection) error
- func (u *User) ConfirmReauthentication(tx *storage.Connection) error
- func (u *User) FindOwnedFactorByID(tx *storage.Connection, factorID uuid.UUID) (*Factor, error)
- func (u *User) GetEmail() string
- func (u *User) GetPhone() string
- func (u *User) HasBeenInvited() bool
- func (u *User) HasMFAEnabled() bool
- func (u *User) HasPassword() bool
- func (u *User) HasRole(roleName string) bool
- func (u *User) IsBanned() bool
- func (u *User) IsConfirmed() bool
- func (u *User) IsPhoneConfirmed() bool
- func (u *User) Recover(tx *storage.Connection) error
- func (u *User) RemoveUnconfirmedIdentities(tx *storage.Connection, identity *Identity) error
- func (u *User) SetEmail(tx *storage.Connection, email string) error
- func (u *User) SetPassword(ctx context.Context, password string, encrypt bool, ...) error
- func (u *User) SetPhone(tx *storage.Connection, phone string) error
- func (u *User) SetRole(tx *storage.Connection, roleName string) error
- func (u *User) SoftDeleteUser(tx *storage.Connection) error
- func (u *User) SoftDeleteUserIdentities(tx *storage.Connection) error
- func (User) TableName() string
- func (u *User) UpdateAppMetaData(tx *storage.Connection, updates map[string]interface{}) error
- func (u *User) UpdateAppMetaDataProviders(tx *storage.Connection) error
- func (u *User) UpdateBannedUntil(tx *storage.Connection) error
- func (u *User) UpdateLastSignInAt(tx *storage.Connection) error
- func (u *User) UpdatePassword(tx *storage.Connection, sessionID *uuid.UUID) error
- func (u *User) UpdateUserEmailFromIdentities(tx *storage.Connection) error
- func (u *User) UpdateUserMetaData(tx *storage.Connection, updates map[string]interface{}) error
- func (user *User) WebAuthnCredentials() []webauthn.Credential
- func (user *User) WebAuthnDisplayName() string
- func (user *User) WebAuthnID() []byte
- func (user *User) WebAuthnName() string
- type UserEmailUniqueConflictError
- type UserNotFoundError
- type WebAuthnCredential
- type WebAuthnSessionData
Constants ¶
const ( SessionValid SessionValidityReason = iota SessionPastNotAfter = iota SessionPastTimebox = iota SessionTimedOut = iota )
const CreatedAt = "created_at"
const InvalidCodeChallengeError = "code challenge does not match previously saved code verifier"
const InvalidCodeMethodError = "code challenge method not supported"
const Phone = "phone"
const TOTP = "totp"
const WebAuthn = "webauthn"
Variables ¶
var ActionLogTypeMap = map[AuditAction]auditLogType{ LoginAction: account, LogoutAction: account, InviteAcceptedAction: account, UserSignedUpAction: team, UserInvitedAction: team, UserDeletedAction: team, TokenRevokedAction: token, TokenRefreshedAction: token, UserModifiedAction: user, UserRecoveryRequestedAction: user, UserConfirmationRequestedAction: user, UserRepeatedSignUpAction: user, UserUpdatePasswordAction: user, GenerateRecoveryCodesAction: user, EnrollFactorAction: factor, UnenrollFactorAction: factor, CreateChallengeAction: factor, VerifyFactorAction: factor, DeleteFactorAction: factor, UpdateFactorAction: factor, MFACodeLoginAction: factor, DeleteRecoveryCodesAction: recoveryCodes, }
Functions ¶
func AddClaimToSession ¶
func AddClaimToSession(tx *storage.Connection, sessionId uuid.UUID, authenticationMethod AuthenticationMethod) error
func ClearAllOneTimeTokensForUser ¶
func ClearAllOneTimeTokensForUser(tx *storage.Connection, userID uuid.UUID) error
func ClearOneTimeTokenForUser ¶
func ClearOneTimeTokenForUser( tx *storage.Connection, userID uuid.UUID, tokenType OneTimeTokenType, ) error
func CountOtherUsers ¶
CountOtherUsers counts how many other users exist besides the one provided
func CreateOneTimeToken ¶
func CreateOneTimeToken( tx *storage.Connection, userID uuid.UUID, relatesTo, tokenHash string, tokenType OneTimeTokenType, ) error
func DeleteExpiredFactors ¶
func DeleteExpiredFactors(tx *storage.Connection, validityDuration time.Duration) error
func DeleteFactorsByUserId ¶
func DeleteFactorsByUserId(tx *storage.Connection, userId uuid.UUID) error
func DeleteUnverifiedFactors ¶
func DeleteUnverifiedFactors(tx *storage.Connection, user *User, factorType string) error
func FindProvidersByUser ¶
func FindProvidersByUser(tx *storage.Connection, user *User) ([]string, error)
FindProvidersByUser returns all providers associated to a user
func FindUserWithRefreshToken ¶
func FindUserWithRefreshToken( tx *storage.Connection, token string, forUpdate bool, ) (*User, *RefreshToken, *Session, error)
FindUserWithRefreshToken finds a user from the provided refresh token. If forUpdate is set to true, then the SELECT statement used by the query has the form SELECT ... FOR UPDATE SKIP LOCKED. This means that a FOR UPDATE lock will only be acquired if there's no other lock. In case there is a lock, a IsNotFound(err) error will be returned.
func GetAccountLinkingDomain ¶
GetAccountLinkingDomain returns a string that describes the account linking domain. An account linking domain describes a set of Identity entities that _should_ generally fall under the same User entity. It's just a runtime string, and is not typically persisted in the database. This value can vary across time.
func IsDuplicatedPhone ¶
func IsDuplicatedPhone(tx *storage.Connection, phone, aud string) (bool, error)
IsDuplicatedPhone checks if the phone number already exists in the users table
func IsNotFoundError ¶
IsNotFoundError returns whether an error represents a "not found" error.
func Logout ¶
func Logout(tx *storage.Connection, userId uuid.UUID) error
Logout deletes all sessions for a user.
func LogoutAllExceptMe ¶
LogoutAllExceptMe deletes all sessions for a user except the current one
func LogoutSession ¶
func LogoutSession(tx *storage.Connection, sessionId uuid.UUID) error
LogoutSession deletes the current session for a user
func NewAuditLogEntry ¶
func NewAuditLogEntry( r *http.Request, tx *storage.Connection, actor *User, action AuditAction, ipAddress string, traits map[string]interface{}, ) error
func RevokeTokenFamily ¶
func RevokeTokenFamily(tx *storage.Connection, token *RefreshToken) error
RevokeTokenFamily revokes all refresh tokens that descended from the provided token.
func TruncateAll ¶
func TruncateAll(conn *storage.Connection) error
TruncateAll deletes all data from the database, as managed by GoTrue. Not intended for use outside of tests.
Types ¶
type AMRClaim ¶
type AMRClaim struct { ID uuid.UUID `json:"id" db:"id"` SessionID uuid.UUID `json:"session_id" db:"session_id"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` AuthenticationMethod *string `json:"authentication_method" db:"authentication_method"` }
func (*AMRClaim) GetAuthenticationMethod ¶
func (*AMRClaim) IsAAL2Claim ¶
type AMREntry ¶
type AMREntry struct { Method string `json:"method"` Timestamp int64 `json:"timestamp"` Provider string `json:"provider,omitempty"` }
AMREntry represents a method that a user has logged in together with the corresponding time
type AccountLinkingDecision ¶
type AccountLinkingDecision = int
const ( AccountExists AccountLinkingDecision = iota CreateAccount LinkAccount MultipleAccounts )
type AccountLinkingResult ¶
type AccountLinkingResult struct { Decision AccountLinkingDecision User *User Identities []*Identity LinkingDomain string CandidateEmail provider.Email }
func DetermineAccountLinking ¶
func DetermineAccountLinking( tx *storage.Connection, config *conf.GlobalConfiguration, emails []provider.Email, aud, providerName, sub string, ) (AccountLinkingResult, error)
DetermineAccountLinking uses the provided data and database state to compute a decision on whether: - A new User should be created (CreateAccount) - A new Identity should be created (LinkAccount) with a UserID pointing to an existing user account - Nothing should be done (AccountExists) - It's not possible to decide due to data inconsistency (MultipleAccounts) and the caller should decide
Errors signal failure in processing only, like database access errors.
type AuditAction ¶
type AuditAction string
const ( LoginAction AuditAction = "login" LogoutAction AuditAction = "logout" InviteAcceptedAction AuditAction = "invite_accepted" UserSignedUpAction AuditAction = "user_signedup" UserInvitedAction AuditAction = "user_invited" UserDeletedAction AuditAction = "user_deleted" UserModifiedAction AuditAction = "user_modified" UserRecoveryRequestedAction AuditAction = "user_recovery_requested" UserReauthenticateAction AuditAction = "user_reauthenticate_requested" UserConfirmationRequestedAction AuditAction = "user_confirmation_requested" UserRepeatedSignUpAction AuditAction = "user_repeated_signup" UserUpdatePasswordAction AuditAction = "user_updated_password" TokenRevokedAction AuditAction = "token_revoked" TokenRefreshedAction AuditAction = "token_refreshed" GenerateRecoveryCodesAction AuditAction = "generate_recovery_codes" EnrollFactorAction AuditAction = "factor_in_progress" UnenrollFactorAction AuditAction = "factor_unenrolled" CreateChallengeAction AuditAction = "challenge_created" VerifyFactorAction AuditAction = "verification_attempted" DeleteFactorAction AuditAction = "factor_deleted" DeleteRecoveryCodesAction AuditAction = "recovery_codes_deleted" UpdateFactorAction AuditAction = "factor_updated" MFACodeLoginAction AuditAction = "mfa_code_login" IdentityUnlinkAction AuditAction = "identity_unlinked" )
type AuditLogEntry ¶
type AuditLogEntry struct { ID uuid.UUID `json:"id" db:"id"` Payload JSONMap `json:"payload" db:"payload"` CreatedAt time.Time `json:"created_at" db:"created_at"` IPAddress string `json:"ip_address" db:"ip_address"` DONTUSEINSTANCEID uuid.UUID `json:"-" db:"instance_id"` }
AuditLogEntry is the database model for audit log entries.
func FindAuditLogEntries ¶
func FindAuditLogEntries( tx *storage.Connection, filterColumns []string, filterValue string, pageParams *Pagination, ) ([]*AuditLogEntry, error)
func (AuditLogEntry) TableName ¶
func (AuditLogEntry) TableName() string
type AuthenticationMethod ¶
type AuthenticationMethod int
const ( OAuth AuthenticationMethod = iota PasswordGrant OTP TOTPSignIn MFAPhone MFAWebAuthn SSOSAML Recovery Invite MagicLink EmailSignup EmailChange TokenRefresh Anonymous )
func ParseAuthenticationMethod ¶
func ParseAuthenticationMethod(authMethod string) (AuthenticationMethod, error)
func (AuthenticationMethod) String ¶
func (authMethod AuthenticationMethod) String() string
type AuthenticatorAssuranceLevel ¶
type AuthenticatorAssuranceLevel int
const ( AAL1 AuthenticatorAssuranceLevel = iota AAL2 AAL3 )
func (AuthenticatorAssuranceLevel) String ¶
func (aal AuthenticatorAssuranceLevel) String() string
type Challenge ¶
type Challenge struct { ID uuid.UUID `json:"challenge_id" db:"id"` FactorID uuid.UUID `json:"factor_id" db:"factor_id"` CreatedAt time.Time `json:"created_at" db:"created_at"` VerifiedAt *time.Time `json:"verified_at,omitempty" db:"verified_at"` IPAddress string `json:"ip_address" db:"ip_address"` Factor *Factor `json:"factor,omitempty" belongs_to:"factor"` OtpCode string `json:"otp_code,omitempty" db:"otp_code"` WebAuthnSessionData *WebAuthnSessionData `json:"web_authn_session_data,omitempty" db:"web_authn_session_data"` }
func (*Challenge) GetExpiryTime ¶
func (*Challenge) GetOtpCode ¶
func (*Challenge) HasExpired ¶
func (*Challenge) SetOtpCode ¶
type ChallengeNotFoundError ¶
type ChallengeNotFoundError struct{}
ChallengeNotFoundError represents when a user is not found.
func (ChallengeNotFoundError) Error ¶
func (e ChallengeNotFoundError) Error() string
type Cleanup ¶
type Cleanup struct {
// contains filtered or unexported fields
}
func NewCleanup ¶
func NewCleanup(config *conf.GlobalConfiguration) *Cleanup
func (*Cleanup) Clean ¶
func (c *Cleanup) Clean(db *storage.Connection) (int, error)
Cleanup removes stale entities in the database. You can call it on each request or as a periodic background job. It does quick lockless updates or deletes, has an execution timeout and acquire timeout so that cleanups do not affect performance of other database jobs. Note that calling this does not clean up the whole database, but does a small piecemeal clean up each time when called.
type CodeChallengeMethod ¶
type CodeChallengeMethod int
const ( SHA256 CodeChallengeMethod = iota Plain )
func ParseCodeChallengeMethod ¶
func ParseCodeChallengeMethod(codeChallengeMethod string) (CodeChallengeMethod, error)
func (CodeChallengeMethod) String ¶
func (codeChallengeMethod CodeChallengeMethod) String() string
type ConfirmationOrRecoveryTokenNotFoundError ¶
type ConfirmationOrRecoveryTokenNotFoundError struct{}
ConfirmationOrRecoveryTokenNotFoundError represents when a confirmation or recovery token is not found.
func (ConfirmationOrRecoveryTokenNotFoundError) Error ¶
func (e ConfirmationOrRecoveryTokenNotFoundError) Error() string
type ConfirmationTokenNotFoundError ¶
type ConfirmationTokenNotFoundError struct{}
ConfirmationTokenNotFoundError represents when a confirmation token is not found.
func (ConfirmationTokenNotFoundError) Error ¶
func (e ConfirmationTokenNotFoundError) Error() string
type Factor ¶
type Factor struct { ID uuid.UUID `json:"id" db:"id"` // TODO: Consider removing this nested user field. We don't use it. User User `json:"-" belongs_to:"user"` UserID uuid.UUID `json:"-" db:"user_id"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` Status string `json:"status" db:"status"` FriendlyName string `json:"friendly_name,omitempty" db:"friendly_name"` Secret string `json:"-" db:"secret"` FactorType string `json:"factor_type" db:"factor_type"` Challenge []Challenge `json:"-" has_many:"challenges"` Phone storage.NullString `json:"phone" db:"phone"` LastChallengedAt *time.Time `json:"last_challenged_at" db:"last_challenged_at"` WebAuthnCredential *WebAuthnCredential `json:"-" db:"web_authn_credential"` WebAuthnAAGUID *uuid.UUID `json:"web_authn_aaguid,omitempty" db:"web_authn_aaguid"` }
func FindFactorByFactorID ¶
func NewFactor ¶
func NewFactor(user *User, friendlyName string, factorType string, state FactorState) *Factor
func NewPhoneFactor ¶
func NewTOTPFactor ¶
func NewWebAuthnFactor ¶
func (*Factor) CreateChallenge ¶
func (*Factor) CreatePhoneChallenge ¶
func (*Factor) DowngradeSessionsToAAL1 ¶
func (f *Factor) DowngradeSessionsToAAL1(tx *storage.Connection) error
func (*Factor) FindChallengeByID ¶
func (*Factor) FindLatestUnexpiredChallenge ¶
func (*Factor) IsPhoneFactor ¶
func (*Factor) IsUnverified ¶
func (*Factor) IsVerified ¶
func (*Factor) SaveWebAuthnCredential ¶
func (f *Factor) SaveWebAuthnCredential(tx *storage.Connection, credential *webauthn.Credential) error
func (*Factor) UpdateFriendlyName ¶
func (f *Factor) UpdateFriendlyName(tx *storage.Connection, friendlyName string) error
UpdateFriendlyName changes the friendly name
func (*Factor) UpdatePhone ¶
func (f *Factor) UpdatePhone(tx *storage.Connection, phone string) error
func (*Factor) UpdateStatus ¶
func (f *Factor) UpdateStatus(tx *storage.Connection, state FactorState) error
UpdateStatus modifies the factor status
func (*Factor) WriteChallengeToDatabase ¶
func (f *Factor) WriteChallengeToDatabase(tx *storage.Connection, challenge *Challenge) error
type FactorNotFoundError ¶
type FactorNotFoundError struct{}
FactorNotFoundError represents when a user is not found.
func (FactorNotFoundError) Error ¶
func (e FactorNotFoundError) Error() string
type FactorState ¶
type FactorState int
const ( FactorStateUnverified FactorState = iota FactorStateVerified )
func (FactorState) String ¶
func (factorState FactorState) String() string
type FlowState ¶
type FlowState struct { ID uuid.UUID `json:"id" db:"id"` UserID *uuid.UUID `json:"user_id,omitempty" db:"user_id"` AuthCode string `json:"auth_code" db:"auth_code"` AuthenticationMethod string `json:"authentication_method" db:"authentication_method"` CodeChallenge string `json:"code_challenge" db:"code_challenge"` CodeChallengeMethod string `json:"code_challenge_method" db:"code_challenge_method"` ProviderType string `json:"provider_type" db:"provider_type"` ProviderAccessToken string `json:"provider_access_token" db:"provider_access_token"` ProviderRefreshToken string `json:"provider_refresh_token" db:"provider_refresh_token"` AuthCodeIssuedAt *time.Time `json:"auth_code_issued_at" db:"auth_code_issued_at"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
func FindFlowStateByAuthCode ¶
func FindFlowStateByAuthCode(tx *storage.Connection, authCode string) (*FlowState, error)
func FindFlowStateByID ¶
func FindFlowStateByID(tx *storage.Connection, id string) (*FlowState, error)
func FindFlowStateByUserID ¶
func FindFlowStateByUserID(tx *storage.Connection, id string, authenticationMethod AuthenticationMethod) (*FlowState, error)
func NewFlowState ¶
func NewFlowState(providerType, codeChallenge string, codeChallengeMethod CodeChallengeMethod, authenticationMethod AuthenticationMethod, userID *uuid.UUID) *FlowState
func (*FlowState) RecordAuthCodeIssuedAtTime ¶
func (f *FlowState) RecordAuthCodeIssuedAtTime(tx *storage.Connection) error
func (*FlowState) VerifyPKCE ¶
type FlowStateNotFoundError ¶
type FlowStateNotFoundError struct{}
FlowStateNotFoundError represents an error when an FlowState can't be found.
func (FlowStateNotFoundError) Error ¶
func (e FlowStateNotFoundError) Error() string
type GrantParams ¶
type GrantParams struct { FactorID *uuid.UUID SessionNotAfter *time.Time SessionTag *string UserAgent string IP string }
GrantParams is used to pass session-specific parameters when issuing a new refresh token to authenticated users.
func (*GrantParams) FillGrantParams ¶
func (g *GrantParams) FillGrantParams(r *http.Request)
type Identity ¶
type Identity struct { // returned as identity_id in JSON for backward compatibility with the interface exposed by the client library // see https://github.com/supabase/gotrue-js/blob/c9296bbc27a2f036af55c1f33fca5930704bd021/src/lib/types.ts#L230-L240 ID uuid.UUID `json:"identity_id" db:"id"` // returned as id in JSON for backward compatibility with the interface exposed by the client library // see https://github.com/supabase/gotrue-js/blob/c9296bbc27a2f036af55c1f33fca5930704bd021/src/lib/types.ts#L230-L240 ProviderID string `json:"id" db:"provider_id"` UserID uuid.UUID `json:"user_id" db:"user_id"` IdentityData JSONMap `json:"identity_data,omitempty" db:"identity_data"` Provider string `json:"provider" db:"provider"` LastSignInAt *time.Time `json:"last_sign_in_at,omitempty" db:"last_sign_in_at"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` Email storage.NullString `json:"email,omitempty" db:"email" rw:"r"` }
func FindIdentitiesByUserID ¶
FindIdentitiesByUserID returns all identities associated to a user ID.
func FindIdentityByIdAndProvider ¶
func FindIdentityByIdAndProvider( tx *storage.Connection, providerId, provider string, ) (*Identity, error)
FindIdentityById searches for an identity with the matching id and provider given.
func NewIdentity ¶
func NewIdentity( user *User, provider string, identityData map[string]interface{}, ) (*Identity, error)
NewIdentity returns an identity associated to the user's id.
func (*Identity) BeforeCreate ¶
func (*Identity) BeforeUpdate ¶
func (*Identity) IsForSSOProvider ¶
func (*Identity) UpdateIdentityData ¶
func (i *Identity) UpdateIdentityData( tx *storage.Connection, updates map[string]interface{}, ) error
UpdateIdentityData sets all identity_data from a map of updates, ensuring that it doesn't override attributes that are not in the provided map.
type IdentityNotFoundError ¶
type IdentityNotFoundError struct{}
IdentityNotFoundError represents when an identity is not found.
func (IdentityNotFoundError) Error ¶
func (e IdentityNotFoundError) Error() string
type OneTimeToken ¶
type OneTimeToken struct { ID uuid.UUID `json:"id" db:"id"` UserID uuid.UUID `json:"user_id" db:"user_id"` TokenType OneTimeTokenType `json:"token_type" db:"token_type"` TokenHash string `json:"token_hash" db:"token_hash"` RelatesTo string `json:"relates_to" db:"relates_to"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
func FindOneTimeToken ¶
func FindOneTimeToken( tx *storage.Connection, tokenHash string, tokenTypes ...OneTimeTokenType, ) (*OneTimeToken, error)
func (OneTimeToken) TableName ¶
func (OneTimeToken) TableName() string
type OneTimeTokenNotFoundError ¶
type OneTimeTokenNotFoundError struct { }
func (OneTimeTokenNotFoundError) Error ¶
func (e OneTimeTokenNotFoundError) Error() string
type OneTimeTokenType ¶
type OneTimeTokenType int
const ( ConfirmationToken OneTimeTokenType = iota ReauthenticationToken RecoveryToken EmailChangeTokenNew EmailChangeTokenCurrent PhoneChangeToken )
func ParseOneTimeTokenType ¶
func ParseOneTimeTokenType(s string) (OneTimeTokenType, error)
func (*OneTimeTokenType) Scan ¶
func (t *OneTimeTokenType) Scan(src interface{}) error
func (OneTimeTokenType) String ¶
func (t OneTimeTokenType) String() string
type Pagination ¶
func (*Pagination) Offset ¶
func (p *Pagination) Offset() uint64
type RefreshToken ¶
type RefreshToken struct { ID int64 `db:"id"` Token string `db:"token"` UserID uuid.UUID `db:"user_id"` Parent storage.NullString `db:"parent"` SessionId *uuid.UUID `db:"session_id"` Revoked bool `db:"revoked"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` DONTUSEINSTANCEID uuid.UUID `json:"-" db:"instance_id"` }
RefreshToken is the database model for refresh tokens.
func FindTokenBySessionID ¶
func FindTokenBySessionID(tx *storage.Connection, sessionId *uuid.UUID) (*RefreshToken, error)
func GrantAuthenticatedUser ¶
func GrantAuthenticatedUser( tx *storage.Connection, user *User, params GrantParams, ) (*RefreshToken, error)
GrantAuthenticatedUser creates a refresh token for the provided user.
func GrantRefreshTokenSwap ¶
func GrantRefreshTokenSwap( r *http.Request, tx *storage.Connection, user *User, token *RefreshToken, ) (*RefreshToken, error)
GrantRefreshTokenSwap swaps a refresh token for a new one, revoking the provided token.
func (RefreshToken) TableName ¶
func (RefreshToken) TableName() string
type RefreshTokenNotFoundError ¶
type RefreshTokenNotFoundError struct{}
RefreshTokenNotFoundError represents when a refresh token is not found.
func (RefreshTokenNotFoundError) Error ¶
func (e RefreshTokenNotFoundError) Error() string
type SAMLAttribute ¶
type SAMLAttributeMapping ¶
type SAMLAttributeMapping struct {
Keys map[string]SAMLAttribute `json:"keys,omitempty"`
}
func (*SAMLAttributeMapping) Equal ¶
func (m *SAMLAttributeMapping) Equal(o *SAMLAttributeMapping) bool
func (*SAMLAttributeMapping) Scan ¶
func (m *SAMLAttributeMapping) Scan(src interface{}) error
type SAMLProvider ¶
type SAMLProvider struct { ID uuid.UUID `db:"id" json:"-"` SSOProvider *SSOProvider `belongs_to:"sso_providers" json:"-"` SSOProviderID uuid.UUID ` json:"-" db:"sso_provider_id"` EntityID string `db:"entity_id" json:"entity_id"` MetadataXML string `db:"metadata_xml" json:"metadata_xml,omitempty"` MetadataURL *string `db:"metadata_url" json:"metadata_url,omitempty"` AttributeMapping SAMLAttributeMapping `db:"attribute_mapping" json:"attribute_mapping,omitempty"` NameIDFormat *string `db:"name_id_format" json:"name_id_format,omitempty"` CreatedAt time.Time `db:"created_at" json:"-"` UpdatedAt time.Time `db:"updated_at" json:"-"` }
func (SAMLProvider) EntityDescriptor ¶
func (p SAMLProvider) EntityDescriptor() (*saml.EntityDescriptor, error)
func (SAMLProvider) TableName ¶
func (p SAMLProvider) TableName() string
type SAMLRelayState ¶
type SAMLRelayState struct { ID uuid.UUID `db:"id"` SSOProviderID uuid.UUID `db:"sso_provider_id"` RequestID string `db:"request_id"` ForEmail *string `db:"for_email"` RedirectTo string `db:"redirect_to"` CreatedAt time.Time `db:"created_at" json:"-"` UpdatedAt time.Time `db:"updated_at" json:"-"` FlowStateID *uuid.UUID `db:"flow_state_id" json:"flow_state_id,omitempty"` FlowState *FlowState `db:"-" json:"flow_state,omitempty" belongs_to:"flow_state"` }
func FindSAMLRelayStateByID ¶
func FindSAMLRelayStateByID(tx *storage.Connection, id uuid.UUID) (*SAMLRelayState, error)
func (SAMLRelayState) TableName ¶
func (s SAMLRelayState) TableName() string
type SAMLRelayStateNotFoundError ¶
type SAMLRelayStateNotFoundError struct{}
SAMLRelayStateNotFoundError represents an error when a SAML relay state can't be found.
func (SAMLRelayStateNotFoundError) Error ¶
func (e SAMLRelayStateNotFoundError) Error() string
type SSODomain ¶
type SSODomain struct { ID uuid.UUID `db:"id" json:"-"` SSOProvider *SSOProvider `belongs_to:"sso_providers" json:"-"` SSOProviderID uuid.UUID ` json:"-" db:"sso_provider_id"` Domain string `db:"domain" json:"domain"` CreatedAt time.Time `db:"created_at" json:"-"` UpdatedAt time.Time `db:"updated_at" json:"-"` }
type SSOProvider ¶
type SSOProvider struct { ID uuid.UUID `db:"id" json:"id"` SAMLProvider SAMLProvider `has_one:"saml_providers" fk_id:"sso_provider_id" json:"saml,omitempty"` SSODomains []SSODomain ` fk_id:"sso_provider_id" json:"domains" has_many:"sso_domains"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
func FindAllSAMLProviders ¶
func FindAllSAMLProviders(tx *storage.Connection) ([]SSOProvider, error)
func FindSAMLProviderByEntityID ¶
func FindSAMLProviderByEntityID(tx *storage.Connection, entityId string) (*SSOProvider, error)
func FindSSOProviderByDomain ¶
func FindSSOProviderByDomain(tx *storage.Connection, domain string) (*SSOProvider, error)
func FindSSOProviderByID ¶
func FindSSOProviderByID(tx *storage.Connection, id uuid.UUID) (*SSOProvider, error)
func FindSSOProviderForEmailAddress ¶
func FindSSOProviderForEmailAddress( tx *storage.Connection, emailAddress string, ) (*SSOProvider, error)
func (SSOProvider) TableName ¶
func (p SSOProvider) TableName() string
func (SSOProvider) Type ¶
func (p SSOProvider) Type() string
type SSOProviderNotFoundError ¶
type SSOProviderNotFoundError struct{}
SSOProviderNotFoundError represents an error when a SSO Provider can't be found.
func (SSOProviderNotFoundError) Error ¶
func (e SSOProviderNotFoundError) Error() string
type Session ¶
type Session struct { ID uuid.UUID `json:"-" db:"id"` UserID uuid.UUID `json:"user_id" db:"user_id"` // NotAfter is overriden by timeboxed sessions. NotAfter *time.Time `json:"not_after,omitempty" db:"not_after"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` FactorID *uuid.UUID `json:"factor_id" db:"factor_id"` AMRClaims []AMRClaim `json:"amr,omitempty" has_many:"amr_claims"` AAL *string `json:"aal" db:"aal"` RefreshedAt *time.Time `json:"refreshed_at,omitempty" db:"refreshed_at"` UserAgent *string `json:"user_agent,omitempty" db:"user_agent"` IP *string `json:"ip,omitempty" db:"ip"` Tag *string `json:"tag" db:"tag"` }
func FindAllSessionsForUser ¶
func FindAllSessionsForUser(tx *storage.Connection, userId uuid.UUID, forUpdate bool) ([]*Session, error)
FindAllSessionsForUser finds all of the sessions for a user. If forUpdate is set, it will first lock on the user row which can be used to prevent issues with concurrency. If the lock is acquired, it will return a UserNotFoundError and the operation should be retried. If there are no sessions for the user, a nil result is returned without an error.
func FindSessionByID ¶
FindSessionByID looks up a Session by the provided id. If forUpdate is set to true, then the SELECT statement used by the query has the form SELECT ... FOR UPDATE SKIP LOCKED. This means that a FOR UPDATE lock will only be acquired if there's no other lock. In case there is a lock, a IsNotFound(err) error will be retured.
func FindSessionByUserID ¶
func FindSessionsByFactorID ¶
func (*Session) CalculateAALAndAMR ¶
func (s *Session) CalculateAALAndAMR(user *User) (aal AuthenticatorAssuranceLevel, amr []AMREntry, err error)
func (*Session) CheckValidity ¶
func (*Session) DetermineTag ¶
func (*Session) FindCurrentlyActiveRefreshToken ¶
func (s *Session) FindCurrentlyActiveRefreshToken(tx *storage.Connection) (*RefreshToken, error)
FindCurrentlyActiveRefreshToken returns the currently active refresh token in the session. This is the last created (ordered by the serial primary key) non-revoked refresh token for the session.
func (*Session) LastRefreshedAt ¶
func (*Session) UpdateAALAndAssociatedFactor ¶
func (s *Session) UpdateAALAndAssociatedFactor(tx *storage.Connection, aal AuthenticatorAssuranceLevel, factorID *uuid.UUID) error
func (*Session) UpdateOnlyRefreshInfo ¶
func (s *Session) UpdateOnlyRefreshInfo(tx *storage.Connection) error
type SessionNotFoundError ¶
type SessionNotFoundError struct{}
func (SessionNotFoundError) Error ¶
func (e SessionNotFoundError) Error() string
type SessionValidityReason ¶
type SessionValidityReason = int
type SortDirection ¶
type SortDirection string
const Ascending SortDirection = "ASC"
const Descending SortDirection = "DESC"
type SortField ¶
type SortField struct { Name string Dir SortDirection }
type SortParams ¶
type SortParams struct {
Fields []SortField
}
type User ¶
type User struct { ID uuid.UUID `json:"id" db:"id"` Aud string `json:"aud" db:"aud"` Role string `json:"role" db:"role"` Email storage.NullString `json:"email" db:"email"` IsSSOUser bool `json:"-" db:"is_sso_user"` EncryptedPassword *string `json:"-" db:"encrypted_password"` EmailConfirmedAt *time.Time `json:"email_confirmed_at,omitempty" db:"email_confirmed_at"` InvitedAt *time.Time `json:"invited_at,omitempty" db:"invited_at"` Phone storage.NullString `json:"phone" db:"phone"` PhoneConfirmedAt *time.Time `json:"phone_confirmed_at,omitempty" db:"phone_confirmed_at"` ConfirmationToken string `json:"-" db:"confirmation_token"` ConfirmationSentAt *time.Time `json:"confirmation_sent_at,omitempty" db:"confirmation_sent_at"` // For backward compatibility only. Use EmailConfirmedAt or PhoneConfirmedAt instead. ConfirmedAt *time.Time `json:"confirmed_at,omitempty" db:"confirmed_at" rw:"r"` RecoveryToken string `json:"-" db:"recovery_token"` RecoverySentAt *time.Time `json:"recovery_sent_at,omitempty" db:"recovery_sent_at"` EmailChangeTokenCurrent string `json:"-" db:"email_change_token_current"` EmailChangeTokenNew string `json:"-" db:"email_change_token_new"` EmailChange string `json:"new_email,omitempty" db:"email_change"` EmailChangeSentAt *time.Time `json:"email_change_sent_at,omitempty" db:"email_change_sent_at"` EmailChangeConfirmStatus int `json:"-" db:"email_change_confirm_status"` PhoneChangeToken string `json:"-" db:"phone_change_token"` PhoneChange string `json:"new_phone,omitempty" db:"phone_change"` PhoneChangeSentAt *time.Time `json:"phone_change_sent_at,omitempty" db:"phone_change_sent_at"` ReauthenticationToken string `json:"-" db:"reauthentication_token"` ReauthenticationSentAt *time.Time `json:"reauthentication_sent_at,omitempty" db:"reauthentication_sent_at"` LastSignInAt *time.Time `json:"last_sign_in_at,omitempty" db:"last_sign_in_at"` AppMetaData JSONMap `json:"app_metadata" db:"raw_app_meta_data"` UserMetaData JSONMap `json:"user_metadata" db:"raw_user_meta_data"` Factors []Factor `json:"factors,omitempty" has_many:"factors"` Identities []Identity `json:"identities" has_many:"identities"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` BannedUntil *time.Time `json:"banned_until,omitempty" db:"banned_until"` DeletedAt *time.Time `json:"deleted_at,omitempty" db:"deleted_at"` IsAnonymous bool `json:"is_anonymous" db:"is_anonymous"` DONTUSEINSTANCEID uuid.UUID `json:"-" db:"instance_id"` }
User respresents a registered user with email/password authentication
func FindUserByConfirmationOrRecoveryToken ¶
func FindUserByConfirmationOrRecoveryToken(tx *storage.Connection, token string) (*User, error)
FindUserByConfirmationToken finds users with the matching confirmation token.
func FindUserByConfirmationToken ¶
func FindUserByConfirmationToken(tx *storage.Connection, token string) (*User, error)
FindUserByConfirmationToken finds users with the matching confirmation token.
func FindUserByEmailAndAudience ¶
func FindUserByEmailAndAudience(tx *storage.Connection, email, aud string) (*User, error)
FindUserByEmailAndAudience finds a user with the matching email and audience.
func FindUserByEmailChangeCurrentAndAudience ¶
func FindUserByEmailChangeCurrentAndAudience( tx *storage.Connection, email, token, aud string, ) (*User, error)
FindUserByEmailChangeCurrentAndAudience finds a user with the matching email change and audience.
func FindUserByEmailChangeNewAndAudience ¶
func FindUserByEmailChangeNewAndAudience( tx *storage.Connection, email, token, aud string, ) (*User, error)
FindUserByEmailChangeNewAndAudience finds a user with the matching email change and audience.
func FindUserByEmailChangeToken ¶
func FindUserByEmailChangeToken(tx *storage.Connection, token string) (*User, error)
FindUserByEmailChangeToken finds a user with the matching email change token.
func FindUserByID ¶
FindUserByID finds a user matching the provided ID.
func FindUserByPhoneAndAudience ¶
func FindUserByPhoneAndAudience(tx *storage.Connection, phone, aud string) (*User, error)
FindUserByPhoneAndAudience finds a user with the matching email and audience.
func FindUserByPhoneChangeAndAudience ¶
func FindUserByPhoneChangeAndAudience(tx *storage.Connection, phone, aud string) (*User, error)
FindUserByPhoneChangeAndAudience finds a user with the matching phone change and audience.
func FindUserByRecoveryToken ¶
func FindUserByRecoveryToken(tx *storage.Connection, token string) (*User, error)
FindUserByRecoveryToken finds a user with the matching recovery token.
func FindUserForEmailChange ¶
func FindUserForEmailChange( tx *storage.Connection, email, token, aud string, secureEmailChangeEnabled bool, ) (*User, error)
FindUserForEmailChange finds a user requesting for an email change
func FindUsersInAudience ¶
func FindUsersInAudience( tx *storage.Connection, aud string, pageParams *Pagination, sortParams *SortParams, filter string, ) ([]*User, error)
FindUsersInAudience finds users with the matching audience.
func IsDuplicatedEmail ¶
func IsDuplicatedEmail( tx *storage.Connection, email, aud string, currentUser *User, ) (*User, error)
IsDuplicatedEmail returns whether a user exists with a matching email and audience. If a currentUser is provided, we will need to filter out any identities that belong to the current user.
func NewUserWithPasswordHash ¶
func (*User) Authenticate ¶
func (u *User) Authenticate( ctx context.Context, tx *storage.Connection, password string, decryptionKeys map[string]string, encrypt bool, encryptionKeyID string, ) (bool, bool, error)
Authenticate a user from a password
func (*User) BeforeSave ¶
BeforeSave is invoked before the user is saved to the database
func (*User) Confirm ¶
func (u *User) Confirm(tx *storage.Connection) error
Confirm resets the confimation token and sets the confirm timestamp
func (*User) ConfirmEmailChange ¶
func (u *User) ConfirmEmailChange(tx *storage.Connection, status int) error
ConfirmEmailChange confirm the change of email for a user
func (*User) ConfirmPhone ¶
func (u *User) ConfirmPhone(tx *storage.Connection) error
ConfirmPhone resets the confimation token and sets the confirm timestamp
func (*User) ConfirmPhoneChange ¶
func (u *User) ConfirmPhoneChange(tx *storage.Connection) error
ConfirmPhoneChange confirms the change of phone for a user
func (*User) ConfirmReauthentication ¶
func (u *User) ConfirmReauthentication(tx *storage.Connection) error
ConfirmReauthentication resets the reauthentication token
func (*User) FindOwnedFactorByID ¶
func (*User) HasBeenInvited ¶
HasBeenInvited checks if user has been invited
func (*User) HasMFAEnabled ¶
func (*User) HasPassword ¶
func (*User) IsConfirmed ¶
IsConfirmed checks if a user has already been registered and confirmed.
func (*User) IsPhoneConfirmed ¶
IsPhoneConfirmed checks if a user's phone has already been registered and confirmed.
func (*User) Recover ¶
func (u *User) Recover(tx *storage.Connection) error
Recover resets the recovery token
func (*User) RemoveUnconfirmedIdentities ¶
func (u *User) RemoveUnconfirmedIdentities(tx *storage.Connection, identity *Identity) error
RemoveUnconfirmedIdentities removes potentially malicious unconfirmed identities from a user (if any)
func (*User) SetEmail ¶
func (u *User) SetEmail(tx *storage.Connection, email string) error
SetEmail sets the user's email
func (*User) SetPassword ¶
func (*User) SetPhone ¶
func (u *User) SetPhone(tx *storage.Connection, phone string) error
SetPhone sets the user's phone
func (*User) SetRole ¶
func (u *User) SetRole(tx *storage.Connection, roleName string) error
SetRole sets the users Role to roleName
func (*User) SoftDeleteUser ¶
func (u *User) SoftDeleteUser(tx *storage.Connection) error
SoftDeleteUser performs a soft deletion on the user by obfuscating and clearing certain fields
func (*User) SoftDeleteUserIdentities ¶
func (u *User) SoftDeleteUserIdentities(tx *storage.Connection) error
SoftDeleteUserIdentities performs a soft deletion on all identities associated to a user
func (*User) UpdateAppMetaData ¶
func (u *User) UpdateAppMetaData(tx *storage.Connection, updates map[string]interface{}) error
UpdateAppMetaData updates all app data from a map of updates
func (*User) UpdateAppMetaDataProviders ¶
func (u *User) UpdateAppMetaDataProviders(tx *storage.Connection) error
UpdateAppMetaDataProviders updates the provider field in AppMetaData column
func (*User) UpdateBannedUntil ¶
func (u *User) UpdateBannedUntil(tx *storage.Connection) error
func (*User) UpdateLastSignInAt ¶
func (u *User) UpdateLastSignInAt(tx *storage.Connection) error
UpdateLastSignInAt update field last_sign_in_at for user according to specified field
func (*User) UpdatePassword ¶
UpdatePassword updates the user's password. Use SetPassword outside of a transaction first!
func (*User) UpdateUserEmailFromIdentities ¶
func (u *User) UpdateUserEmailFromIdentities(tx *storage.Connection) error
UpdateUserEmail updates the user's email to one of the identity's email if the current email used doesn't match any of the identities email
func (*User) UpdateUserMetaData ¶
func (u *User) UpdateUserMetaData(tx *storage.Connection, updates map[string]interface{}) error
UpdateUserMetaData sets all user data from a map of updates, ensuring that it doesn't override attributes that are not in the provided map.
func (*User) WebAuthnCredentials ¶
func (user *User) WebAuthnCredentials() []webauthn.Credential
func (*User) WebAuthnDisplayName ¶
func (*User) WebAuthnID ¶
func (*User) WebAuthnName ¶
type UserEmailUniqueConflictError ¶
type UserEmailUniqueConflictError struct{}
func (UserEmailUniqueConflictError) Error ¶
func (e UserEmailUniqueConflictError) Error() string
type UserNotFoundError ¶
type UserNotFoundError struct{}
UserNotFoundError represents when a user is not found.
func (UserNotFoundError) Error ¶
func (e UserNotFoundError) Error() string
type WebAuthnCredential ¶
type WebAuthnCredential struct {
webauthn.Credential
}
func (*WebAuthnCredential) Scan ¶
func (wc *WebAuthnCredential) Scan(value interface{}) error
type WebAuthnSessionData ¶
type WebAuthnSessionData struct {
*webauthn.SessionData
}
func (*WebAuthnSessionData) Scan ¶
func (s *WebAuthnSessionData) Scan(value interface{}) error
func (*WebAuthnSessionData) ToChallenge ¶
func (ws *WebAuthnSessionData) ToChallenge(factorID uuid.UUID, ipAddress string) *Challenge