Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: restrict mfa enrollment to aal2 if verified factors are present #1439

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/api/mfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const (
func (a *API) EnrollFactor(w http.ResponseWriter, r *http.Request) error {
ctx := r.Context()
user := getUser(ctx)
session := getSession(ctx)
config := a.config

params := &EnrollFactorParams{}
Expand Down Expand Up @@ -110,6 +111,10 @@ func (a *API) EnrollFactor(w http.ResponseWriter, r *http.Request) error {
return forbiddenError("Maximum number of enrolled factors reached, unenroll to continue")
}

if numVerifiedFactors > 0 && !session.IsAAL2() {
return forbiddenError("AAL2 required to enroll a new factor")
}

key, err := totp.Generate(totp.GenerateOpts{
Issuer: issuer,
AccountName: user.GetEmail(),
Expand Down
Loading