Skip to content

Commit 9de35cf

Browse files
committed
Release 1.1.0
Changed behaviours: - `AssertionExtensionInputsBuilder.appid(Optional<AppId>)` now fails fast if the argument is `null` - `ClientAssertionExtensionOutputsBuilder.appid(Optional<Boolean>)` now fails fast if the argument is `null` New features: - Public API methods that take `Optional` parameters now come with `Optional`-less aliases.
2 parents 8aaf483 + aad92ec commit 9de35cf

35 files changed

+978
-59
lines changed

NEWS

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
== Version 1.1.0 ==
2+
3+
Changed behaviours:
4+
5+
* `AssertionExtensionInputsBuilder.appid(Optional<AppId>)` now fails fast if the
6+
argument is `null`
7+
* `ClientAssertionExtensionOutputsBuilder.appid(Optional<Boolean>)` now fails
8+
fast if the argument is `null`
9+
10+
11+
New features:
12+
13+
* Public API methods that take `Optional` parameters now come with
14+
`Optional`-less aliases.
15+
16+
117
== Version 1.0.1 ==
218

319
Bugfixes:

README

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ Maven:
2727
<dependency>
2828
<groupId>com.yubico</groupId>
2929
<artifactId>webauthn-server-core</artifactId>
30-
<version>1.0.0</version>
30+
<version>1.1.0</version>
3131
<scope>compile</scope>
3232
</dependency>
3333
----------
3434

3535
Gradle:
3636

3737
----------
38-
compile 'com.yubico:webauthn-server-core:1.0.0'
38+
compile 'com.yubico:webauthn-server-core:1.1.0'
3939
----------
4040

