Versions in this module Expand all Collapse all v0 v0.0.4 Nov 10, 2024 v0.0.3 Oct 13, 2024 v0.0.2 Oct 13, 2024 v0.0.1 Oct 13, 2024 Changes in this version + const APIVersionHeaderName + const DefaultHTTPHookRetries + const DefaultHTTPHookTimeout + const DefaultQRSize + const HTTPHookBackoffDuration + const InvalidChannelError + const InvalidLoginMessage + const InvalidNonceMessage + const InvalidPKCEParamsErrorMessage + const MaxCodeChallengeLength + const MaxPasswordLength + const MinCodeChallengeLength + const PKCEPrefix + const PayloadLimit + const QRCodeGenerationErrorMessage + const SAMLSubjectIDAttributeName + var APIVersion20240101 = time.Date(2024, time.January, 1, 0, 0, 0, 0, time.UTC) + var APIVersionInitial = time.Time + var AddressNotAuthorized error = errors.New("Destination email address not authorized") + var DuplicateEmailMsg = "A user with this email address has already been registered" + var DuplicatePhoneMsg = "A user with this phone number has already been registered" + var EmailRateLimitExceeded error = errors.New("email rate limit exceeded") + var UserExistsError error = errors.New("user already exists") + func FormatAPIVersion(apiVersion APIVersion) string + func HandleResponseError(err error, w http.ResponseWriter, r *http.Request) + func IsSAMLMetadataStale(idpMetadata *saml.EntityDescriptor, samlProvider models.SAMLProvider) bool + type API struct + func NewAPI(globalConfig *conf.GlobalConfiguration, db *storage.Connection, opt ...Option) *API + func NewAPIWithVersion(globalConfig *conf.GlobalConfiguration, db *storage.Connection, version string, ...) *API + func NewAPIWithVersionAndLogger(globalConfig *conf.GlobalConfiguration, db *storage.Connection, version string, ...) (*API, http.Handler) + func (a *API) ChallengeFactor(w http.ResponseWriter, r *http.Request) error + func (a *API) DeleteIdentity(w http.ResponseWriter, r *http.Request) error + func (a *API) EnrollFactor(w http.ResponseWriter, r *http.Request) error + func (a *API) ExternalProviderCallback(w http.ResponseWriter, r *http.Request) error + func (a *API) ExternalProviderRedirect(w http.ResponseWriter, r *http.Request) error + func (a *API) GetExternalProviderRedirectURL(w http.ResponseWriter, r *http.Request, linkingTargetUser *models.User) (string, error) + func (a *API) HealthCheck(w http.ResponseWriter, r *http.Request) error + func (a *API) IdTokenGrant(ctx context.Context, w http.ResponseWriter, r *http.Request) error + func (a *API) Invite(w http.ResponseWriter, r *http.Request) error + func (a *API) Jwks(w http.ResponseWriter, r *http.Request) error + func (a *API) LinkIdentity(w http.ResponseWriter, r *http.Request) error + func (a *API) Logout(w http.ResponseWriter, r *http.Request) error + func (a *API) MagicLink(w http.ResponseWriter, r *http.Request) error + func (a *API) Mailer() mailer.Mailer + func (a *API) Now() time.Time + func (a *API) OAuthProvider(ctx context.Context, name string) (provider.OAuthProvider, error) + func (a *API) Otp(w http.ResponseWriter, r *http.Request) error + func (a *API) PKCE(ctx context.Context, w http.ResponseWriter, r *http.Request) error + func (a *API) Provider(ctx context.Context, name string, scopes string) (provider.Provider, error) + func (a *API) Reauthenticate(w http.ResponseWriter, r *http.Request) error + func (a *API) Recover(w http.ResponseWriter, r *http.Request) error + func (a *API) RefreshTokenGrant(ctx context.Context, w http.ResponseWriter, r *http.Request) error + func (a *API) Resend(w http.ResponseWriter, r *http.Request) error + func (a *API) ResourceOwnerPasswordGrant(ctx context.Context, w http.ResponseWriter, r *http.Request) error + func (a *API) SAMLMetadata(w http.ResponseWriter, r *http.Request) error + func (a *API) SamlAcs(w http.ResponseWriter, r *http.Request) error + func (a *API) ServeHTTP(w http.ResponseWriter, r *http.Request) + func (a *API) Settings(w http.ResponseWriter, r *http.Request) error + func (a *API) Signup(w http.ResponseWriter, r *http.Request) error + func (a *API) SignupAnonymously(w http.ResponseWriter, r *http.Request) error + func (a *API) SingleSignOn(w http.ResponseWriter, r *http.Request) error + func (a *API) SmsOtp(w http.ResponseWriter, r *http.Request) error + func (a *API) Token(w http.ResponseWriter, r *http.Request) error + func (a *API) UnenrollFactor(w http.ResponseWriter, r *http.Request) error + func (a *API) UserGet(w http.ResponseWriter, r *http.Request) error + func (a *API) UserUpdate(w http.ResponseWriter, r *http.Request) error + func (a *API) Verify(w http.ResponseWriter, r *http.Request) error + func (a *API) VerifyFactor(w http.ResponseWriter, r *http.Request) error + type APIVersion = time.Time + func DetermineClosestAPIVersion(date string) (APIVersion, error) + type AccessTokenClaims struct + AppMetaData map[string]interface{} + AuthenticationMethodReference []models.AMREntry + AuthenticatorAssuranceLevel string + Email string + IsAnonymous bool + Phone string + Role string + SessionId string + UserMetaData map[string]interface{} + type AccessTokenResponse struct + ExpiresAt int64 + ExpiresIn int + ProviderAccessToken string + ProviderRefreshToken string + RefreshToken string + Token string + TokenType string + User *models.User + WeakPassword *WeakPasswordError + func (r *AccessTokenResponse) AsRedirectURL(redirectURL string, extraParams url.Values) string + type AdminListUsersResponse struct + Aud string + Users []*models.User + type AdminUserParams struct + AppMetaData map[string]interface{} + Aud string + BanDuration string + Email string + EmailConfirm bool + Id string + Password *string + PasswordHash string + Phone string + PhoneConfirm bool + Role string + UserMetaData map[string]interface{} + type AuthMicroserviceClaims struct + FunctionHooks FunctionHooks + InstanceID string + SiteURL string + type ChallengeFactorParams struct + Channel string + WebAuthn *WebAuthnParams + type ChallengeFactorResponse struct + CredentialCreationOptions *wbnprotocol.CredentialCreation + CredentialRequestOptions *wbnprotocol.CredentialAssertion + ExpiresAt int64 + ID uuid.UUID + Type string + type CreateSSOProviderParams struct + AttributeMapping models.SAMLAttributeMapping + Domains []string + MetadataURL string + MetadataXML string + NameIDFormat string + Type string + type EnrollFactorParams struct + FactorType string + FriendlyName string + Issuer string + Phone string + type EnrollFactorResponse struct + FriendlyName string + ID uuid.UUID + Phone string + TOTP *TOTPObject + Type string + type ErrorCause interface + Cause func() error + type ErrorCode = string + const ErrorBadCodeVerifier + const ErrorCodeAnonymousProviderDisabled + const ErrorCodeBadJSON + const ErrorCodeBadJWT + const ErrorCodeBadOAuthCallback + const ErrorCodeBadOAuthState + const ErrorCodeCaptchaFailed + const ErrorCodeConflict + const ErrorCodeEmailAddressNotAuthorized + const ErrorCodeEmailConflictIdentityNotDeletable + const ErrorCodeEmailExists + const ErrorCodeEmailNotConfirmed + const ErrorCodeEmailProviderDisabled + const ErrorCodeFlowStateExpired + const ErrorCodeFlowStateNotFound + const ErrorCodeHookPayloadInvalidContentType + const ErrorCodeHookPayloadOverSizeLimit + const ErrorCodeHookTimeout + const ErrorCodeHookTimeoutAfterRetry + const ErrorCodeIdentityAlreadyExists + const ErrorCodeIdentityNotFound + const ErrorCodeInsufficientAAL + const ErrorCodeInvalidCredentials + const ErrorCodeInviteNotFound + const ErrorCodeMFAChallengeExpired + const ErrorCodeMFAFactorNameConflict + const ErrorCodeMFAFactorNotFound + const ErrorCodeMFAIPAddressMismatch + const ErrorCodeMFAPhoneEnrollDisabled + const ErrorCodeMFAPhoneVerifyDisabled + const ErrorCodeMFATOTPEnrollDisabled + const ErrorCodeMFATOTPVerifyDisabled + const ErrorCodeMFAVerificationFailed + const ErrorCodeMFAVerificationRejected + const ErrorCodeMFAVerifiedFactorExists + const ErrorCodeMFAWebAuthnEnrollDisabled + const ErrorCodeMFAWebAuthnVerifyDisabled + const ErrorCodeManualLinkingDisabled + const ErrorCodeNoAuthorization + const ErrorCodeNotAdmin + const ErrorCodeOAuthProviderNotSupported + const ErrorCodeOTPDisabled + const ErrorCodeOTPExpired + const ErrorCodeOverEmailSendRateLimit + const ErrorCodeOverRequestRateLimit + const ErrorCodeOverSMSSendRateLimit + const ErrorCodePhoneExists + const ErrorCodePhoneNotConfirmed + const ErrorCodePhoneProviderDisabled + const ErrorCodeProviderDisabled + const ErrorCodeProviderEmailNeedsVerification + const ErrorCodeReauthenticationNeeded + const ErrorCodeReauthenticationNotValid + const ErrorCodeRequestTimeout + const ErrorCodeSAMLAssertionNoEmail + const ErrorCodeSAMLAssertionNoUserID + const ErrorCodeSAMLEntityIDMismatch + const ErrorCodeSAMLIdPAlreadyExists + const ErrorCodeSAMLIdPNotFound + const ErrorCodeSAMLMetadataFetchFailed + const ErrorCodeSAMLProviderDisabled + const ErrorCodeSAMLRelayStateExpired + const ErrorCodeSAMLRelayStateNotFound + const ErrorCodeSMSSendFailed + const ErrorCodeSSODomainAlreadyExists + const ErrorCodeSSOProviderNotFound + const ErrorCodeSamePassword + const ErrorCodeSessionNotFound + const ErrorCodeSignupDisabled + const ErrorCodeSingleIdentityNotDeletable + const ErrorCodeTooManyEnrolledMFAFactors + const ErrorCodeUnexpectedAudience + const ErrorCodeUnexpectedFailure + const ErrorCodeUnknown + const ErrorCodeUserAlreadyExists + const ErrorCodeUserBanned + const ErrorCodeUserNotFound + const ErrorCodeUserSSOManaged + const ErrorCodeValidationFailed + const ErrorCodeWeakPassword + type ExternalProviderClaims struct + FlowStateID string + InviteToken string + LinkingTargetID string + Provider string + Referrer string + type FunctionHooks map[string][]string + func (f *FunctionHooks) UnmarshalJSON(b []byte) error + type GenerateLinkParams struct + Data map[string]interface{} + Email string + NewEmail string + Password string + RedirectTo string + Type string + type GenerateLinkResponse struct + ActionLink string + EmailOtp string + HashedToken string + RedirectTo string + VerificationType string + type HTTPError struct + ErrorCode string + ErrorID string + HTTPStatus int + InternalError error + InternalMessage string + Message string + func (e *HTTPError) Cause() error + func (e *HTTPError) Error() string + func (e *HTTPError) Is(target error) bool + func (e *HTTPError) WithInternalError(err error) *HTTPError + func (e *HTTPError) WithInternalMessage(fmtString string, args ...interface{}) *HTTPError + type HTTPErrorResponse20240101 struct + Code ErrorCode + Message string + type HealthCheckResponse struct + Description string + Name string + Version string + type IdTokenGrantParams struct + AccessToken string + ClientID string + IdToken string + Issuer string + Nonce string + Provider string + type InviteParams struct + Data map[string]interface{} + Email string + type JwksResponse struct + Keys []jwk.Key + type LimiterOptions struct + AnonymousSignIns *limiter.Limiter + Email *limiter.Limiter + FactorChallenge *limiter.Limiter + FactorVerify *limiter.Limiter + MagicLink *limiter.Limiter + Otp *limiter.Limiter + Phone *limiter.Limiter + Recover *limiter.Limiter + Resend *limiter.Limiter + SAMLAssertion *limiter.Limiter + SSO *limiter.Limiter + Signups *limiter.Limiter + Token *limiter.Limiter + User *limiter.Limiter + Verify *limiter.Limiter + func NewLimiterOptions(gc *conf.GlobalConfiguration) *LimiterOptions + type LogoutBehavior string + const LogoutGlobal + const LogoutLocal + const LogoutOthers + type MagicLinkParams struct + CodeChallenge string + CodeChallengeMethod string + Data map[string]interface{} + Email string + func (p *MagicLinkParams) Validate(a *API) error + type OAuthError struct + Description string + Err string + InternalError error + InternalMessage string + func (e *OAuthError) Cause() error + func (e *OAuthError) Error() string + func (e *OAuthError) WithInternalError(err error) *OAuthError + func (e *OAuthError) WithInternalMessage(fmtString string, args ...interface{}) *OAuthError + type OAuthProviderData struct + type Option interface + type OtpParams struct + Channel string + CodeChallenge string + CodeChallengeMethod string + CreateUser bool + Data map[string]interface{} + Email string + Phone string + func (p *OtpParams) Validate() error + type PKCEGrantParams struct + AuthCode string + CodeVerifier string + type PasswordGrantParams struct + Email string + Password string + Phone string + type ProviderSettings struct + AnonymousUsers bool + Apple bool + Azure bool + Bitbucket bool + Discord bool + Email bool + Facebook bool + Figma bool + Fly bool + GitHub bool + GitLab bool + Google bool + Kakao bool + Keycloak bool + Linkedin bool + LinkedinOIDC bool + Notion bool + Phone bool + Slack bool + SlackOIDC bool + Spotify bool + Twitch bool + Twitter bool + WorkOS bool + Zoom bool + type RecoverParams struct + CodeChallenge string + CodeChallengeMethod string + Email string + func (p *RecoverParams) Validate(a *API) error + type RefreshTokenGrantParams struct + RefreshToken string + type RequestParams interface + type ResendConfirmationParams struct + Email string + Phone string + Type string + func (p *ResendConfirmationParams) Validate(a *API) error + type SAMLAssertion struct + func (a *SAMLAssertion) Attribute(name string) []saml.AttributeValue + func (a *SAMLAssertion) Email() string + func (a *SAMLAssertion) NotAfter() time.Time + func (a *SAMLAssertion) NotBefore() time.Time + func (a *SAMLAssertion) Process(mapping models.SAMLAttributeMapping) map[string]interface{} + func (a *SAMLAssertion) SubjectID() (string, bool) + func (a *SAMLAssertion) UserID() string + type Settings struct + DisableSignup bool + ExternalProviders ProviderSettings + MailerAutoconfirm bool + PhoneAutoconfirm bool + SAMLEnabled bool + SmsProvider string + type SharedLimiter struct + EmailLimiter *limiter.Limiter + PhoneLimiter *limiter.Limiter + type SignupParams struct + Aud string + Channel string + CodeChallenge string + CodeChallengeMethod string + Data map[string]interface{} + Email string + Password string + Phone string + Provider string + func (p *SignupParams) ConfigureDefaults() + func (params *SignupParams) ToUserModel(isSSOUser bool) (user *models.User, err error) + type SingleSignOnParams struct + CodeChallenge string + CodeChallengeMethod string + Domain string + ProviderID uuid.UUID + RedirectTo string + SkipHTTPRedirect *bool + type SingleSignOnResponse struct + URL string + type SmsOtpResponse struct + MessageID string + type SmsParams struct + Channel string + CodeChallenge string + CodeChallengeMethod string + Data map[string]interface{} + Phone string + func (p *SmsParams) Validate(config *conf.GlobalConfiguration) error + type TOTPObject struct + QRCode string + Secret string + URI string + type UnenrollFactorResponse struct + ID uuid.UUID + type UserUpdateParams struct + AppData map[string]interface{} + Channel string + CodeChallenge string + CodeChallengeMethod string + Data map[string]interface{} + Email string + Nonce string + Password *string + Phone string + type VerifyFactorParams struct + ChallengeID uuid.UUID + Code string + WebAuthn *WebAuthnParams + type VerifyParams struct + Email string + Phone string + RedirectTo string + Token string + TokenHash string + Type string + func (p *VerifyParams) Validate(r *http.Request, a *API) error + type WeakPasswordError struct + Message string + Reasons []string + func (e *WeakPasswordError) Error() string + type WebAuthnParams struct + AssertionResponse json.RawMessage + CreationResponse json.RawMessage + RPID string + RPOrigins string + func (w *WebAuthnParams) GetRPOrigins() []string + func (w *WebAuthnParams) ToConfig() (*webauthn.WebAuthn, error)