Skip to content

Commit 6d3f4a6

Browse files
committed
Fix deserializer for AuthenticationExtensionsClientOutputs
The deserializer is updated to properly ignore unknown extensions. This fix addresses the WebAuthn authentication failure appeared when using FIDO2 security keys on Safari. Closes gh-18643 Signed-off-by: Ziqin Wang <ziqin@wangziqin.net>
1 parent 378833c commit 6d3f4a6

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

webauthn/src/main/java/org/springframework/security/web/webauthn/jackson/AuthenticationExtensionsClientOutputsDeserializer.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,18 @@ public AuthenticationExtensionsClientOutputs deserialize(JsonParser parser, Dese
5555
throws JacksonException {
5656
List<AuthenticationExtensionsClientOutput<?>> outputs = new ArrayList<>();
5757
for (String key = parser.nextName(); key != null; key = parser.nextName()) {
58-
JsonToken startObject = parser.nextValue();
59-
if (startObject != JsonToken.START_OBJECT) {
60-
break;
61-
}
62-
if (CredentialPropertiesOutput.EXTENSION_ID.equals(key)) {
58+
JsonToken next = parser.nextToken();
59+
if (next == JsonToken.START_OBJECT && CredentialPropertiesOutput.EXTENSION_ID.equals(key)) {
6360
CredentialPropertiesOutput output = parser.readValueAs(CredentialPropertiesOutput.class);
6461
outputs.add(output);
6562
}
6663
else {
6764
if (logger.isDebugEnabled()) {
6865
logger.debug("Skipping unknown extension with id " + key);
6966
}
70-
parser.nextValue();
67+
if (next.isStructStart()) {
68+
parser.skipChildren();
69+
}
7170
}
7271
}
7372

webauthn/src/main/java/org/springframework/security/web/webauthn/jackson/AuthenticationExtensionsClientOutputsJackson2Deserializer.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,18 @@ public AuthenticationExtensionsClientOutputs deserialize(JsonParser parser, Dese
6262
throws IOException, JacksonException {
6363
List<AuthenticationExtensionsClientOutput<?>> outputs = new ArrayList<>();
6464
for (String key = parser.nextFieldName(); key != null; key = parser.nextFieldName()) {
65-
JsonToken startObject = parser.nextValue();
66-
if (startObject != JsonToken.START_OBJECT) {
67-
break;
68-
}
69-
if (CredentialPropertiesOutput.EXTENSION_ID.equals(key)) {
65+
JsonToken next = parser.nextToken();
66+
if (next == JsonToken.START_OBJECT && CredentialPropertiesOutput.EXTENSION_ID.equals(key)) {
7067
CredentialPropertiesOutput output = parser.readValueAs(CredentialPropertiesOutput.class);
7168
outputs.add(output);
7269
}
7370
else {
7471
if (logger.isDebugEnabled()) {
7572
logger.debug("Skipping unknown extension with id " + key);
7673
}
77-
parser.nextValue();
74+
if (next.isStructStart()) {
75+
parser.skipChildren();
76+
}
7877
}
7978
}
8079

0 commit comments

Comments
 (0)