4141

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public class AssertionRequest {
5959
* </p>
6060
*/
6161
@NonNull
62-
@Builder.Default
63-
private final Optional<String> username = Optional.empty();
62+
private final Optional<String> username;
6463

6564
@JsonCreator
6665
private AssertionRequest(
@@ -75,6 +74,8 @@ public static AssertionRequestBuilder.MandatoryStages builder() {
7574
}
7675

7776
public static class AssertionRequestBuilder {
77+
private Optional<String> username = Optional.empty();
78+
7879
public static class MandatoryStages {
7980
private final AssertionRequestBuilder builder = new AssertionRequestBuilder();
8081

@@ -86,6 +87,31 @@ public AssertionRequestBuilder publicKeyCredentialRequestOptions(PublicKeyCreden
8687
return builder.publicKeyCredentialRequestOptions(publicKeyCredentialRequestOptions);
8788
}
8889
}
90+
91+
/**
92+
* The username of the user to authenticate, if the user has already been identified.
93+
* <p>
94+
* If this is absent, this indicates that this is a request for an assertion by a <a
95+
* href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#client-side-resident-public-key-credential-source">client-side-resident
96+
* credential</a>, and identification of the user has been deferred until the response is received.
97+
* </p>
98+
*/
99+
public AssertionRequestBuilder username(@NonNull Optional<String> username) {
100+
this.username = username;
101+
return this;
102+
}
103+
104+
/**
105+
* The username of the user to authenticate, if the user has already been identified.
106+
* <p>
107+
* If this is absent, this indicates that this is a request for an assertion by a <a
108+
* href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#client-side-resident-public-key-credential-source">client-side-resident
109+
* credential</a>, and identification of the user has been deferred until the response is received.
110+
* </p>
111+
*/
112+
public AssertionRequestBuilder username(@NonNull String username) {
113+
return this.username(Optional.of(username));
114+
}
89115
}
90116

91117
}

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,15 @@ public class FinishAssertionOptions {
6161
* @see <a href="https://tools.ietf.org/html/rfc8471">The Token Binding Protocol Version 1.0</a>
6262
*/
6363
@NonNull
64-
@Builder.Default
65-
private final Optional<ByteArray> callerTokenBindingId = Optional.empty();
64+
private final Optional<ByteArray> callerTokenBindingId;
6665

6766
public static FinishAssertionOptionsBuilder.MandatoryStages builder() {
6867
return new FinishAssertionOptionsBuilder.MandatoryStages();
6968
}
7069

7170
public static class FinishAssertionOptionsBuilder {
71+
private Optional<ByteArray> callerTokenBindingId = Optional.empty();
72+
7273
public static class MandatoryStages {
7374
private final FinishAssertionOptionsBuilder builder = new FinishAssertionOptionsBuilder();
7475

@@ -83,6 +84,27 @@ public FinishAssertionOptionsBuilder response(PublicKeyCredential<AuthenticatorA
8384
}
8485
}
8586
}
87+
88+
/**
89+
* The <a href="https://tools.ietf.org/html/rfc8471#section-3.2">token binding ID</a> of the connection to the
90+
* client, if any.
91+
*
92+
* @see <a href="https://tools.ietf.org/html/rfc8471">The Token Binding Protocol Version 1.0</a>
93+
*/
94+
public FinishAssertionOptionsBuilder callerTokenBindingId(@NonNull Optional<ByteArray> callerTokenBindingId) {
95+
this.callerTokenBindingId = callerTokenBindingId;
96+
return this;
97+
}
98+
99+
/**
100+
* The <a href="https://tools.ietf.org/html/rfc8471#section-3.2">token binding ID</a> of the connection to the
101+
* client, if any.
102+
*
103+
* @see <a href="https://tools.ietf.org/html/rfc8471">The Token Binding Protocol Version 1.0</a>
104+
*/
105+
public FinishAssertionOptionsBuilder callerTokenBindingId(@NonNull ByteArray callerTokenBindingId) {
106+
return this.callerTokenBindingId(Optional.of(callerTokenBindingId));
107+
}
86108
}
87109

88110
}

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,15 @@ public class FinishRegistrationOptions {
6262
* @see <a href="https://tools.ietf.org/html/rfc8471">The Token Binding Protocol Version 1.0</a>
6363
*/
6464
@NonNull
65-
@Builder.Default
66-
private final Optional<ByteArray> callerTokenBindingId = Optional.empty();
65+
private final Optional<ByteArray> callerTokenBindingId;
6766

6867
public static FinishRegistrationOptionsBuilder.MandatoryStages builder() {
6968
return new FinishRegistrationOptionsBuilder.MandatoryStages();
7069
}
7170

7271
public static class FinishRegistrationOptionsBuilder {
72+
private Optional<ByteArray> callerTokenBindingId = Optional.empty();
73+
7374
public static class MandatoryStages {
7475
private final FinishRegistrationOptionsBuilder builder = new FinishRegistrationOptionsBuilder();
7576

@@ -84,5 +85,26 @@ public FinishRegistrationOptionsBuilder response(PublicKeyCredential<Authenticat
8485
}
8586
}
8687
}
88+
89+
/**
90+
* The <a href="https://tools.ietf.org/html/rfc8471#section-3.2">token binding ID</a> of the connection to the
91+
* client, if any.
92+
*
93+
* @see <a href="https://tools.ietf.org/html/rfc8471">The Token Binding Protocol Version 1.0</a>
94+
*/
95+
public FinishRegistrationOptionsBuilder callerTokenBindingId(@NonNull Optional<ByteArray> callerTokenBindingId) {
96+
this.callerTokenBindingId = callerTokenBindingId;
97+
return this;
98+
}
99+
100+
/**
101+
* The <a href="https://tools.ietf.org/html/rfc8471#section-3.2">token binding ID</a> of the connection to the
102+
* client, if any.
103+
*
104+
* @see <a href="https://tools.ietf.org/html/rfc8471">The Token Binding Protocol Version 1.0</a>
105+
*/
106+
public FinishRegistrationOptionsBuilder callerTokenBindingId(@NonNull ByteArray callerTokenBindingId) {
107+
return this.callerTokenBindingId(Optional.of(callerTokenBindingId));
108+
}
87109
}
88110
}

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

