Skip to content

Commit a013bfa

Browse files
committed
Merge branch 'gh-18643-6.5.x' into gh-18643-7.0.x
2 parents 5b4fc73 + e726c05 commit a013bfa

2 files changed

Lines changed: 46 additions & 6 deletions

File tree

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

webauthn/src/test/java/org/springframework/security/web/webauthn/jackson/Jackson2Tests.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,47 @@ void readCredPropsWhenAuthenticatorDisplayName() throws Exception {
122122
assertThat(outputs).usingRecursiveComparison().isEqualTo(credProps);
123123
}
124124

125+
@Test
126+
void readAuthenticationExtensionsClientOutputsWhenAppId() throws Exception {
127+
String json = """
128+
{
129+
"appid": false,
130+
"credProps": {
131+
"rk": false
132+
}
133+
}
134+
""";
135+
CredentialPropertiesOutput credProps = new CredentialPropertiesOutput(false);
136+
137+
AuthenticationExtensionsClientOutputs outputs = this.mapper.readValue(json,
138+
AuthenticationExtensionsClientOutputs.class);
139+
assertThat(outputs.getOutputs()).usingRecursiveFieldByFieldElementComparator().contains(credProps);
140+
}
141+
142+
@Test
143+
void readAuthenticationExtensionsClientOutputsWhenUnknownExtension() throws Exception {
144+
String json = """
145+
{
146+
"unknownObject1": {
147+
"key": "value"
148+
},
149+
"unknownArray": [
150+
{ "key": "value1" },
151+
{ "key": "value2" }
152+
],
153+
"credProps": {
154+
"rk": false
155+
},
156+
"unknownObject2": {}
157+
}
158+
""";
159+
CredentialPropertiesOutput credProps = new CredentialPropertiesOutput(false);
160+
161+
AuthenticationExtensionsClientOutputs outputs = this.mapper.readValue(json,
162+
AuthenticationExtensionsClientOutputs.class);
163+
assertThat(outputs.getOutputs()).usingRecursiveFieldByFieldElementComparator().contains(credProps);
164+
}
165+
125166
@Test
126167
void readAuthenticationExtensionsClientOutputsWhenFieldAfter() throws Exception {
127168
String json = """

0 commit comments

Comments
 (0)