Skip to content

Commit 4f0e12e

Browse files
committed
Refine getting started in README
1 parent 840c4c2 commit 4f0e12e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

README

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,11 @@ RelyingParty rp = RelyingParty.builder()
155155
A registration ceremony consists of 5 main steps:
156156

157157
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()`].
159160
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()`]
161163
and return their results along with `cred` to the server.
162164
4. Validate the response using `RelyingParty.finishRegistration(...)`.
163165
5. Update your database using the `finishRegistration` output.
@@ -230,6 +232,7 @@ PublicKeyCredential<AuthenticatorAttestationResponse, ClientRegistrationExtensio
230232
try {
231233
RegistrationResult result = rp.finishRegistration(FinishRegistrationOptions.builder()
232234
.request(request) // The PublicKeyCredentialCreationOptions from startRegistration above
235+
// NOTE: Must be stored in server memory or otherwise protected against tampering
233236
.response(pkc)
234237
.build());
235238
} catch (RegistrationFailedException e) { /* ... */ }
@@ -242,7 +245,7 @@ Here's an example of things you'll likely want to store:
242245
----------
243246
storeCredential( // Some database access method of your own design
244247
"alice", // Username or other appropriate user identifier
245-
result.getKeyId(), // Credential ID for allowCredentials
248+
result.getKeyId(), // Credential ID and transports for allowCredentials
246249
result.getPublicKeyCose(), // Public key for verifying authentication signatures
247250
result.isDiscoverable(), // Can this key be used for username-less auth?
248251
result.getTransports(), // Transport hints to put in allowCredentials along with ID
@@ -258,9 +261,12 @@ storeCredential( // Some database access method of your own design
258261
Like registration ceremonies, an authentication ceremony consists of 5 main steps:
259262

260263
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.
264270
4. Validate the response using `RelyingParty.finishAssertion(...)`.
265271
5. Update your database using the `finishAssertion` output, and act upon the result (for example, grant login access).
266272

@@ -269,7 +275,7 @@ First, generate authentication parameters and send them to the client:
269275
[source,java]
270276
----------
271277
AssertionRequest request = rp.startAssertion(StartAssertionOptions.builder()
272-
.username(Optional.of("alice")) // Omit for username-less login
278+
.username("alice") // Omit for username-less login
273279
.build());
274280
String credentialGetJson = request.toCredentialGetJson();
275281
return credentialGetJson; // Send to client

0 commit comments

Comments
 (0)