Skip to content

WebAuthn Support #15404

Closed
Closed

Description

@dsanders11

Is your feature request related to a problem? Please describe.
Electron doesn't appear to support WebAuthn, giving the error Uncaught (in promise) DOMException: The user agent does not implement a password store. when you attempt to use navigator.credentials.create, which otherwise works in Chromium.

Describe the solution you'd like
WebAuthn should be supported, it allows for strong security and passwordless experiences. It's built-in to Chromium.

Activity

  1. welcome commented on Oct 26, 2018

    @welcome

    👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

    To help make it easier for us to investigate your issue, please follow the contributing guidelines.

  2. dsanders11 commented on Oct 26, 2018

    @dsanders11
    MemberAuthor

    This may be simply because Electron seems to be running M66, and WebAuthn was behind a flag until M68. Unfortunately the error isn't very helpful in figuring that out.

  3. MarshallOfSound commented on Oct 26, 2018

    @MarshallOfSound
    Member

    @dsanders11 Electron 4.x has Chromium 69, can you test on that version?

  4. added
    blocked/need-info ❌
    on Oct 26, 2018
  5. dsanders11 commented on Oct 26, 2018

    @dsanders11
    MemberAuthor

    @MarshallOfSound, it works there. Apologies for the premature issue, I didn't realize the version of Chromium in Electron 3.x was too old to support WebAuthn. In my mind WebAuthn has been in Chromium for over a year because that's how long I've been playing with it, but I forgot it was behind a flag until recently. I'm going to go ahead and close this since Electron 4.x should fix it.

  6. queesamor commented on Oct 26, 2018

    @queesamor

    @dsanders11 Did you happen to specifically test U2F in the E4 beta while you were poking around? I know a whole host of people who would be ecstatic to hear affirmatively that U2F works out of the box in the upcoming Electron version, since many Electron apps with federated login can't currently support the U2F tokens those identity providers require, and WebAuthn is presumably going to natively replace Chrome's current implementation of U2F. 😃

  7. dsanders11 commented on Oct 26, 2018

    @dsanders11
    MemberAuthor

    @queesamor, yes, I've tested it fully now with the Electron 4 beta. Granted, I tested with the Yubico Security Key version which supports both U2F and FIDO2, so I can't know for sure it fully supported legacy U2F, but from what I know about the Chromium implementation of WebAuthn, it should support legacy U2F just fine.

    Anyone looking to test this in the Electron 4 beta can use the following:

    mainWindow = new BrowserWindow({width: 800, height: 600, webPreferences: { nodeIntegration: false })
    mainWindow.loadUrl('https://webauthn.org/')

    Note that disabling Node integration seems important, otherwise that demo site has an error regarding '$' being undefined, which seems related to #345.

  8. queesamor commented on Oct 26, 2018

    @queesamor

    Fantastic news, thank you! A simple adjustment to the libraries on that site will surely solve its specific issue so that disabling node integration isn't required, and presumably any existing apps are already dealing with conflicts in Window in the best way for their own needs.

    Here's to hoping nothing regresses before release of v4! 🤞

  9. MarshallOfSound commented on Oct 26, 2018

    @MarshallOfSound
    Member

    @queesamor You should never load a remote site with node integration enabled. It is a massive security issue and puts all your users at risk

  10. queesamor commented on Oct 26, 2018

    @queesamor

    :blink: :blink:

    I just want to be able to log into Slack with my security key... 🤷‍♂️

  11. dsanders11 commented on Oct 28, 2018

    @dsanders11
    MemberAuthor

    Having played with this some more, I'm running into some issues getting it to work without a server in the loop in Electron. That's a useful use-case as you may want to provide 2FA for an entirely offline app, or allow a security key to be used to login while offline.

    Chromium only allows the WebAuthn API to be used with either https domains (needs a hostname, no bare IP allowed) or http://localhost. For allowing offline usage of an already registered key for login, you'd need to spoof the URL of the site the key was registered at (say, https://github.com). I looked into using protocol interceptors to accomplish this without a server, but had some difficultly there (see #15434). Despite that difficulty, it was at least good enough for a proof-of-concept test, where I ran into the second problem. Changing from the file:// protocol to http:// broke relative file imports between my modules, as the relevant renderer code wasn't run. I again worked around that for a proof-of-concept by simply dumping everything into a single file to sidestep that issue. With that done, the proof-of-concept worked.

    @MarshallOfSound, any suggestions for the relative file path issue? I can at least use http://localhost for development until something like #15434 is implemented, but not being able to split my code into different modules is a much bigger pain in the mean time. There are bundlers like webpack, but they don't always play nice with npm packages made for node I've found. Is there any chance Electron's module importer supports a prefix like '@' or '#' to represent the root project directory?

  12. MarshallOfSound commented on Oct 28, 2018

    @MarshallOfSound
    Member

    @dsanders11 I'd say the best way forward for this is to make it possible for Electron apps to override this limitation

    Chromium only allows the WebAuthn API to be used with either https domains

    Some kind of protocol.registerAuthnProtocol API or similar so that custom protocols or event the file:// protocol could support it. The https limitation only makes sense for remote content in a web context, running a desktop app should allow authn 👍

    EDIT:

    I've only briefly looked into this but I beleive if you render your scheme as standard and secure using the registerStandardSchemes API it should work

  13. dsanders11 commented on Oct 28, 2018

    @dsanders11
    MemberAuthor

    I've only briefly looked into this but I believe if you render your scheme as standard and secure using the registerStandardSchemes API it should work

    @MarshallOfSound This didn't work, the error persists:

    DOMException: Public-key credentials are only available to HTTPS origin or HTTP origins that fall under 'localhost'. See https://crbug.com/824383

    BTW, that was a painful experience. loadUrl('atom:///webauthn.html') actually loads 'atom://webauthn.html' for starters, making the filename the host this was actually an unexpected (to me) result of making it a standard scheme. At this point if getting this to work requires use of the protocol module I wouldn't recommend anyone try it currently, unless they have a high tolerance for quirks and finding workarounds.

    I still don't have a solution for having my code in modules (that require each other) once I switch to custom protocols as I mentioned in the earlier comment.

  14. mahnunchik commented on Jul 16, 2020

    @mahnunchik
    Contributor

    Hi @MarshallOfSound @dsanders11 could you please help me to make WebAuthn works from local file.

    Registering as a standard and secure protocol doesn't help:

    protocol.registerSchemesAsPrivileged([
      { scheme: 'fido', privileges: { standard: true, secure: true } },
    ]);

    More info in my ticket #24573 (fiddle example included)

  15. mahnunchik commented on Sep 29, 2023

    @mahnunchik
    Contributor

    @dsanders11 WebAuthn works in Electron #24573 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked/need-info ❌

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions