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

Method VerifyFactor

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

Source from the content-addressed store, hash-verified

987}
988
989func (a *API) VerifyFactor(w http.ResponseWriter, r *http.Request) error {
990 ctx := r.Context()
991 factor := getFactor(ctx)
992 config := a.config
993
994 params := &VerifyFactorParams{}
995 if err := retrieveRequestParams(r, params); err != nil {
996 return err
997 }
998 if params.Code == "" && factor.FactorType != models.WebAuthn {
999 return apierrors.NewBadRequestError(apierrors.ErrorCodeValidationFailed, "Code needs to be non-empty")
1000 }
1001
1002 switch factor.FactorType {
1003 case models.Phone:
1004 if !config.MFA.Phone.VerifyEnabled {
1005 return apierrors.NewUnprocessableEntityError(apierrors.ErrorCodeMFAPhoneVerifyDisabled, "MFA verification is disabled for Phone")
1006 }
1007
1008 return a.verifyPhoneFactor(w, r, params)
1009 case models.TOTP:
1010 if !config.MFA.TOTP.VerifyEnabled {
1011 return apierrors.NewUnprocessableEntityError(apierrors.ErrorCodeMFATOTPVerifyDisabled, "MFA verification is disabled for TOTP")
1012 }
1013 return a.verifyTOTPFactor(w, r, params)
1014 case models.WebAuthn:
1015 if !config.MFA.WebAuthn.VerifyEnabled {
1016 return apierrors.NewUnprocessableEntityError(apierrors.ErrorCodeMFAWebAuthnEnrollDisabled, "MFA verification is disabled for WebAuthn")
1017 }
1018 return a.verifyWebAuthnFactor(w, r, params)
1019 default:
1020 return apierrors.NewBadRequestError(apierrors.ErrorCodeValidationFailed, "factor_type needs to be totp, phone, or webauthn")
1021 }
1022
1023}
1024
1025func (a *API) UnenrollFactor(w http.ResponseWriter, r *http.Request) error {
1026 var err error

Callers

nothing calls this directly

Calls 7

verifyPhoneFactorMethod · 0.95
verifyTOTPFactorMethod · 0.95
verifyWebAuthnFactorMethod · 0.95
NewBadRequestErrorFunction · 0.92
getFactorFunction · 0.85
retrieveRequestParamsFunction · 0.85

Tested by

no test coverage detected