Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-4556] Add passkey properties to authentication method response #575

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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