|
1 | 1 | /** |
2 | | - * This package makes up the public API of the webauthn-server-core library. |
| 2 | + * This package and its subpackages make up the public API of the webauthn-server-core library. |
3 | 3 | * |
4 | 4 | * <p>The main entry point is the {@link com.yubico.webauthn.RelyingParty} class. It provides |
5 | 5 | * methods for generating inputs to the <code>navigator.credentials.create()</code> and <code> |
|
82 | 82 | * com.yubico.webauthn.data.PublicKeyCredentialCreationOptions} which can be serialized to JSON and |
83 | 83 | * passed as the <code>publicKey</code> argument to <code>navigator.credentials.create()</code>. You |
84 | 84 | * can use the {@link com.yubico.webauthn.data.PublicKeyCredentialCreationOptions#toBuilder() |
85 | | - * toBuilder()} method to make any modifications you need. You should store this in temporary |
86 | | - * storage so that it can later be passed as an argument to {@link |
87 | | - * com.yubico.webauthn.RelyingParty#finishRegistration(FinishRegistrationOptions)}. |
88 | | - * |
89 | | - * <p>After receiving the response from the client, construct a {@link |
90 | | - * com.yubico.webauthn.data.PublicKeyCredential}<{@link |
91 | | - * com.yubico.webauthn.data.AuthenticatorAttestationResponse}, {@link |
92 | | - * com.yubico.webauthn.data.ClientRegistrationExtensionOutputs}> from the response and wrap that |
93 | | - * in a {@link com.yubico.webauthn.FinishRegistrationOptions} along with the {@link |
| 85 | + * toBuilder()} method to make any modifications you need, then the {@link |
| 86 | + * com.yubico.webauthn.data.PublicKeyCredentialCreationOptions#toCredentialsCreateJson()} method is |
| 87 | + * suitable for converting the value to JSON to send to the client. |
| 88 | + * |
| 89 | + * <p>You should also store the {@link com.yubico.webauthn.data.PublicKeyCredentialCreationOptions} |
| 90 | + * object in temporary storage so that it can later be passed as an argument to {@link |
| 91 | + * com.yubico.webauthn.RelyingParty#finishRegistration(FinishRegistrationOptions)}. If you need to |
| 92 | + * serialize the object for storage, the {@link |
| 93 | + * com.yubico.webauthn.data.PublicKeyCredentialCreationOptions#toJson()} and {@link |
| 94 | + * com.yubico.webauthn.data.PublicKeyCredentialCreationOptions#fromJson(java.lang.String)} methods |
| 95 | + * are suitable for serializing to and from a string value. |
| 96 | + * |
| 97 | + * <p>After receiving the response from the client, use the {@link |
| 98 | + * com.yubico.webauthn.data.PublicKeyCredential#parseRegistrationResponseJson(java.lang.String)} |
| 99 | + * function to parse the response and wrap it in a {@link |
| 100 | + * com.yubico.webauthn.FinishRegistrationOptions} along with the {@link |
94 | 101 | * com.yubico.webauthn.data.PublicKeyCredentialCreationOptions} used to initiate the request. Pass |
95 | 102 | * that as the argument to {@link |
96 | 103 | * com.yubico.webauthn.RelyingParty#finishRegistration(FinishRegistrationOptions)}, which will |
|
107 | 114 | * com.yubico.webauthn.RegistrationResult#getPublicKeyCose() publicKeyCose} as a new |
108 | 115 | * credential for the user. The {@link com.yubico.webauthn.CredentialRepository} will need to |
109 | 116 | * look these up for authentication. |
| 117 | + * <li>Store the {@link com.yubico.webauthn.RegistrationResult#getSignatureCount() signature |
| 118 | + * counter} value in the new credential. If available, this will be used in future |
| 119 | + * authentication ceremonies do detect authenticator cloning. |
| 120 | + * <li>Optionally, store the {@link com.yubico.webauthn.RegistrationResult#isDiscoverable() |
| 121 | + * isDiscoverable} flag, if present, in the new credential. This may help you determine which |
| 122 | + * user interaction flows are possible with which credential. |
110 | 123 | * <li>If you care about authenticator attestation, check that the {@link |
111 | 124 | * com.yubico.webauthn.RegistrationResult#isAttestationTrusted() attestationTrusted} field |
112 | 125 | * satisfies your attestation policy. For this you will likely need to configure the {@link |
113 | 126 | * com.yubico.webauthn.RelyingParty.RelyingPartyBuilder#attestationTrustSource(com.yubico.webauthn.attestation.AttestationTrustSource) |
114 | 127 | * attestationTrustSource} setting on your {@link com.yubico.webauthn.RelyingParty} instance. |
115 | | - * You may also want to consult some external data source to verify the authenticity of the |
116 | | - * {@link com.yubico.webauthn.data.AuthenticatorAttestationResponse#getAttestationObject() |
117 | | - * attestation object}. |
| 128 | + * See also the <code>webauthn-server-attestation</code> for an implementation of such an |
| 129 | + * attestation trust and metadata source. |
118 | 130 | * <li>If you care about authenticator attestation, it is recommended to also store the raw {@link |
119 | 131 | * com.yubico.webauthn.data.AuthenticatorAttestationResponse#getAttestationObject() |
120 | 132 | * attestation object} as part of the credential. This enables you to retroactively inspect |
|
130 | 142 | * com.yubico.webauthn.RelyingParty#startAssertion(StartAssertionOptions)}. The main parameter you |
131 | 143 | * need to set here is the {@link |
132 | 144 | * com.yubico.webauthn.StartAssertionOptions.StartAssertionOptionsBuilder#username(java.util.Optional) |
133 | | - * username} of the user to authenticate, but even this parameter is optional. If the username is |
134 | | - * not set, then the {@link |
| 145 | + * username} or {@link |
| 146 | + * com.yubico.webauthn.StartAssertionOptions.StartAssertionOptionsBuilder#userHandle(java.util.Optional) |
| 147 | + * user handle} of the user to authenticate, but even these parameters are optional. If neither is |
| 148 | + * set, then the {@link |
135 | 149 | * com.yubico.webauthn.data.PublicKeyCredentialRequestOptions#getAllowCredentials() |
136 | | - * allowCredentials} parameter will not be set. This which means the user must use a <a |
137 | | - * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#client-side-discoverable-public-key-credential-source">client-side-resident |
| 150 | + * allowCredentials} parameter will not be set. This means the user must use a <a |
| 151 | + * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#client-side-discoverable-public-key-credential-source">client-side-discoverable |
138 | 152 | * credential</a> to authenticate; also known as "first-factor authentication". This use case has |
139 | 153 | * both advantages and disadvantages; see the Web Authentication specification for an extended |
140 | 154 | * discussion of this. |
|
143 | 157 | * startAssertion} method returns an {@link com.yubico.webauthn.AssertionRequest} containing the |
144 | 158 | * username, if any, and a {@link com.yubico.webauthn.data.PublicKeyCredentialRequestOptions} |
145 | 159 | * instance which can be serialized to JSON and passed as the <code>publicKey</code> argument to |
146 | | - * <code>navigator.credentials.get()</code>. Again, store the {@link |
147 | | - * com.yubico.webauthn.AssertionRequest} in temporary storage so it can be passed as an argument to |
148 | | - * {@link |
| 160 | + * <code>navigator.credentials.get()</code>. Again, use {@link |
| 161 | + * com.yubico.webauthn.AssertionRequest#toBuilder()} to make any necessary changes, {@link |
| 162 | + * com.yubico.webauthn.AssertionRequest#toCredentialsGetJson()} to convert it to JSON for sending to |
| 163 | + * the client, and store the {@link com.yubico.webauthn.AssertionRequest} in temporary storage so it |
| 164 | + * can be passed as an argument to {@link |
149 | 165 | * com.yubico.webauthn.RelyingParty#finishAssertion(com.yubico.webauthn.FinishAssertionOptions)}. |
150 | | - * |
151 | | - * <p>After receiving the response from the client, construct a {@link |
152 | | - * com.yubico.webauthn.data.PublicKeyCredential}<{@link |
153 | | - * com.yubico.webauthn.data.AuthenticatorAssertionResponse}, {@link |
154 | | - * com.yubico.webauthn.data.ClientAssertionExtensionOutputs}> from the response and wrap that in |
155 | | - * a {@link com.yubico.webauthn.FinishAssertionOptions} along with the {@link |
156 | | - * com.yubico.webauthn.AssertionRequest} used to initiate the request. Pass that as the argument to |
157 | | - * {@link |
| 166 | + * Again, {@link com.yubico.webauthn.AssertionRequest#toJson()} and {@link |
| 167 | + * com.yubico.webauthn.AssertionRequest#fromJson(java.lang.String)} can be used to convert to and |
| 168 | + * from JSON for storage. |
| 169 | + * |
| 170 | + * <p>After receiving the response from the client, use {@link |
| 171 | + * com.yubico.webauthn.data.PublicKeyCredential#parseAssertionResponseJson(java.lang.String)} to |
| 172 | + * parse the response, then wrap that in a {@link com.yubico.webauthn.FinishAssertionOptions} along |
| 173 | + * with the {@link com.yubico.webauthn.AssertionRequest} used to initiate the request. Pass that as |
| 174 | + * the argument to {@link |
158 | 175 | * com.yubico.webauthn.RelyingParty#finishAssertion(com.yubico.webauthn.FinishAssertionOptions)}, |
159 | 176 | * which will return an {@link com.yubico.webauthn.AssertionResult} if successful and throw an |
160 | 177 | * exception if not. Regardless of whether it succeeds, you should remove the {@link |
|
0 commit comments