Skip to content

Add support to debug virtual authenticators#7842

Merged
shs96c merged 14 commits intoSeleniumHQ:masterfrom
nsatragno:webauthn_java_followup
Dec 11, 2019
Merged

Add support to debug virtual authenticators#7842
shs96c merged 14 commits intoSeleniumHQ:masterfrom
nsatragno:webauthn_java_followup

Conversation

@nsatragno
Copy link
Copy Markdown
Contributor

Description

This patch adds support for the addCredential, getCredentials, removeCredential, removeAllCredentials and setUserVerified commands of the WebAuthn automation API.

To add these methods directly into the VirtualAuthenticator class, I extracted it into an interface and implemented a RemoteVirtualAuthenticator as inner class of RemoteWebDriver.

Motivation and Context

Support more WebAuthn use cases:

  • Trying an assertion without having to create a credential first.
  • Handle user verification failures.
  • Use specific private keys to back credentials.
  • Handle credentials being cleared from an authenticator gracefully.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Fixes #7829

Copy link
Copy Markdown
Member

@shs96c shs96c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. Thank you! I love that it has tests too :) I'll wait for your comments before landing this. Feel free to disagree with anything: a lot of my comments are just questions.

Comment thread java/client/src/org/openqa/selenium/virtualauthenticator/Credential.java Outdated

public Map<String, Object> toMap() {
Base64.Encoder encoder = Base64.getUrlEncoder();
HashMap<String, Object> map = new HashMap();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Map on the LHS.

It doesn't matter a huge amount, but I'm curious why you've used ImmutableMap elsewhere and not here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an earlier version of my patch modified the map in place on RemoteWebDriver. Changed to ImmutableMap here and in VirtualAuthenticatorOptions for consistency. This means I had to add guava as a dependency to the bazel package -- ptal.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! We strive to make sure that the selenium-api doesn't need any third party libraries. If we want this to be immutable, the only Java 8 option is to use Collections.unmodifiableMap. The Map.of() method from Java 11 would be better, but we can't use that yet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the dependency and used Collections.unmodifiableMap instead. Please take a look.

@claassistantio
Copy link
Copy Markdown

claassistantio commented Dec 5, 2019

CLA assistant check
All committers have signed the CLA.

@nsatragno nsatragno force-pushed the webauthn_java_followup branch from 9b63b59 to 3d7ef7b Compare December 5, 2019 19:52
Copy link
Copy Markdown
Contributor Author

@nsatragno nsatragno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your quick review! Comments addressed below:

Comment thread java/client/src/org/openqa/selenium/virtualauthenticator/Credential.java Outdated

public Map<String, Object> toMap() {
Base64.Encoder encoder = Base64.getUrlEncoder();
HashMap<String, Object> map = new HashMap();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an earlier version of my patch modified the map in place on RemoteWebDriver. Changed to ImmutableMap here and in VirtualAuthenticatorOptions for consistency. This means I had to add guava as a dependency to the bazel package -- ptal.

@nsatragno nsatragno requested a review from shs96c December 5, 2019 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement the rest of the WebAuthn automation methods

3 participants