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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃殌 Feature]: Add virtual authenticator support for all Selenium language bindings #10541

Closed
pujagani opened this issue Apr 13, 2022 · 7 comments
Milestone

Comments

@pujagani
Copy link
Contributor

Feature and motivation

Applications often integrate WebAuthn as part of the login step. This triggers a WebAuthn browser-specific WebAuthn flow.
Example of WebAuthn in Chrome:
Screenshot 2022-04-13 at 6 02 36 PM

Automating interaction with the WebAuthn dialog, as shown above, is possible via the extension VirtualAuthenticator APIs defined as part of https://w3c.github.io/webauthn/#sctn-automation.

Implementation

Implementation for Java was added as part of #7760 and #7842. The rest of the language bindings need to add the relevant code and can refer to the Java implementation for guidance.

An outline of implementing VirtualAuthenticator

  1. VirtualAuthenticatorOptions (this is used when adding the VirtualAuthenticator)
  2. Credential (The credentials to be used by the VirtualAuthenticator)
  3. List of methods (which call the WebDriver commands) and the respective parameters required:
  • addVirtualAuthenticator(VirtualAuthenticatorOptions options) - Returns an authenticator id as a string
  • removeVirtualAuthenticator (String authenticatorId)
  • addCredential(Credential credential, String authenticatorId)
  • getCredentials(String authenticatorId) - Returns a Map<String,Object>
  • removeCredential(byte[] credentialId, String authenticatorId)
  • removeCredential(String credentialId, String authenticatorId)
  • removeAllCredentials(String authenticatorId)
  • setUserVerified(boolean verified, String authenticatorId)
    Refer:
    public VirtualAuthenticator addVirtualAuthenticator(VirtualAuthenticatorOptions options) {

    private class RemoteVirtualAuthenticator implements VirtualAuthenticator {

Tests are defined in https://github.com/SeleniumHQ/selenium/blob/trunk/java/test/org/openqa/selenium/virtualauthenticator/VirtualAuthenticatorTest.java

Note: Currently, only chromium-based browsers implement the WebAuthn APIs. Though Java does not do it, till the rest of the vendors implement it might be a good idea for the VirtualAuthenticator APIs to sit in the chromium section of each binding (similar to the current implementation of Permissions API).

C#
It can follow the Java implementation since both are strongly typed. C# binding has similar interface declarations as Java for existing features (example: HasPermissions).

Ruby
All extension APIs are defined in https://github.com/SeleniumHQ/selenium/tree/39dec028673260e8a9518898fe40a910426adc85/rb/lib/selenium/webdriver/common/driver_extensions. Similarly, has_virtualauthenticator interface can be implemented and added here and used in the chromium module.

Python
Chromium-specific Selenium commands in python are in https://github.com/SeleniumHQ/selenium/blob/trunk/py/selenium/webdriver/chromium/webdriver.py
VirtualAuthenticator commands can be added here and authentication id can be defined as a local variable.

Javascript
Chromium-specific Selenium commands in javascript are in https://github.com/SeleniumHQ/selenium/blob/trunk/javascript/node/selenium-webdriver/chromium.js
VirtualAuthenticator commands can be added here and authentication id can be defined as a local variable.

Usage example

A sample java example:

    WebDriver driver = new ChromeDriver();
   
    HasVirtualAuthenticator virtualAuthenticatorManager = ((HasVirtualAuthenticator) driver);

    VirtualAuthenticatorOptions options = new VirtualAuthenticatorOptions();
    options.setIsUserConsenting(true);
    options.setProtocol(VirtualAuthenticatorOptions.Protocol.U2F);
    options.setTransport(VirtualAuthenticatorOptions.Transport.USB);
    
    VirtualAuthenticator authenticator = virtualAuthenticatorManager.addVirtualAuthenticator(options);
    authenticator.setUserVerified(true);
@github-actions
Copy link

@pujagani, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@SinghHrmn
Copy link
Contributor

I'll start working on the Py binding.

@TamsilAmani
Copy link
Contributor

Starting to work on nodejs binding.

@SinghHrmn
Copy link
Contributor

SinghHrmn commented May 4, 2022

Feature Update

Virtual Authenticator changes needs to be implemented in the common WebDriver Methods. Currently, only Chromium browsers [Edge/Chrome] support Virtual Authenticator stuff. By adding it in common, it will insure that Firefox/Safari changes are smooth.

Steps to Follow

  • Add a method that will check if the browser is Firefox or Safari and respond with a proper message like Virtual Authentication stuff is only available in chromium based browsers.
  • In Future if Firefox/Safari implement Virtual Authentication we'll remove this check

See Example: #10579

pujagani pushed a commit that referenced this issue May 5, 2022
Co-authored-by: David Burns <david.burns@theautomatedtester.co.uk>
Related to #10541
@titusfortner titusfortner added this to the 4.3 milestone May 10, 2022
@symonk symonk removed the C-py label May 14, 2022
@symonk
Copy link
Member

symonk commented May 14, 2022

@titusfortner @SinghHrmn removed C-py here as to my understanding this is done as far as python is concerned

TamsilAmani added a commit to TamsilAmani/selenium that referenced this issue May 18, 2022
TamsilAmani added a commit to TamsilAmani/selenium that referenced this issue May 20, 2022
harsha509 added a commit that referenced this issue May 31, 2022
* [JS] feat: Added virtual authenticator

Relates #10541

* [JS] fix: code review changes

Co-authored-by: Puja Jagani <puja.jagani93@gmail.com>
Co-authored-by: Sri Harsha <12621691+harsha509@users.noreply.github.com>
@diemol diemol removed the C-nodejs label May 31, 2022
@diemol
Copy link
Member

diemol commented May 31, 2022

Removed NodeJS label as the PR was merged

elgatov pushed a commit to elgatov/selenium that referenced this issue Jun 27, 2022
Co-authored-by: David Burns <david.burns@theautomatedtester.co.uk>
Related to SeleniumHQ#10541
elgatov pushed a commit to elgatov/selenium that referenced this issue Jun 27, 2022
* [JS] feat: Added virtual authenticator

Relates SeleniumHQ#10541

* [JS] fix: code review changes

Co-authored-by: Puja Jagani <puja.jagani93@gmail.com>
Co-authored-by: Sri Harsha <12621691+harsha509@users.noreply.github.com>
@titusfortner titusfortner modified the milestones: 4.3, 4.4 Jul 1, 2022
@pujagani pujagani removed the C-dotnet label Jul 20, 2022
@github-actions
Copy link

github-actions bot commented Sep 4, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants