Skip to content

Add support to debug virtual authenticators #7842

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

Merged
merged 14 commits into from
Dec 11, 2019

Conversation

nsatragno
Copy link
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
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.


public Map<String, Object> toMap() {
Base64.Encoder encoder = Base64.getUrlEncoder();
HashMap<String, Object> map = new HashMap();
Copy link
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
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
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
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

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
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:


public Map<String, Object> toMap() {
Base64.Encoder encoder = Base64.getUrlEncoder();
HashMap<String, Object> map = new HashMap();
Copy link
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