electron/patches/chromium/add_trustedauthclient_to_urlloaderfactory.patch
Electron Bot 72a089262e
chore: bump chromium to a84d34e372b8fb5e9a94b1b4b447e (master) (#23908)
* chore: bump chromium in DEPS to a7249f73ae05d456c04487ef1693325f719556dd

* chore: bump chromium in DEPS to 202466fa40b58f0bb9c9a76a037d1c50154c099e

* chore: bump chromium in DEPS to 2dd1b25c8d794b50fb0dd911e0c4e909ff39f145

* Update patches

* update patches

* Revert "[printing] Mojofy PrintHostMsg_CheckForCancel"

https://chromium-review.googlesource.com/c/chromium/src/+/2226002

* chore: bump chromium in DEPS to 8c1542e7dd36854fdf4abd1a8021eeb65a6a2e2b

* chore: bump chromium in DEPS to 078bc6d796334fb403acd8975b99d1c8ecd028e8

* chore: bump chromium in DEPS to d96e9f16ae852ec9dbd15bf17df3d440402413bb

* update patches

* chore: update patches

* Use ExtensionSystem::is_ready() instead of ExtensionService::is_ready()

https://chromium-review.googlesource.com/c/chromium/src/+/2207499

* Remove WebImeTextSpan

https://chromium-review.googlesource.com/c/chromium/src/+/2225240

* Remove PDFAnnotations flag altogether.

https://chromium-review.googlesource.com/c/chromium/src/+/2229317

* Rework find-from-selection so it's synchronous -- fixes flaky tests

https://chromium-review.googlesource.com/c/chromium/src/+/2181570

* fixup! Revert "[printing] Mojofy PrintHostMsg_CheckForCancel"

* chore: bump chromium in DEPS to a8a280835830c65145ed8573a9a09f36d3920418

* update sysroots

* update patches

* update patches

* Take RFH as a parameter for DidUpdateFavicon/ManifestURL

https://chromium-review.googlesource.com/c/chromium/src/+/2224745

* chore: bump chromium in DEPS to b6149cb5a5e32caf8eab67b97ef3072b72521ca8

* Update patches

* Rename net::cookie_util::StripStatuses to StripAccessResults

https://chromium-review.googlesource.com/c/chromium/src/+/2212697

* use net::CookieAccessResultList instead of net::CookieAccessResultList

* fix mas_no_private_api patch

https://chromium-review.googlesource.com/c/chromium/src/+/2230281

* chore: bump chromium in DEPS to a27feee1643d952e48f77c92d8c03aedea14b720

* update patches

* fix: add new navigation state REUSE_SITE_INSTANCE

To fix the new set of state checks added in
https://chromium-review.googlesource.com/c/chromium/src/+/2215141

* chore: bump chromium in DEPS to ff4559a4c13d20888202474e4ab9917dbdad8a9a

* update patches

* Cleanup usages of old mojo types and remove unused code

https://chromium-review.googlesource.com/c/chromium/src/+/2235699

* chore: bump chromium in DEPS to 05279845f76eb22900a8b0d1a11d4fd339a8e53b

* chore: bump chromium in DEPS to 821558279767cffec90e3b5b947865f90089fed3

* chore: bump chromium in DEPS to 1aef04e6486be337d3dd820b2d64d6320a1b9c13

* chore: bump chromium in DEPS to dc86386e8fdd796a0f7577e91e42a7f8b7e9bc78

* chore: bump chromium in DEPS to 64f2360794f14643764092ba3e58e2ed8f9fee12

* chore: update patches

* refactor: MessageLoop, you are terminated \o/

Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2246173

* refactor: plumb DownloadSchedule to DownloadItem

Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2242202

* chore: fix variable typo in IPC

* chore: s/BindPipeAndPassReceiver/BindNewPipeAndPassReceiver

* chore: update patches

* chore: XEvent becomes x11::Event

Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2240355

* fixup! refactor: MessageLoop, you are terminated \o/

* fixup! chore: XEvent becomes x11::Event

* build: update v8 headers

* chore: fix windows build

* chore: disable SameSite-by-default changes

https://chromium-review.googlesource.com/c/chromium/src/+/2231445

* update printing.patch

* chore: bump chromium DEPS to 9ae03ef8f7d4f6ac663f725bcfe70311987652f3

* Convert WidgetHostMsg_SelectionBoundsChanged/TextInputStateChanged

https://chromium-review.googlesource.com/c/chromium/src/+/2243531

* chore: update v8 patches

* [XProto] Replace usages of XID and ::Window with x11::Window

https://chromium-review.googlesource.com/c/chromium/src/+/2249389

* Update VideoFrameMetadata to use base::Optionals

https://chromium-review.googlesource.com/c/chromium/src/+/2231706
https://chromium-review.googlesource.com/c/chromium/src/+/2238361

* --disable-dev-shm-usage for gpu process crash

* [v8] Allow for 4GB TypedArrays

https://chromium-review.googlesource.com/c/v8/v8/+/2249668

* update lib_src_switch_buffer_kmaxlength_to_size_t.patch

* disable app.getGPUInfo spec on linux

* update patches

Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
Co-authored-by: Electron Bot <anonymous@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
2020-06-22 10:35:10 -07:00

161 lines
7.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Tue, 12 Nov 2019 11:50:16 -0800
Subject: add TrustedAuthClient to URLLoaderFactory
This allows intercepting authentication requests for the 'net' module.
Without this, the 'login' event for electron.net.ClientRequest can't be
implemented, because the existing path checks for the presence of a
WebContents, and cancels the authentication if there's no WebContents
available, which there isn't in the case of the 'net' module.
diff --git a/services/network/public/mojom/network_context.mojom b/services/network/public/mojom/network_context.mojom
index 842a4d27ee7a27a4e5c6d60033cee6526aac1bee..07682bd496e0872498f1fd404466408ebf21583c 100644
--- a/services/network/public/mojom/network_context.mojom
+++ b/services/network/public/mojom/network_context.mojom
@@ -214,6 +214,25 @@ struct CTPolicy {
array<string> excluded_legacy_spkis;
};
+interface TrustedAuthClient {
+ OnAuthRequired(
+ mojo_base.mojom.UnguessableToken? window_id,
+ uint32 process_id,
+ uint32 routing_id,
+ uint32 request_id,
+ url.mojom.Url url,
+ bool first_auth_attempt,
+ AuthChallengeInfo auth_info,
+ URLResponseHead? head,
+ pending_remote<AuthChallengeResponder> auth_challenge_responder);
+};
+interface TrustedURLLoaderAuthClient {
+ // When a new URLLoader is created, this will be called to pass a
+ // corresponding |auth_client|.
+ OnLoaderCreated(int32 request_id,
+ pending_receiver<TrustedAuthClient> auth_client);
+};
+
interface CertVerifierClient {
Verify(
int32 default_error,
@@ -640,6 +659,8 @@ struct URLLoaderFactoryParams {
// impact because of the extra process hops, so use should be minimized.
pending_remote<TrustedURLLoaderHeaderClient>? header_client;
+ pending_remote<TrustedURLLoaderAuthClient>? auth_client;
+
// |factory_bound_access_patterns| are used for CORS checks in addition to
// the per-context allow patterns that is managed via NetworkContext
// interface. This still respects the per-context block lists.
diff --git a/services/network/url_loader.cc b/services/network/url_loader.cc
index 80dc1f91fd4051dc054f1c9e9a5ab0087c4d66fd..4eec90182ae4944f219e12ff2673d0fbd24e112d 100644
--- a/services/network/url_loader.cc
+++ b/services/network/url_loader.cc
@@ -437,6 +437,7 @@ URLLoader::URLLoader(
base::WeakPtr<KeepaliveStatisticsRecorder> keepalive_statistics_recorder,
base::WeakPtr<NetworkUsageAccumulator> network_usage_accumulator,
mojom::TrustedURLLoaderHeaderClient* url_loader_header_client,
+ mojom::TrustedURLLoaderAuthClient* url_loader_auth_client,
mojom::OriginPolicyManager* origin_policy_manager,
std::unique_ptr<TrustTokenRequestHelperFactory> trust_token_helper_factory,
mojo::PendingRemote<mojom::CookieAccessObserver> cookie_observer)
@@ -497,6 +498,11 @@ URLLoader::URLLoader(
header_client_.set_disconnect_handler(
base::BindOnce(&URLLoader::OnMojoDisconnect, base::Unretained(this)));
}
+ if (url_loader_auth_client) {
+ url_loader_auth_client->OnLoaderCreated(request_id_, auth_client_.BindNewPipeAndPassReceiver());
+ auth_client_.set_disconnect_handler(
+ base::BindOnce(&URLLoader::OnMojoDisconnect, base::Unretained(this)));
+ }
if (want_raw_headers_) {
options_ |= mojom::kURLLoadOptionSendSSLInfoWithResponse |
mojom::kURLLoadOptionSendSSLInfoForCertificateError;
@@ -1016,7 +1022,7 @@ void URLLoader::OnAuthRequired(net::URLRequest* url_request,
// |this| may have been deleted.
return;
}
- if (!network_context_client_) {
+ if (!network_context_client_ && !auth_client_) {
OnAuthCredentials(base::nullopt);
return;
}
@@ -1032,11 +1038,20 @@ void URLLoader::OnAuthRequired(net::URLRequest* url_request,
if (url_request->response_headers())
head->headers = url_request->response_headers();
head->auth_challenge_info = auth_info;
- network_context_client_->OnAuthRequired(
- fetch_window_id_, factory_params_->process_id, render_frame_id_,
- request_id_, url_request_->url(), first_auth_attempt_, auth_info,
- std::move(head),
- auth_challenge_responder_receiver_.BindNewPipeAndPassRemote());
+
+ if (auth_client_) {
+ auth_client_->OnAuthRequired(
+ fetch_window_id_, factory_params_->process_id, render_frame_id_,
+ request_id_, url_request_->url(), first_auth_attempt_, auth_info,
+ std::move(head),
+ auth_challenge_responder_receiver_.BindNewPipeAndPassRemote());
+ } else {
+ network_context_client_->OnAuthRequired(
+ fetch_window_id_, factory_params_->process_id, render_frame_id_,
+ request_id_, url_request_->url(), first_auth_attempt_, auth_info,
+ std::move(head),
+ auth_challenge_responder_receiver_.BindNewPipeAndPassRemote());
+ }
auth_challenge_responder_receiver_.set_disconnect_handler(
base::BindOnce(&URLLoader::DeleteSelf, base::Unretained(this)));
diff --git a/services/network/url_loader.h b/services/network/url_loader.h
index f5436f10a312c713e95fac4670eab3edf048a742..02212de14459ee6cd15492e7b35cd2791f48205c 100644
--- a/services/network/url_loader.h
+++ b/services/network/url_loader.h
@@ -115,6 +115,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) URLLoader
base::WeakPtr<KeepaliveStatisticsRecorder> keepalive_statistics_recorder,
base::WeakPtr<NetworkUsageAccumulator> network_usage_accumulator,
mojom::TrustedURLLoaderHeaderClient* url_loader_header_client,
+ mojom::TrustedURLLoaderAuthClient* url_loader_auth_client,
mojom::OriginPolicyManager* origin_policy_manager,
std::unique_ptr<TrustTokenRequestHelperFactory>
trust_token_helper_factory,
@@ -456,6 +457,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) URLLoader
base::Optional<base::UnguessableToken> fetch_window_id_;
mojo::Remote<mojom::TrustedHeaderClient> header_client_;
+ mojo::Remote<mojom::TrustedAuthClient> auth_client_;
std::unique_ptr<FileOpenerForUpload> file_opener_for_upload_;
diff --git a/services/network/url_loader_factory.cc b/services/network/url_loader_factory.cc
index c8f02a3760f938c772c9e81afff8b37e49a73cbd..7e5bb5d1384488de2dee3672f933eba643dc14f7 100644
--- a/services/network/url_loader_factory.cc
+++ b/services/network/url_loader_factory.cc
@@ -75,6 +75,7 @@ URLLoaderFactory::URLLoaderFactory(
resource_scheduler_client_(std::move(resource_scheduler_client)),
header_client_(std::move(params_->header_client)),
coep_reporter_(std::move(params_->coep_reporter)),
+ auth_client_(std::move(params_->auth_client)),
cors_url_loader_factory_(cors_url_loader_factory),
cookie_observer_(std::move(params_->cookie_observer)) {
DCHECK(context);
@@ -270,6 +271,7 @@ void URLLoaderFactory::CreateLoaderAndStart(
std::move(keepalive_statistics_recorder),
std::move(network_usage_accumulator),
header_client_.is_bound() ? header_client_.get() : nullptr,
+ auth_client_.is_bound() ? auth_client_.get() : nullptr,
context_->origin_policy_manager(), std::move(trust_token_factory),
std::move(cookie_observer));
diff --git a/services/network/url_loader_factory.h b/services/network/url_loader_factory.h
index 8b29b67a5b0663778df3169e09bf818e6bbcec3f..e504fa3d41066907a3fbc41e69daac968415dfa6 100644
--- a/services/network/url_loader_factory.h
+++ b/services/network/url_loader_factory.h
@@ -75,6 +75,7 @@ class URLLoaderFactory : public mojom::URLLoaderFactory {
scoped_refptr<ResourceSchedulerClient> resource_scheduler_client_;
mojo::Remote<mojom::TrustedURLLoaderHeaderClient> header_client_;
mojo::Remote<mojom::CrossOriginEmbedderPolicyReporter> coep_reporter_;
+ mojo::Remote<mojom::TrustedURLLoaderAuthClient> auth_client_;
// |cors_url_loader_factory_| owns this.
cors::CorsURLLoaderFactory* cors_url_loader_factory_;