Skip to content

Commit fb0de20

Browse files
authored
[SDK-4556] Add passkey properties to authentication method response (#575)
1 parent a1b7ffc commit fb0de20

3 files changed

Lines changed: 57 additions & 2 deletions

File tree

src/main/java/com/auth0/json/mgmt/users/authenticationmethods/AuthenticationMethod.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ public class AuthenticationMethod {
4040
private String relyingPartyIdentifier;
4141
@JsonProperty("authentication_methods")
4242
private List<AuthMethod> authenticationMethods;
43+
@JsonProperty("credential_device_type")
44+
private String credentialDeviceType;
45+
@JsonProperty("credential_backed_up")
46+
private Boolean credentialBackedUp;
47+
@JsonProperty("identity_user_id")
48+
private String identityUserId;
49+
@JsonProperty("user_agent")
50+
private String userAgent;
4351

4452
/**
4553
* Create a new instance.
@@ -243,4 +251,40 @@ public void setRelyingPartyIdentifier(String relyingPartyIdentifier) {
243251
public List<AuthMethod> getAuthenticationMethods() {
244252
return authenticationMethods;
245253
}
254+
255+
/**
256+
* Applies to passkeys only.
257+
*
258+
* @return The kind of device the credential is stored on as defined by backup eligibility. "single_device" credentials cannot be backed up and synced to another device, "multi_device" credentials can be backed up if enabled by the end-user.
259+
*/
260+
public String getCredentialDeviceType() {
261+
return credentialDeviceType;
262+
}
263+
264+
/**
265+
* Applies to passkeys only.
266+
*
267+
* @return Whether the credential was backed up.
268+
*/
269+
public Boolean getCredentialBackedUp() {
270+
return credentialBackedUp;
271+
}
272+
273+
/**
274+
* Applies to passkeys only.
275+
*
276+
* @return The ID of the user identity linked with the authentication method.
277+
*/
278+
public String getIdentityUserId() {
279+
return identityUserId;
280+
}
281+
282+
/**
283+
* Applies to passkeys only.
284+
*
285+
* @return The user-agent of the browser used to create the passkey.
286+
*/
287+
public String getUserAgent() {
288+
return userAgent;
289+
}
246290
}

src/test/java/com/auth0/json/mgmt/users/authenticationmethods/AuthenticationMethodTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ public void shouldDeserialize() throws Exception {
3030
" \"totp_secret\":\"totp\",\n" +
3131
" \"preferred_authentication_method\":\"phone\",\n" +
3232
" \"relying_party_identifier\":\"abc\",\n" +
33-
" \"authentication_methods\":[{\"id\": \"id\", \"type\": \"type\"}]\n" +
33+
" \"authentication_methods\":[{\"id\": \"id\", \"type\": \"type\"}],\n" +
34+
" \"credential_device_type\": \"single_device\",\n" +
35+
" \"credential_backed_up\": true,\n" +
36+
" \"identity_user_id\": \"identityId\",\n" +
37+
" \"user_agent\": \"userAgent\"" +
3438
" }";
3539

3640

@@ -54,7 +58,10 @@ public void shouldDeserialize() throws Exception {
5458
assertThat(authenticationMethod.getAuthenticationMethods(), hasSize(1));
5559
assertThat(authenticationMethod.getAuthenticationMethods().get(0).getId(), is("id"));
5660
assertThat(authenticationMethod.getAuthenticationMethods().get(0).getType(), is("type"));
57-
61+
assertThat(authenticationMethod.getCredentialDeviceType(), is("single_device"));
62+
assertThat(authenticationMethod.getCredentialBackedUp(), is(true));
63+
assertThat(authenticationMethod.getIdentityUserId(), is("identityId"));
64+
assertThat(authenticationMethod.getUserAgent(), is("userAgent"));
5865
}
5966

6067
@Test

src/test/resources/mgmt/authenticator_method_list.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"created_at": "2023-02-01T18:44:46.483Z",
88
"last_auth_at": "2023-02-07T20:29:33.547Z",
99
"preferred_authentication_method": "sms",
10+
"credential_device_type": "single_device",
11+
"credential_backed_up": true,
12+
"identity_user_id": "identityId",
13+
"user_agent": "userAgent",
1014
"authentication_methods": [
1115
{
1216
"id": "sms|id",

0 commit comments

Comments
 (0)