-
-
Notifications
You must be signed in to change notification settings - Fork 964
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
Allow admin to remove MFA credentials (TOTP, lookup secrets, webauthn) #2505
Comments
Hi! This feature would be also useful for us and we are starting to work on the Solution 3 implementation |
I think this is a great idea and solution 3 looks very good to me |
I would love to work on this. Is there any draft for this issue ? While checking the remove method from the settings part I could see:
count, err := s.d.IdentityManager().CountActiveFirstFactorCredentials(r.Context(), i)
if err != nil {
return err
}
if count < 2 && wasPasswordless {
return s.handleSettingsError(w, r, ctxUpdate, p, errors.WithStack(ErrNotEnoughCredentials))
} Once this is done, we can safely remove the credential (identified by ID) by deep-coping the Credential array and removing the said WebAuthn credential: updated := make([]Credential, 0)
for k, cred := range cc.Credentials {
if fmt.Sprintf("%x", cred.ID) != p.Remove {
updated = append(updated, cc.Credentials[k])
}
}
if len(updated) == 0 {
i.DeleteCredentialsType(identity.CredentialsTypeWebAuthn)
ctxUpdate.UpdateIdentity(i)
return nil
}
cc.Credentials = updated
cred.Config, err = json.Marshal(cc)
if err != nil {
return errors.WithStack(herodot.ErrInternalServerError.WithReasonf("Unable to encode identity credentials.").WithDebug(err.Error()))
}
i.SetCredentials(s.ID(), *cred)
ctxUpdate.UpdateIdentity(i)
i.DeleteCredentialsType(identity.CredentialsTypeTOTP)
ctxUpdate.UpdateIdentity(i) https://github.com/ory/kratos/blob/master/selfservice/strategy/totp/settings.go#L226
i.DeleteCredentialsType(identity.CredentialsTypeLookup)
ctxUpdate.UpdateIdentity(i) https://github.com/ory/kratos/blob/master/selfservice/strategy/lookup/settings.go#L180 |
Sounds great! How would the REST API for this look like? |
I was thinking we could have a simple API as we discussed previously (solution 3):
|
After trying to implement, i've decided to go with the simple solution and implement only a deletion by type. If you want to implement it by |
Preflight checklist
Describe your problem
If a user loses all their configured MFA credentials (when
reuired_aal
is set tohighest_available
for the profile) there is currently no exposed way to remove the MFA credentials.I consider it a sensible feature to expose an endpoint on the admin API to remove/reset MFA.
There are currently a few open PRs that lay the groundwork for this:
#2423 will allow updating credentials in general
#2380 will allow selectively updating the only credentials
#2438 will allow adding
totp
andlookup_secrets
What I consider still missing, is a way to remove the credentials via an admin API endpoint.
Describe your ideal solution
Solution 1:
Allow the
PUT /admin/identities/{id}
(and the futurePATCH /admin/identities/{id}
) to remove credentialsPossibly by passing something like (YAML for simpler notation)
Solution 2:
Create a new
DELETE /admin/identities/{id}/mfa
or similar endpointSolution 3:
Create a new
DELETE /admin/identities/{id}/credentials/{type}
(type beingtotp
,webauthn
,lookup_secrets
) or similar endpoint.Workarounds or alternatives
Any of the three solutions would fulfill the need. My personal preference would be to offer both solution 1 and one of 2 or 3, with 3 being probably the cleaner one.
Version
v0.10.1
Additional Context
No response
The text was updated successfully, but these errors were encountered: