Localize WebAuthn registration verification errors#51012
Localize WebAuthn registration verification errors#51012AkashKumar7902 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Localizes WebAuthn registration errors for missing user presence or verification while retaining diagnostic details.
Changes:
- Maps WebAuthn4J exceptions to login-theme message keys.
- Adds English and German messages.
- Adds unit coverage for mapped and fallback exceptions.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
themes/.../messages_en.properties |
Adds English error messages. |
themes/.../messages_de.properties |
Adds German translations. |
WebAuthnRegisterTest.java |
Tests exception mappings and fallback. |
Messages.java |
Defines the new message keys. |
WebAuthnRegister.java |
Localizes user-facing errors while preserving diagnostics. |
|
Thank you for the pull request. Instead of a unit test, can you please provide an integration test? There is no need to add a German translation in this PR. This is better handled in the Weblate project. As you're overriding the English text already, you should be able to test this without the German text. In the code where you map an exception to a text, it would be good to add a note that this is only possible for those exceptions that map to a single message in the webauthn4j code (unfortunately, some of them don't). |
Map user-presence and user-verification exceptions to theme messages while retaining the original WebAuthn4J diagnostics in logs and event details. Closes keycloak#44963 Signed-off-by: Akash Kumar <meakash7902@gmail.com>
2814a7b to
2ef6614
Compare
|
Thanks for the review. I addressed all three points in
I also rebased onto current |
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRegisterClickKeycloak CI - Forms IT (firefox) |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
services/src/main/java/org/keycloak/authentication/requiredactions/WebAuthnRegister.java:463
- The new
UserNotPresentExceptionbranch has no corresponding test; the updated integration test only exercisesUserNotVerifiedException. Add a registration case (or focused unit test) that triggers a missing UP flag and asserts the localized user-presence message.
if (exception instanceof UserNotPresentException) {
return WEBAUTHN_ERROR_USER_NOT_PRESENT;
|
Please avoid merging the main branch into the PR or rebasing the PR unless there are merge conflicts reported by GitHub or a reviewer asks you for a rebase. This prevents spamming reviewers with notifications and saves minutes on the GitHub actions CI. Thanks! |
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRegisterClickKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.oauth.ClientAuthPostMethodTest#testPostAuthenticationNotAllowedWhenBasicRequestedorg.keycloak.testsuite.oauth.ClientAuthPostMethodTest#testBasicAuthenticationNotAllowedWhenPostRequestedorg.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRegisterClickKeycloak CI - Forms IT (firefox) org.keycloak.testsuite.forms.BrowserFlowTest#testUserWithOneAdditionalFactorOtpSuccess |
Clear the UP flag in a browser-generated attestation so the integration suite covers the localized UserNotPresentException mapping. Signed-off-by: Akash Kumar <meakash7902@gmail.com>
|
Understood—thanks for the guidance. I left the branch history as-is; this update was a normal fast-forward push containing only the requested UP-coverage test. I won’t merge or rebase |
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.forms.BrowserFlowTest#testUserWithOneAdditionalFactorOtpSuccessorg.keycloak.testsuite.forms.MultipleTabsLoginTest#testEmptyBaseUrlKeycloak CI - Forms IT (firefox) org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredInTheMiddleKeycloak CI - Forms IT (firefox) |
Summary
Motivation
When user verification is required but the authenticator does not verify the user, Keycloak currently renders a localized registration-error prefix followed by WebAuthn4J's English developer-facing exception text. This resolves a Keycloak message key for the user-facing detail while preserving the original diagnostic for operators.
Only WebAuthn4J exception types that represent a single failure reason are mapped. Other WebAuthn exception types, browser-originated registration errors, and the authentication path are unchanged.
Testing
Automated:
./mvnw test -f tests/webauthn/pom.xml -Dtest=WebAuthnPolicyComplianceTest#tamperedUserPresence— 1 test passed./mvnw test -f tests/webauthn/pom.xml -Dtest=WebAuthnPolicyComplianceTest#tamperedUserVerification— 1 test passed./mvnw test -f tests/webauthn/pom.xml -Dtest=WebAuthnPolicyComplianceTest— 9 tests passed./mvnw -pl quarkus/dist -am -DskipTests -DskipTestsuite -DskipExamples package— 53-module reactor passed./mvnw -pl services,themes,tests/webauthn -DskipTests spotless:checkgit diff --checkManual:
45554ad0, started it with a disposable H2 realm, and drove registration with a standalone headless Chrome client. A valid credential was accepted; after clearing the UP flag from a browser-generated credential before submission, Keycloak rendered “Failed to register your Passkey. User presence is required.”Documentation
Not applicable; this changes an existing error diagnostic and introduces no configuration or workflow change.
AI disclosure
I used OpenAI Codex agents to assist with repository analysis, implementation, tests, and review of this change. I reviewed, understand, and can explain and revise every submitted change.
Closes #44963