Skip to content

Fix WebAuthn to publish authentication events gh-18113#18938

Open
suuuuuuminnnnnn wants to merge 2 commits intospring-projects:mainfrom
suuuuuuminnnnnn:gh-18113
Open

Fix WebAuthn to publish authentication events gh-18113#18938
suuuuuuminnnnnn wants to merge 2 commits intospring-projects:mainfrom
suuuuuuminnnnnn:gh-18113

Conversation

@suuuuuuminnnnnn
Copy link
Copy Markdown

Fixes gh-18113

WebAuthnConfigurer creates a ProviderManager directly via new ProviderManager(...),
bypassing the AuthenticationManagerBuilder pipeline that normally injects the
AuthenticationEventPublisher. As a result, WebAuthn authentication always uses
ProviderManager's default NullEventPublisher, silently ignoring any
AuthenticationEventPublisher bean registered by the user.

This commit wires the AuthenticationEventPublisher bean into the ProviderManager
using the existing getBeanOrNull() helper, matching the behavior of other
authentication mechanisms such as form login. If no bean is present, the existing
NullEventPublisher fallback is preserved.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 19, 2026
@jzheaux jzheaux self-assigned this Mar 31, 2026
@jzheaux jzheaux added type: enhancement A general enhancement in: webauthn WebAuthn and Passkeys and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 31, 2026
@jzheaux jzheaux added this to the 7.1.0-RC1 milestone Mar 31, 2026
Signed-off-by: suuuuuuminnnnnn <sumin45402214@gmail.com>
Copy link
Copy Markdown
Contributor

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @suuuuuuminnnnnn! I've left some feedback inline.

ProviderManager providerManager = new ProviderManager(
new WebAuthnAuthenticationProvider(rpOperations, userDetailsService));
getBeanOrNull(AuthenticationEventPublisher.class).ifPresent(providerManager::setAuthenticationEventPublisher);
providerManager = postProcess(providerManager);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While post-processing the provider manager is certainly useful, is it possible to leave this out of this commit? In this way, one can look at the commit and see what was needed to add events.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure — i can drop the postProcess(providerManager) from this change to keep the fix focused on wiring the AuthenticationEventPublisher. if you think post-processing is still desirable here, i can follow up with a separate pr.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated in the latest commit — postProcess(providerManager) removed.

Signed-off-by: suuuuuuminnnnnn <sumin45402214@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: webauthn WebAuthn and Passkeys type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebAuthn ignores AuthenticationEventPublisher

3 participants