Skip to content

Commit

Permalink
fix: add initial structure
Browse files Browse the repository at this point in the history
  • Loading branch information
J0 committed Sep 12, 2024
1 parent c00ca00 commit 418a0b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/api/errorcodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ const (
ErrorCodeMFAPhoneVerifyDisabled ErrorCode = "mfa_phone_verify_not_enabled"
ErrorCodeMFATOTPEnrollDisabled ErrorCode = "mfa_totp_enroll_not_enabled"
ErrorCodeMFATOTPVerifyDisabled ErrorCode = "mfa_totp_verify_not_enabled"
ErrorCodeMFAWebAuthnEnrollDisabled ErrorCode = "mfa_webauthn_enroll_not_enabled"
ErrorCodeMFAWebAuthnVerifyDisabled ErrorCode = "mfa_webauthn_verify_not_enabled"
ErrorCodeMFAVerifiedFactorExists ErrorCode = "mfa_verified_factor_exists"
//#nosec G101 -- Not a secret value.
ErrorCodeInvalidCredentials ErrorCode = "invalid_credentials"
Expand Down
8 changes: 8 additions & 0 deletions internal/api/mfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ func (a *API) enrollPhoneFactor(w http.ResponseWriter, r *http.Request, params *
})
}

func (a *API) enrollWebAuthnFactor(w http.ResponseWriter, r *http.Request, params *EnrollFactorParams) error {
}

func (a *API) enrollTOTPFactor(w http.ResponseWriter, r *http.Request, params *EnrollFactorParams) error {
ctx := r.Context()
user := getUser(ctx)
Expand Down Expand Up @@ -280,6 +283,11 @@ func (a *API) EnrollFactor(w http.ResponseWriter, r *http.Request) error {
return unprocessableEntityError(ErrorCodeMFATOTPEnrollDisabled, "MFA enroll is disabled for TOTP")
}
return a.enrollTOTPFactor(w, r, params)
case models.WebAuthn:
if !config.MFA.WebAuthn.EnrollEnabled {
return unprocessableEntityError(ErrorCodeMFAWebAuthnEnrollDisabled, "MFA enroll is disabled for WebAuthn")
}
return a.enrollWebAuthnFactor(w, r, params)
default:
return badRequestError(ErrorCodeValidationFailed, "factor_type needs to be totp or phone")
}
Expand Down

0 comments on commit 418a0b8

Please sign in to comment.