This repository has been archived by the owner on Oct 30, 2023. It is now read-only.
forked from electron/electron
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…
…#35374) * 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(). * Remove redundant, commented-out code * style: comment cleanup * style: updated comments and formatting based on pull request review * style: fix lint error on header guard clause
- Loading branch information
1 parent
d85c58d
commit de96d3b
Showing
5 changed files
with
57 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
17 changes: 17 additions & 0 deletions
17
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,17 @@ | ||
// Copyright (c) 2022 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "shell/browser/webauthn/electron_authenticator_request_delegate.h" | ||
|
||
namespace electron { | ||
|
||
ElectronWebAuthenticationDelegate::~ElectronWebAuthenticationDelegate() = | ||
default; | ||
|
||
bool ElectronWebAuthenticationDelegate::SupportsResidentKeys( | ||
content::RenderFrameHost* render_frame_host) { | ||
return true; | ||
} | ||
|
||
} // namespace electron |
23 changes: 23 additions & 0 deletions
23
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,23 @@ | ||
// Copyright (c) 2022 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef ELECTRON_SHELL_BROWSER_WEBAUTHN_ELECTRON_AUTHENTICATOR_REQUEST_DELEGATE_H_ | ||
#define ELECTRON_SHELL_BROWSER_WEBAUTHN_ELECTRON_AUTHENTICATOR_REQUEST_DELEGATE_H_ | ||
|
||
#include "content/public/browser/authenticator_request_client_delegate.h" | ||
|
||
namespace electron { | ||
|
||
// Modified from chrome/browser/webauthn/chrome_authenticator_request_delegate.h | ||
class ElectronWebAuthenticationDelegate | ||
: public content::WebAuthenticationDelegate { | ||
public: | ||
~ElectronWebAuthenticationDelegate() override; | ||
|
||
bool SupportsResidentKeys( | ||
content::RenderFrameHost* render_frame_host) override; | ||
}; | ||
|
||
} // namespace electron | ||
#endif // ELECTRON_SHELL_BROWSER_WEBAUTHN_ELECTRON_AUTHENTICATOR_REQUEST_DELEGATE_H_ |