Skip to content

Commit 1576b3d

Browse files
committed
Handle empty allowCredentials the same as absent in finishAssertion
1 parent e371103 commit 1576b3d

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

NEWS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
== Version 2.4.2 (unreleased) ==
22

3+
Changes:
4+
35
* Updated README and JavaDoc to use the "passkey" term and provide more guidance
46
around passkey use cases.
57

8+
Fixes:
9+
10+
* `RelyingParty.finishAssertion` now behaves the same if
11+
`StartAssertionOptions.allowCredentials` is explicitly set to a present, empty
12+
list as when absent.
13+
614

715
== Version 2.4.1 ==
816

webauthn-server-core/src/main/java/com/yubico/webauthn/FinishAssertionSteps.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public void validate() {
111111
request
112112
.getPublicKeyCredentialRequestOptions()
113113
.getAllowCredentials()
114+
.filter(allowCredentials -> !allowCredentials.isEmpty())
114115
.ifPresent(
115116
allowed -> {
116117
assertTrue(

webauthn-server-core/src/test/scala/com/yubico/webauthn/RelyingPartyAssertionSpec.scala

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -594,14 +594,21 @@ class RelyingPartyAssertionSpec
594594
}
595595

596596
it("Succeeds if no credential IDs were requested.") {
597-
val steps = finishAssertion(
598-
allowCredentials = None,
599-
credentialId = new ByteArray(Array(0, 1, 2, 3)),
600-
)
601-
val step: FinishAssertionSteps#Step5 = steps.begin
597+
for {
598+
allowCredentials <- List(
599+
None,
600+
Some(List.empty[PublicKeyCredentialDescriptor].asJava),
601+
)
602+
} {
603+
val steps = finishAssertion(
604+
allowCredentials = allowCredentials,
605+
credentialId = new ByteArray(Array(0, 1, 2, 3)),
606+
)
607+
val step: FinishAssertionSteps#Step5 = steps.begin
602608

603-
step.validations shouldBe a[Success[_]]
604-
step.tryNext shouldBe a[Success[_]]
609+
step.validations shouldBe a[Success[_]]
610+
step.tryNext shouldBe a[Success[_]]
611+
}
605612
}
606613
}
607614

0 commit comments

Comments
 (0)