Skip to content

Commit

Permalink
[SDK-4556] Add passkey properties to authentication method response (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyjames committed Oct 25, 2023
1 parent a1b7ffc commit fb0de20
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public class AuthenticationMethod {
private String relyingPartyIdentifier;
@JsonProperty("authentication_methods")
private List<AuthMethod> authenticationMethods;
@JsonProperty("credential_device_type")
private String credentialDeviceType;
@JsonProperty("credential_backed_up")
private Boolean credentialBackedUp;
@JsonProperty("identity_user_id")
private String identityUserId;
@JsonProperty("user_agent")
private String userAgent;

/**
* Create a new instance.
Expand Down Expand Up @@ -243,4 +251,40 @@ public void setRelyingPartyIdentifier(String relyingPartyIdentifier) {
public List<AuthMethod> getAuthenticationMethods() {
return authenticationMethods;
}

/**
* Applies to passkeys only.
*
* @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.
*/
public String getCredentialDeviceType() {
return credentialDeviceType;
}

/**
* Applies to passkeys only.
*
* @return Whether the credential was backed up.
*/
public Boolean getCredentialBackedUp() {
return credentialBackedUp;
}

/**
* Applies to passkeys only.
*
* @return The ID of the user identity linked with the authentication method.
*/
public String getIdentityUserId() {
return identityUserId;
}

/**
* Applies to passkeys only.
*
* @return The user-agent of the browser used to create the passkey.
*/
public String getUserAgent() {
return userAgent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ public void shouldDeserialize() throws Exception {
" \"totp_secret\":\"totp\",\n" +
" \"preferred_authentication_method\":\"phone\",\n" +
" \"relying_party_identifier\":\"abc\",\n" +
" \"authentication_methods\":[{\"id\": \"id\", \"type\": \"type\"}]\n" +
" \"authentication_methods\":[{\"id\": \"id\", \"type\": \"type\"}],\n" +
" \"credential_device_type\": \"single_device\",\n" +
" \"credential_backed_up\": true,\n" +
" \"identity_user_id\": \"identityId\",\n" +
" \"user_agent\": \"userAgent\"" +
" }";


Expand All @@ -54,7 +58,10 @@ public void shouldDeserialize() throws Exception {
assertThat(authenticationMethod.getAuthenticationMethods(), hasSize(1));
assertThat(authenticationMethod.getAuthenticationMethods().get(0).getId(), is("id"));
assertThat(authenticationMethod.getAuthenticationMethods().get(0).getType(), is("type"));

assertThat(authenticationMethod.getCredentialDeviceType(), is("single_device"));
assertThat(authenticationMethod.getCredentialBackedUp(), is(true));
assertThat(authenticationMethod.getIdentityUserId(), is("identityId"));
assertThat(authenticationMethod.getUserAgent(), is("userAgent"));
}

@Test
Expand Down
4 changes: 4 additions & 0 deletions src/test/resources/mgmt/authenticator_method_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"created_at": "2023-02-01T18:44:46.483Z",
"last_auth_at": "2023-02-07T20:29:33.547Z",
"preferred_authentication_method": "sms",
"credential_device_type": "single_device",
"credential_backed_up": true,
"identity_user_id": "identityId",
"user_agent": "userAgent",
"authentication_methods": [
{
"id": "sms|id",
Expand Down

0 comments on commit fb0de20

Please sign in to comment.