@@ -155,9 +155,11 @@ RelyingParty rp = RelyingParty.builder()
155
155
A registration ceremony consists of 5 main steps:
156
156
157
157
1. Generate registration parameters using `RelyingParty.startRegistration(...)`.
158
- 2. Send registration parameters to the client and call `navigator.credentials.create()`.
158
+ 2. Send registration parameters to the client and call
159
+ https://developer.mozilla.org/en-US/docs/Web/API/CredentialsContainer/create[`navigator.credentials.create()`].
159
160
3. With `cred` as the result of the successfully resolved promise,
160
- call `cred.getClientExtensionResults()` and `cred.response.getTransports()`
161
+ call https://www.w3.org/TR/webauthn-2/#ref-for-dom-publickeycredential-getclientextensionresults[`cred.getClientExtensionResults()`]
162
+ and https://www.w3.org/TR/webauthn-2/#ref-for-dom-authenticatorattestationresponse-gettransports[`cred.response.getTransports()`]
161
163
and return their results along with `cred` to the server.
162
164
4. Validate the response using `RelyingParty.finishRegistration(...)`.
163
165
5. Update your database using the `finishRegistration` output.
@@ -230,6 +232,7 @@ PublicKeyCredential<AuthenticatorAttestationResponse, ClientRegistrationExtensio
230
232
try {
231
233
RegistrationResult result = rp.finishRegistration(FinishRegistrationOptions.builder()
232
234
.request(request) // The PublicKeyCredentialCreationOptions from startRegistration above
235
+ // NOTE: Must be stored in server memory or otherwise protected against tampering
233
236
.response(pkc)
234
237
.build());
235
238
} catch (RegistrationFailedException e) { /* ... */ }
@@ -242,7 +245,7 @@ Here's an example of things you'll likely want to store:
242
245
----------
243
246
storeCredential( // Some database access method of your own design
244
247
"alice", // Username or other appropriate user identifier
245
- result.getKeyId(), // Credential ID for allowCredentials
248
+ result.getKeyId(), // Credential ID and transports for allowCredentials
246
249
result.getPublicKeyCose(), // Public key for verifying authentication signatures
247
250
result.isDiscoverable(), // Can this key be used for username-less auth?
248
251
result.getTransports(), // Transport hints to put in allowCredentials along with ID
@@ -258,9 +261,12 @@ storeCredential( // Some database access method of your own design
258
261
Like registration ceremonies, an authentication ceremony consists of 5 main steps:
259
262
260
263
1. Generate authentication parameters using `RelyingParty.startAssertion(...)`.
261
- 2. Send authentication parameters to the client, call `navigator.credentials.get()` and return the response.
262
- 3. With `cred` as the result of the successfully resolved promise,
263
- call `cred.getClientExtensionResults()` and return the result along with `cred` to the server.
264
+ 2. Send authentication parameters to the client, call
265
+ https://developer.mozilla.org/en-US/docs/Web/API/CredentialsContainer/get[`navigator.credentials.get()`]
266
+ and return the response.
267
+ 3. With `cred` as the result of the successfully resolved promise, call
268
+ https://www.w3.org/TR/webauthn-2/#ref-for-dom-publickeycredential-getclientextensionresults[`cred.getClientExtensionResults()`]
269
+ and return the result along with `cred` to the server.
264
270
4. Validate the response using `RelyingParty.finishAssertion(...)`.
265
271
5. Update your database using the `finishAssertion` output, and act upon the result (for example, grant login access).
266
272
@@ -269,7 +275,7 @@ First, generate authentication parameters and send them to the client:
269
275
[source,java]
270
276
----------
271
277
AssertionRequest request = rp.startAssertion(StartAssertionOptions.builder()
272
- .username(Optional.of( "alice") ) // Omit for username-less login
278
+ .username("alice") // Omit for username-less login
273
279
.build());
274
280
String credentialGetJson = request.toCredentialGetJson();
275
281
return credentialGetJson; // Send to client
0 commit comments