MCPcopy Create free account
hub / github.com/supabase/auth / ChallengeFactor

Method ChallengeFactor

internal/api/mfa.go:566–592  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

564}
565
566func (a *API) ChallengeFactor(w http.ResponseWriter, r *http.Request) error {
567 ctx := r.Context()
568 config := a.config
569 factor := getFactor(ctx)
570
571 switch factor.FactorType {
572 case models.Phone:
573 if !config.MFA.Phone.VerifyEnabled {
574 return apierrors.NewUnprocessableEntityError(apierrors.ErrorCodeMFAPhoneVerifyDisabled, "MFA verification is disabled for Phone")
575 }
576 return a.challengePhoneFactor(w, r)
577
578 case models.TOTP:
579 if !config.MFA.TOTP.VerifyEnabled {
580 return apierrors.NewUnprocessableEntityError(apierrors.ErrorCodeMFATOTPVerifyDisabled, "MFA verification is disabled for TOTP")
581 }
582 return a.challengeTOTPFactor(w, r)
583 case models.WebAuthn:
584 if !config.MFA.WebAuthn.VerifyEnabled {
585 return apierrors.NewUnprocessableEntityError(apierrors.ErrorCodeMFAWebAuthnVerifyDisabled, "MFA verification is disabled for WebAuthn")
586 }
587 return a.challengeWebAuthnFactor(w, r)
588 default:
589 return apierrors.NewBadRequestError(apierrors.ErrorCodeValidationFailed, "factor_type needs to be totp, phone, or webauthn")
590 }
591
592}
593
594func (a *API) verifyTOTPFactor(w http.ResponseWriter, r *http.Request, params *VerifyFactorParams) error {
595 var err error

Callers

nothing calls this directly

Calls 6

challengePhoneFactorMethod · 0.95
challengeTOTPFactorMethod · 0.95
NewBadRequestErrorFunction · 0.92
getFactorFunction · 0.85

Tested by

no test coverage detected