Skip to content

Commit d220ef2

Browse files
committed
Pass hints through in RelyingParty.startAssertion
1 parent 4c3bde4 commit d220ef2

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,8 @@ public AssertionRequest startAssertion(StartAssertionOptions startAssertionOptio
538538
startAssertionOptions
539539
.getExtensions()
540540
.merge(startAssertionOptions.getExtensions().toBuilder().appid(appId).build()))
541-
.timeout(startAssertionOptions.getTimeout());
541+
.timeout(startAssertionOptions.getTimeout())
542+
.hints(startAssertionOptions.getHints());
542543

543544
startAssertionOptions.getUserVerification().ifPresent(pkcro::userVerification);
544545

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,59 @@ class RelyingPartyStartOperationSpec
818818
}
819819
}
820820

821+
describe("allows setting the hints") {
822+
val rp = relyingParty(userId = userId)
823+
824+
it("to string values in the spec or not.") {
825+
val pkcro = rp.startAssertion(
826+
StartAssertionOptions
827+
.builder()
828+
.hints("hej", "security-key", "hoj", "client-device", "hybrid")
829+
.build()
830+
)
831+
pkcro.getPublicKeyCredentialRequestOptions.getHints.asScala should equal(
832+
List(
833+
"hej",
834+
PublicKeyCredentialHint.SECURITY_KEY.getValue,
835+
"hoj",
836+
PublicKeyCredentialHint.CLIENT_DEVICE.getValue,
837+
PublicKeyCredentialHint.HYBRID.getValue,
838+
)
839+
)
840+
}
841+
842+
it("to PublicKeyCredentialHint values in the spec or not.") {
843+
val pkcro = rp.startAssertion(
844+
StartAssertionOptions
845+
.builder()
846+
.hints(
847+
PublicKeyCredentialHint.of("hej"),
848+
PublicKeyCredentialHint.HYBRID,
849+
PublicKeyCredentialHint.SECURITY_KEY,
850+
PublicKeyCredentialHint.of("hoj"),
851+
PublicKeyCredentialHint.CLIENT_DEVICE,
852+
)
853+
.build()
854+
)
855+
pkcro.getPublicKeyCredentialRequestOptions.getHints.asScala should equal(
856+
List(
857+
"hej",
858+
PublicKeyCredentialHint.HYBRID.getValue,
859+
PublicKeyCredentialHint.SECURITY_KEY.getValue,
860+
"hoj",
861+
PublicKeyCredentialHint.CLIENT_DEVICE.getValue,
862+
)
863+
)
864+
}
865+
866+
it("or not, defaulting to the empty list.") {
867+
val pkcro = rp.startAssertion(StartAssertionOptions.builder().build())
868+
pkcro.getPublicKeyCredentialRequestOptions.getHints.asScala should equal(
869+
List()
870+
)
871+
}
872+
}
873+
821874
it("allows setting the timeout to empty.") {
822875
val req = relyingParty(userId = userId).startAssertion(
823876
StartAssertionOptions

0 commit comments

Comments
 (0)