feat: Fire an event when a passkey is revoked - #543
Merged
Merged
Conversation
Adds Events::USER_DID_REMOVE_PASSKEY, dispatched from Service\Passkey::revoke() after a successful delete, regardless of what triggered it (self-service or admin). This is a live event alongside the existing did_remove_passkey audit log entry, not a replacement for it. Without this there was no way for anything outside this module to notice a passkey had gone and react — needed by the MFA module's passkey driver, which must un-enroll the "Passkey" MFA method once a user's last passkey is revoked, otherwise they are left enrolled in a method they can never again satisfy. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
Events::USER_DID_REMOVE_PASSKEY, dispatched fromService\Passkey::revoke()after a successful delete — regardless of what triggered it (self-service/auth/passkeysor the admin user tab). This is a live event alongside the existingdid_remove_passkeyaudit-log entry, not a replacement for it.Why
Found while building MFA passkey support: revoking a user's last passkey (e.g. from admin) left them enrolled in the MFA module's "Passkey" method with no way to ever satisfy it again — no matching credential exists any more. There was no hook for anything outside this module to react to a passkey disappearing.
The MFA driver (a follow-up PR,
nails/driver-multi-factor-auth-passkey) subscribes to this event and un-enrolls the passkey MFA method once a user has zero passkeys left. This lives here rather than as a hard dependency, somodule-authnever needs to know MFA exists.Testing
composer test— 218/218 passingcomposer analyse— clean/auth/passkeys, confirmed the event fires and (with the driver installed) the dependent MFA method is correctly removed, with no other passkeys affected when more than one remains.🤖 Generated with Claude Code