forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: WebAuthn Discoverable Credential (Resident Credential) electron#…
…33353 Enables support for Webauthn discoverable credentials (aka resident credentials). This allows users to authenticate without first having to select or type a username. To decide if discoverable credentials are supported, the class 'AuthenticatorCommon', in the chrome content code, indirectly calls the method 'context::WebAuthenticationDelegate.SupportsResidentKeys(..)'. The default implementation of this returns false, leaving it up to specific implementations to override. This change adds a new class 'ElectronWebAuthenticationDelegate' to subclass 'WebAuthenticationDelegate' and override the behaviour of the 'SupportsResidentKeys' method to return true. The implementation is copied from the Chrome browser equivalent 'ChromeWebAuthenticationDelegate', though the chrome class includes other methods that don't seem to be required for this functionality. The 'ElectronContentClient' class was also updated to store an instance of 'ElectronWebAuthenticationDelegate', and to provide an accessor method, GetWebAuthenticationDelegate().
- Loading branch information
1 parent
a8934d2
commit e62adbd
Showing
5 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
shell/browser/webauthn/electron_authenticator_request_delegate.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "shell/browser/webauthn/electron_authenticator_request_delegate.h" | ||
|
||
namespace electron { | ||
// --------------------------------------------------------------------- | ||
// ElectronWebAuthenticationDelegate | ||
// --------------------------------------------------------------------- | ||
|
||
ElectronWebAuthenticationDelegate::~ElectronWebAuthenticationDelegate() = | ||
default; | ||
|
||
#if !BUILDFLAG(IS_ANDROID) | ||
bool ElectronWebAuthenticationDelegate::SupportsResidentKeys( | ||
content::RenderFrameHost* render_frame_host) { | ||
return true; | ||
} | ||
|
||
#endif // !IS_ANDROID | ||
|
||
} // namespace electron |
64 changes: 64 additions & 0 deletions
64
shell/browser/webauthn/electron_authenticator_request_delegate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef ELECTRON_BROWSER_WEBAUTHN_CHROME_AUTHENTICATOR_REQUEST_DELEGATE_H_ | ||
#define ELECTRON_BROWSER_WEBAUTHN_CHROME_AUTHENTICATOR_REQUEST_DELEGATE_H_ | ||
|
||
#include "content/public/browser/authenticator_request_client_delegate.h" | ||
|
||
namespace electron { | ||
// ElectronWebAuthenticationDelegate is the //Electron layer implementation of | ||
// content::WebAuthenticationDelegate. | ||
class ElectronWebAuthenticationDelegate | ||
: public content::WebAuthenticationDelegate { | ||
public: | ||
#if BUILDFLAG(IS_MAC) | ||
// Returns a configuration struct for instantiating the macOS WebAuthn | ||
// platform authenticator for the given Profile. | ||
static TouchIdAuthenticatorConfig TouchIdAuthenticatorConfigForProfile( | ||
Profile* profile); | ||
#endif // BUILDFLAG(IS_MAC) | ||
|
||
~ElectronWebAuthenticationDelegate() override; | ||
|
||
#if !BUILDFLAG(IS_ANDROID) | ||
// content::WebAuthenticationDelegate: | ||
// bool OverrideCallerOriginAndRelyingPartyIdValidation( | ||
// content::BrowserContext* browser_context, | ||
// const url::Origin& caller_origin, | ||
// const std::string& relying_party_id) override; | ||
// bool OriginMayUseRemoteDesktopClientOverride( | ||
// content::BrowserContext* browser_context, | ||
// const url::Origin& caller_origin) override; | ||
// absl::optional<std::string> MaybeGetRelyingPartyIdOverride( | ||
// const std::string& claimed_relying_party_id, | ||
// const url::Origin& caller_origin) override; | ||
// bool ShouldPermitIndividualAttestation( | ||
// content::BrowserContext* browser_context, | ||
// const url::Origin& caller_origin, | ||
// const std::string& relying_party_id) override; | ||
bool SupportsResidentKeys( | ||
content::RenderFrameHost* render_frame_host) override; | ||
// bool IsFocused(content::WebContents* web_contents) override; | ||
// absl::optional<bool> IsUserVerifyingPlatformAuthenticatorAvailableOverride( | ||
// content::RenderFrameHost* render_frame_host) override; | ||
// content::WebAuthenticationRequestProxy* MaybeGetRequestProxy( | ||
// content::BrowserContext* browser_context) override; | ||
#endif | ||
// #if BUILDFLAG(IS_WIN) | ||
// void OperationSucceeded(content::BrowserContext* browser_context, | ||
// bool used_win_api) override; | ||
// #endif | ||
// #if BUILDFLAG(IS_MAC) | ||
// absl::optional<TouchIdAuthenticatorConfig> GetTouchIdAuthenticatorConfig( | ||
// content::BrowserContext* browser_context) override; | ||
// #endif // BUILDFLAG(IS_MAC) | ||
// #if BUILDFLAG(IS_CHROMEOS) | ||
// ChromeOSGenerateRequestIdCallback GetGenerateRequestIdCallback( | ||
// content::RenderFrameHost* render_frame_host) override; | ||
// #endif // BUILDFLAG(IS_CHROMEOS) | ||
}; | ||
|
||
} // namespace electron | ||
#endif |