Skip to content

Commit 613d34f

Browse files
committed
Merge branch 'main' into credprotect
2 parents 8e20e63 + ef6b552 commit 613d34f

File tree

6 files changed

+108
-5
lines changed

6 files changed

+108
-5
lines changed

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
== Version 2.7.0 (unreleased) ==
22

3+
* Added overloaded setter `RelyingPartyBuilder.origins(Optional<Set<String>>)`.
34
* Added support for the CTAP2 `credProtect` extension.
45
* (Experimental) Added a new suite of interfaces, starting with
56
`CredentialRepositoryV2`. `RelyingParty` can now be configured with a

webauthn-server-attestation/src/integrationTest/scala/com/yubico/fido/metadata/FidoMetadataServiceIntegrationTest.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,18 @@ class FidoMetadataServiceIntegrationTest
223223

224224
it("a YubiKey Bio.") {
225225
check(
226-
"YubiKey Bio Series",
226+
"YubiKey Bio Series - FIDO Edition",
227227
RealExamples.YubikeyBio_5_5_4,
228228
attachmentHintsUsb,
229229
)
230230
check(
231-
"YubiKey Bio Series",
231+
"YubiKey Bio Series - FIDO Edition",
232232
RealExamples.YubikeyBio_5_5_5,
233233
attachmentHintsUsb,
234234
)
235235
withProviderContext(List(new BouncyCastleProvider)) { // Needed for JDK<14 because this example uses EdDSA
236236
check(
237-
"YubiKey Bio Series",
237+
"YubiKey Bio Series - FIDO Edition",
238238
RealExamples.YubikeyBio_5_5_6,
239239
attachmentHintsUsb,
240240
)

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

+10
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,16 @@ public static class RelyingPartyBuilder {
588588
Optional.empty();
589589
private @NonNull Optional<AttestationTrustSource> attestationTrustSource = Optional.empty();
590590

591+
public RelyingPartyBuilder origins(@NonNull Set<String> origins) {
592+
this.origins = origins;
593+
return this;
594+
}
595+
596+
public RelyingPartyBuilder origins(Optional<Set<String>> origins) {
597+
this.origins = origins.orElse(null);
598+
return this;
599+
}
600+
591601
public static class MandatoryStages {
592602
private final RelyingPartyBuilder builder = new RelyingPartyBuilder();
593603

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

+10
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,16 @@ public static class RelyingPartyV2Builder<C extends CredentialRecord> {
563563
Optional.empty();
564564
private @NonNull Optional<AttestationTrustSource> attestationTrustSource = Optional.empty();
565565

566+
public RelyingPartyV2Builder<C> origins(@NonNull Set<String> origins) {
567+
this.origins = origins;
568+
return this;
569+
}
570+
571+
public RelyingPartyV2Builder<C> origins(Optional<Set<String>> origins) {
572+
this.origins = origins.orElse(null);
573+
return this;
574+
}
575+
566576
/**
567577
* The extension input to set for the <code>appid</code> and <code>appidExclude</code>
568578
* extensions.

webauthn-server-core/src/test/java/com/yubico/webauthn/RelyingPartyTest.java

+82
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,88 @@ public void originsIsImmutable() {
103103
}
104104
}
105105

106+
@Test
107+
public void testOriginsWithEmptySet() {
108+
Set<String> origins = new HashSet<>();
109+
110+
RelyingParty rp =
111+
RelyingParty.builder()
112+
.identity(RelyingPartyIdentity.builder().id("localhost").name("Test").build())
113+
.credentialRepository(unimplementedCredentialRepository())
114+
.origins(origins)
115+
.build();
116+
117+
assertEquals(0, rp.getOrigins().size());
118+
}
119+
120+
@Test
121+
public void testOriginsWithSet() {
122+
Set<String> origins = new HashSet<>();
123+
origins.add("test1");
124+
origins.add("test2");
125+
126+
RelyingParty rp =
127+
RelyingParty.builder()
128+
.identity(RelyingPartyIdentity.builder().id("localhost").name("Test").build())
129+
.credentialRepository(unimplementedCredentialRepository())
130+
.origins(origins)
131+
.build();
132+
133+
assertEquals(2, rp.getOrigins().size());
134+
}
135+
136+
@Test
137+
public void testOriginsWithAbsentOptionalSet() {
138+
{
139+
RelyingParty rp =
140+
RelyingParty.builder()
141+
.identity(RelyingPartyIdentity.builder().id("localhost").name("Test").build())
142+
.credentialRepository(unimplementedCredentialRepository())
143+
.origins(Optional.empty())
144+
.build();
145+
assertEquals(1, rp.getOrigins().size());
146+
}
147+
148+
{
149+
RelyingPartyV2<RegisteredCredential> rp =
150+
RelyingParty.builder()
151+
.identity(RelyingPartyIdentity.builder().id("localhost").name("Test").build())
152+
.credentialRepositoryV2(
153+
new CredentialRepositoryV1ToV2Adapter(unimplementedCredentialRepository()))
154+
.origins(Optional.empty())
155+
.build();
156+
assertEquals(1, rp.getOrigins().size());
157+
}
158+
}
159+
160+
@Test
161+
public void testOriginsWithOptionalSet() {
162+
Set<String> origins = new HashSet<>();
163+
origins.add("test1");
164+
origins.add("test2");
165+
166+
{
167+
RelyingParty rp =
168+
RelyingParty.builder()
169+
.identity(RelyingPartyIdentity.builder().id("localhost").name("Test").build())
170+
.credentialRepository(unimplementedCredentialRepository())
171+
.origins(Optional.of(origins))
172+
.build();
173+
assertEquals(2, rp.getOrigins().size());
174+
}
175+
176+
{
177+
RelyingPartyV2<RegisteredCredential> rp =
178+
RelyingParty.builder()
179+
.identity(RelyingPartyIdentity.builder().id("localhost").name("Test").build())
180+
.credentialRepositoryV2(
181+
new CredentialRepositoryV1ToV2Adapter(unimplementedCredentialRepository()))
182+
.origins(Optional.of(origins))
183+
.build();
184+
assertEquals(2, rp.getOrigins().size());
185+
}
186+
}
187+
106188
@Test
107189
public void filtersAlgorithmsToThoseAvailable() throws HexException {
108190
for (Provider prov : Security.getProviders()) {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class RelyingPartyStartOperationSpec
118118
.identity(rpId)
119119
.credentialRepository(credRepo(credentials, userId))
120120
.preferredPubkeyParams(List(PublicKeyCredentialParameters.ES256).asJava)
121-
.origins(Set.empty.asJava)
121+
.origins(Set.empty[String].asJava)
122122
appId.foreach { appid => builder = builder.appId(appid) }
123123
attestationConveyancePreference.foreach { acp =>
124124
builder = builder.attestationConveyancePreference(acp)
@@ -1097,7 +1097,7 @@ class RelyingPartyStartOperationSpec
10971097
)
10981098
)
10991099
.preferredPubkeyParams(List(PublicKeyCredentialParameters.ES256).asJava)
1100-
.origins(Set.empty.asJava)
1100+
.origins(Set.empty[String].asJava)
11011101
if (usernameRepository) {
11021102
builder.usernameRepository(Helpers.UsernameRepository.withUsers(userId))
11031103
}

0 commit comments

Comments
 (0)