Lines changed: 124 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,8 @@ public class RelyingParty {
145145
* @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-appid-extension">§10.1. FIDO AppID Extension
146146
* (appid)</a>
147147
*/
148-
@Builder.Default
149148
@NonNull
150-
private final Optional<AppId> appId = Optional.empty();
149+
private final Optional<AppId> appId;
151150

152151
/**
153152
* The argument for the {@link PublicKeyCredentialCreationOptions#getAttestation() attestation} parameter in
@@ -165,9 +164,8 @@ public class RelyingParty {
165164
* @see PublicKeyCredentialCreationOptions#getAttestation()
166165
* @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-attestation">§6.4. Attestation</a>
167166
*/
168-
@Builder.Default
169167
@NonNull
170-
private final Optional<AttestationConveyancePreference> attestationConveyancePreference = Optional.empty();
168+
private final Optional<AttestationConveyancePreference> attestationConveyancePreference;
171169

172170
/**
173171
* A {@link MetadataService} instance to use for looking up device attestation metadata. This matters only if {@link
@@ -180,9 +178,8 @@ public class RelyingParty {
180178
* @see PublicKeyCredentialCreationOptions#getAttestation()
181179
* @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-attestation">§6.4. Attestation</a>
182180
*/
183-
@Builder.Default
184181
@NonNull
185-
private final Optional<MetadataService> metadataService = Optional.empty();
182+
private final Optional<MetadataService> metadataService;
186183

187184
/**
188185
* The argument for the {@link PublicKeyCredentialCreationOptions#getPubKeyCredParams() pubKeyCredParams} parameter
@@ -291,7 +288,7 @@ public PublicKeyCredentialCreationOptions startRegistration(StartRegistrationOpt
291288
.challenge(generateChallenge())
292289
.pubKeyCredParams(preferredPubkeyParams)
293290
.excludeCredentials(
294-
Optional.of(credentialRepository.getCredentialIdsForUsername(startRegistrationOptions.getUser().getName()))
291+
credentialRepository.getCredentialIdsForUsername(startRegistrationOptions.getUser().getName())
295292
)
296293
.authenticatorSelection(startRegistrationOptions.getAuthenticatorSelection())
297294
.extensions(startRegistrationOptions.getExtensions())
@@ -336,7 +333,7 @@ FinishRegistrationSteps _finishRegistration(
336333
public AssertionRequest startAssertion(StartAssertionOptions startAssertionOptions) {
337334
PublicKeyCredentialRequestOptionsBuilder pkcro = PublicKeyCredentialRequestOptions.builder()
338335
.challenge(generateChallenge())
339-
.rpId(Optional.of(identity.getId()))
336+
.rpId(identity.getId())
340337
.allowCredentials(
341338
startAssertionOptions.getUsername().map(un ->
342339
new ArrayList<>(credentialRepository.getCredentialIdsForUsername(un)))
@@ -404,6 +401,10 @@ public static RelyingPartyBuilder.MandatoryStages builder() {
404401
}
405402

406403
public static class RelyingPartyBuilder {
404+
private @NonNull Optional<AppId> appId = Optional.empty();
405+
private @NonNull Optional<AttestationConveyancePreference> attestationConveyancePreference = Optional.empty();
406+
private @NonNull Optional<MetadataService> metadataService = Optional.empty();
407+
407408
public static class MandatoryStages {
408409
private final RelyingPartyBuilder builder = new RelyingPartyBuilder();
409410

@@ -429,5 +430,120 @@ public RelyingPartyBuilder credentialRepository(CredentialRepository credentialR
429430
}
430431
}
431432
}
433+
434+
/**
435+
* The extension input to set for the <code>appid</code> extension when initiating authentication operations.
436+
*
437+
* <p>
438+
* If this member is set, {@link #startAssertion(StartAssertionOptions) startAssertion} will automatically set the
439+
* <code>appid</code> extension input, and {@link #finishAssertion(FinishAssertionOptions) finishAssertion} will
440+
* adjust its verification logic to also accept this AppID as an alternative to the RP ID.
441+
* </p>
442+
*
443+
* <p>
444+
* By default, this is not set.
445+
* </p>
446+
*
447+
* @see AssertionExtensionInputs#getAppid()
448+
* @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-appid-extension">§10.1. FIDO AppID Extension
449+
* (appid)</a>
450+
*/
451+
public RelyingPartyBuilder appId(@NonNull Optional<AppId> appId) {
452+
this.appId = appId;
453+
return this;
454+
}
455+
456+
/**
457+
* The extension input to set for the <code>appid</code> extension when initiating authentication operations.
458+
*
459+
* <p>
460+
* If this member is set, {@link #startAssertion(StartAssertionOptions) startAssertion} will automatically set the
461+
* <code>appid</code> extension input, and {@link #finishAssertion(FinishAssertionOptions) finishAssertion} will
462+
* adjust its verification logic to also accept this AppID as an alternative to the RP ID.
463+
* </p>
464+
*
465+
* <p>
466+
* By default, this is not set.
467+
* </p>
468+
*
469+
* @see AssertionExtensionInputs#getAppid()
470+
* @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-appid-extension">§10.1. FIDO AppID Extension
471+
* (appid)</a>
472+
*/
473+
public RelyingPartyBuilder appId(@NonNull AppId appId) {
474+
return this.appId(Optional.of(appId));
475+
}
476+
477+
/**
478+
* The argument for the {@link PublicKeyCredentialCreationOptions#getAttestation() attestation} parameter in
479+
* registration operations.
480+
*
481+
* <p>
482+
* Unless your application has a concrete policy for authenticator attestation, it is recommended to leave this
483+
* parameter undefined.
484+
* </p>
485+
*
486+
* <p>
487+
* By default, this is not set.
488+
* </p>
489+
*
490+
* @see PublicKeyCredentialCreationOptions#getAttestation()
491+
* @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-attestation">§6.4. Attestation</a>
492+
*/
493+
public RelyingPartyBuilder attestationConveyancePreference(@NonNull Optional<AttestationConveyancePreference> attestationConveyancePreference) {
494+
this.attestationConveyancePreference = attestationConveyancePreference;
495+
return this;
496+
}
497+
498+
/**
499+
* The argument for the {@link PublicKeyCredentialCreationOptions#getAttestation() attestation} parameter in
500+
* registration operations.
501+
*
502+
* <p>
503+
* Unless your application has a concrete policy for authenticator attestation, it is recommended to leave this
504+
* parameter undefined.
505+
* </p>
506+
*
507+
* <p>
508+
* By default, this is not set.
509+
* </p>
510+
*
511+
* @see PublicKeyCredentialCreationOptions#getAttestation()
512+
* @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-attestation">§6.4. Attestation</a>
513+
*/
514+
public RelyingPartyBuilder attestationConveyancePreference(@NonNull AttestationConveyancePreference attestationConveyancePreference) {
515+
return this.attestationConveyancePreference(Optional.of(attestationConveyancePreference));
516+
}
517+
518+
/**
519+
* A {@link MetadataService} instance to use for looking up device attestation metadata. This matters only if {@link
520+
* #getAttestationConveyancePreference()} is non-empty and not set to {@link AttestationConveyancePreference#NONE}.
521+
*
522+
* <p>
523+
* By default, this is not set.
524+
* </p>
525+
*
526+
* @see PublicKeyCredentialCreationOptions#getAttestation()
527+
* @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-attestation">§6.4. Attestation</a>
528+
*/
529+
public RelyingPartyBuilder metadataService(@NonNull Optional<MetadataService> metadataService) {
530+
this.metadataService = metadataService;
531+
return this;
532+
}
533+
534+
/**
535+
* A {@link MetadataService} instance to use for looking up device attestation metadata. This matters only if {@link
536+
* #getAttestationConveyancePreference()} is non-empty and not set to {@link AttestationConveyancePreference#NONE}.
537+
*
538+
* <p>
539+
* By default, this is not set.
540+
* </p>
541+
*
542+
* @see PublicKeyCredentialCreationOptions#getAttestation()
543+
* @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-attestation">§6.4. Attestation</a>
544+
*/
545+
public RelyingPartyBuilder metadataService(@NonNull MetadataService metadataService) {
546+
return this.metadataService(Optional.of(metadataService));
547+
}
432548
}
433549
}

0 commit comments

Comments
 (0)