(w http.ResponseWriter, r *http.Request)
| 564 | } |
| 565 | |
| 566 | func (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 | |
| 594 | func (a *API) verifyTOTPFactor(w http.ResponseWriter, r *http.Request, params *VerifyFactorParams) error { |
| 595 | var err error |
nothing calls this directly
no test coverage detected