1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
content / public / browser / authenticator_request_client_delegate.cc [blame]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/browser/authenticator_request_client_delegate.h"
#include <string_view>
#include <utility>
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "content/browser/webauth/authenticator_environment.h"
#include "device/fido/fido_discovery_factory.h"
#include "device/fido/fido_request_handler_base.h"
#include "device/fido/public_key_credential_descriptor.h"
#include "device/fido/public_key_credential_user_entity.h"
#include "url/origin.h"
#if BUILDFLAG(IS_WIN)
#include "device/fido/win/webauthn_api.h"
#endif // BUILDFLAG(IS_WIN)
namespace content {
WebAuthenticationDelegate::WebAuthenticationDelegate() = default;
WebAuthenticationDelegate::~WebAuthenticationDelegate() = default;
bool WebAuthenticationDelegate::OverrideCallerOriginAndRelyingPartyIdValidation(
BrowserContext* browser_context,
const url::Origin& caller_origin,
const std::string& relying_party_id) {
// Perform regular security checks for all origins and RP IDs.
return false;
}
bool WebAuthenticationDelegate::OriginMayUseRemoteDesktopClientOverride(
BrowserContext* browser_context,
const url::Origin& caller_origin) {
// No origin is permitted to claim RP IDs on behalf of another origin.
return false;
}
std::optional<std::string>
WebAuthenticationDelegate::MaybeGetRelyingPartyIdOverride(
const std::string& claimed_relying_party_id,
const url::Origin& caller_origin) {
return std::nullopt;
}
bool WebAuthenticationDelegate::ShouldPermitIndividualAttestation(
BrowserContext* browser_context,
const url::Origin& caller_origin,
const std::string& relying_party_id) {
return false;
}
bool WebAuthenticationDelegate::SupportsResidentKeys(
RenderFrameHost* render_frame_host) {
// The testing API supports resident keys, but for real requests //content
// doesn't by default.
FrameTreeNode* frame_tree_node =
static_cast<RenderFrameHostImpl*>(render_frame_host)->frame_tree_node();
if (AuthenticatorEnvironment::GetInstance()->IsVirtualAuthenticatorEnabledFor(
frame_tree_node)) {
return true;
}
return false;
}
bool WebAuthenticationDelegate::SupportsPasskeyMetadataSyncing() {
return false;
}
bool WebAuthenticationDelegate::IsFocused(WebContents* web_contents) {
return true;
}
void WebAuthenticationDelegate::
IsUserVerifyingPlatformAuthenticatorAvailableOverride(
RenderFrameHost* render_frame_host,
base::OnceCallback<void(std::optional<bool>)> callback) {
FrameTreeNode* frame_tree_node =
static_cast<RenderFrameHostImpl*>(render_frame_host)->frame_tree_node();
if (AuthenticatorEnvironment::GetInstance()->IsVirtualAuthenticatorEnabledFor(
frame_tree_node)) {
std::move(callback).Run(
AuthenticatorEnvironment::GetInstance()
->HasVirtualUserVerifyingPlatformAuthenticator(frame_tree_node));
return;
}
std::move(callback).Run(std::nullopt);
}
WebAuthenticationRequestProxy* WebAuthenticationDelegate::MaybeGetRequestProxy(
BrowserContext* browser_context,
const url::Origin& caller_origin) {
return nullptr;
}
void WebAuthenticationDelegate::DeletePasskey(
content::WebContents* web_contents,
const std::vector<uint8_t>& passkey_credential_id,
const std::string& relying_party_id) {}
void WebAuthenticationDelegate::DeleteUnacceptedPasskeys(
content::WebContents* web_contents,
const std::string& relying_party_id,
const std::vector<uint8_t>& user_id,
const std::vector<std::vector<uint8_t>>& all_accepted_credentials_ids) {}
void WebAuthenticationDelegate::UpdateUserPasskeys(
content::WebContents* web_contents,
const url::Origin& origin,
const std::string& relying_party_id,
std::vector<uint8_t>& user_id,
const std::string& name,
const std::string& display_name) {}
void WebAuthenticationDelegate::BrowserProvidedPasskeysAvailable(
BrowserContext* browser_context,
base::OnceCallback<void(bool)> callback) {
std::move(callback).Run(false);
}
#if BUILDFLAG(IS_MAC)
std::optional<WebAuthenticationDelegate::TouchIdAuthenticatorConfig>
WebAuthenticationDelegate::GetTouchIdAuthenticatorConfig(
BrowserContext* browser_context) {
return std::nullopt;
}
#endif // BUILDFLAG(IS_MAC)
#if BUILDFLAG(IS_CHROMEOS)
WebAuthenticationDelegate::ChromeOSGenerateRequestIdCallback
WebAuthenticationDelegate::GetGenerateRequestIdCallback(
RenderFrameHost* render_frame_host) {
return base::NullCallback();
}
#endif
AuthenticatorRequestClientDelegate::AuthenticatorRequestClientDelegate() =
default;
AuthenticatorRequestClientDelegate::~AuthenticatorRequestClientDelegate() =
default;
void AuthenticatorRequestClientDelegate::SetRelyingPartyId(const std::string&) {
}
bool AuthenticatorRequestClientDelegate::DoesBlockRequestOnFailure(
InterestingFailureReason reason) {
return false;
}
void AuthenticatorRequestClientDelegate::OnTransactionSuccessful(
RequestSource request_source,
device::FidoRequestType request_type,
device::AuthenticatorType authenticator_type) {}
void AuthenticatorRequestClientDelegate::RegisterActionCallbacks(
base::OnceClosure cancel_callback,
base::RepeatingClosure start_over_callback,
AccountPreselectedCallback account_preselected_callback,
device::FidoRequestHandlerBase::RequestCallback request_callback,
base::RepeatingClosure bluetooth_adapter_power_on_callback,
base::RepeatingCallback<
void(device::FidoRequestHandlerBase::BlePermissionCallback)>
request_ble_permission_callback) {}
void AuthenticatorRequestClientDelegate::ConfigureDiscoveries(
const url::Origin& origin,
const std::string& rp_id,
RequestSource request_source,
device::FidoRequestType request_type,
std::optional<device::ResidentKeyRequirement> resident_key_requirement,
device::UserVerificationRequirement user_verification_requirement,
std::optional<std::string_view> user_name,
base::span<const device::CableDiscoveryData> pairings_from_extension,
bool is_enclave_authenticator_available,
device::FidoDiscoveryFactory* fido_discovery_factory) {}
void AuthenticatorRequestClientDelegate::SetHints(const Hints& hints) {}
void AuthenticatorRequestClientDelegate::SelectAccount(
std::vector<device::AuthenticatorGetAssertionResponse> responses,
base::OnceCallback<void(device::AuthenticatorGetAssertionResponse)>
callback) {
// Automatically choose the first account to allow resident keys for virtual
// authenticators without a browser implementation, e.g. on content shell.
// TODO(crbug.com/40639383): Provide a way to determine which account gets
// picked.
DCHECK(virtual_environment_);
std::move(callback).Run(std::move(responses.at(0)));
}
void AuthenticatorRequestClientDelegate::DisableUI() {}
bool AuthenticatorRequestClientDelegate::IsWebAuthnUIEnabled() {
return false;
}
void AuthenticatorRequestClientDelegate::SetVirtualEnvironment(
bool virtual_environment) {
virtual_environment_ = virtual_environment;
}
bool AuthenticatorRequestClientDelegate::IsVirtualEnvironmentEnabled() {
return virtual_environment_;
}
void AuthenticatorRequestClientDelegate::SetConditionalRequest(
bool is_conditional) {}
void AuthenticatorRequestClientDelegate::SetAmbientCredentialTypes(
int credential_type_flags) {}
void AuthenticatorRequestClientDelegate::SetCredentialIdFilter(
std::vector<device::PublicKeyCredentialDescriptor>) {}
void AuthenticatorRequestClientDelegate::SetUserEntityForMakeCredentialRequest(
const device::PublicKeyCredentialUserEntity&) {}
std::vector<std::unique_ptr<device::FidoDiscoveryBase>>
AuthenticatorRequestClientDelegate::CreatePlatformDiscoveries() {
return {};
}
void AuthenticatorRequestClientDelegate::OnTransportAvailabilityEnumerated(
device::FidoRequestHandlerBase::TransportAvailabilityInfo data) {}
bool AuthenticatorRequestClientDelegate::EmbedderControlsAuthenticatorDispatch(
const device::FidoAuthenticator& authenticator) {
return false;
}
void AuthenticatorRequestClientDelegate::BluetoothAdapterStatusChanged(
device::FidoRequestHandlerBase::BleStatus ble_status) {}
void AuthenticatorRequestClientDelegate::FidoAuthenticatorAdded(
const device::FidoAuthenticator& authenticator) {}
void AuthenticatorRequestClientDelegate::FidoAuthenticatorRemoved(
std::string_view device_id) {}
bool AuthenticatorRequestClientDelegate::SupportsPIN() const {
return false;
}
void AuthenticatorRequestClientDelegate::CollectPIN(
CollectPINOptions options,
base::OnceCallback<void(std::u16string)> provide_pin_cb) {
NOTREACHED_IN_MIGRATION();
}
void AuthenticatorRequestClientDelegate::StartBioEnrollment(
base::OnceClosure next_callback) {}
void AuthenticatorRequestClientDelegate::OnSampleCollected(
int bio_samples_remaining) {}
void AuthenticatorRequestClientDelegate::FinishCollectToken() {}
void AuthenticatorRequestClientDelegate::OnRetryUserVerification(int attempts) {
}
} // namespace content