diff --git a/services/src/main/java/org/keycloak/credential/WebAuthnCredentialModelInput.java b/services/src/main/java/org/keycloak/credential/WebAuthnCredentialModelInput.java index a40dcf34c7..f154c5d46d 100644 --- a/services/src/main/java/org/keycloak/credential/WebAuthnCredentialModelInput.java +++ b/services/src/main/java/org/keycloak/credential/WebAuthnCredentialModelInput.java @@ -26,6 +26,7 @@ import com.webauthn4j.data.attestation.authenticator.AttestedCredentialData; import com.webauthn4j.data.attestation.authenticator.COSEKey; import com.webauthn4j.data.attestation.statement.AttestationStatement; +import java.util.Collections; import java.util.Set; import java.util.stream.Collectors; @@ -122,7 +123,7 @@ public class WebAuthnCredentialModelInput implements CredentialInput { } public Set getTransports() { - return transports; + return transports != null ? transports : Collections.emptySet(); } public void setTransports(Set transports) { @@ -170,8 +171,8 @@ public class WebAuthnCredentialModelInput implements CredentialInput { .append(Base64.encodeBytes(authenticationRequest.getCredentialId())) .append(","); } - if (CollectionUtils.isNotEmpty(transports)) { - final String transportsString = transports.stream() + if (CollectionUtils.isNotEmpty(getTransports())) { + final String transportsString = getTransports().stream() .map(AuthenticatorTransport::getValue) .collect(Collectors.joining(",")); diff --git a/themes/src/main/resources/theme/base/login/webauthn-register.ftl b/themes/src/main/resources/theme/base/login/webauthn-register.ftl index 3d76241063..1b339a718e 100644 --- a/themes/src/main/resources/theme/base/login/webauthn-register.ftl +++ b/themes/src/main/resources/theme/base/login/webauthn-register.ftl @@ -104,10 +104,13 @@ $("#attestationObject").val(base64url.encode(new Uint8Array(attestationObject), {pad: false})); $("#publicKeyCredentialId").val(base64url.encode(new Uint8Array(publicKeyCredentialId), {pad: false})); - - let transports = result.response.getTransports(); - if (transports) { - $("#transports").val(getTransportsAsString(transports)); + if (typeof result.response.getTransports === "function") { + let transports = result.response.getTransports(); + if (transports) { + $("#transports").val(getTransportsAsString(transports)); + } + } else { + console.log("Your browser is not able to recognize supported transport media for the authenticator."); } let initLabel = "WebAuthn Authenticator (Default Label)";