From 2efd2f490c1620343447198dc27e0340e4e670f6 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 7 Sep 2022 11:56:54 +1000 Subject: [PATCH] wasm: allow useCredentials access control to be set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce UseCredentialsAttribute that indicates whether the underlying fetch/XMLHttpRequest should use credentials https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials Fixes: QTBUG-90893 Change-Id: I2c43e286db52df387c0a22737d027b9a2a8dd2d3 Reviewed-by: MÃ¥rten Nordheim --- src/network/access/qnetworkreplywasmimpl.cpp | 3 +++ src/network/access/qnetworkrequest.cpp | 7 +++++++ src/network/access/qnetworkrequest.h | 1 + 3 files changed, 11 insertions(+) diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp index 2e0f865ccb6..9ed01d06ce3 100644 --- a/src/network/access/qnetworkreplywasmimpl.cpp +++ b/src/network/access/qnetworkreplywasmimpl.cpp @@ -223,6 +223,9 @@ void QNetworkReplyWasmImplPrivate::doSendRequest() request.attribute(QNetworkRequest::CacheSaveControlAttribute, false).toBool()) { attr.attributes -= EMSCRIPTEN_FETCH_PERSIST_FILE; } + if (request.attribute(QNetworkRequest::UseCredentialsAttribute, true).toBool()) { + attr.withCredentials = true; + } attr.onsuccess = QNetworkReplyWasmImplPrivate::downloadSucceeded; attr.onerror = QNetworkReplyWasmImplPrivate::downloadFailed; diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 9edbd1ff105..e9ab9aec3a7 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -305,6 +305,13 @@ QT_IMPL_METATYPE_EXTERN_TAGGED(QNetworkRequest::RedirectPolicy, QNetworkRequest_ This attribute is ignored if the Http2AllowedAttribute is not set. (This value was introduced in 6.3.) + \value UseCredentialsAttribute + Requests only, type: QMetaType::Bool (default: false) + Indicates if the underlying XMLHttpRequest cross-site Access-Control + requests should be made using credentials. Has no effect on + same-origin requests. This only affects the WebAssembly platform. + (This value was introduced in 6.5.) + \value User Special type. Additional information can be passed in QVariants with types ranging from User to UserMax. The default diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h index a9abcf8c497..eea8dbfd93a 100644 --- a/src/network/access/qnetworkrequest.h +++ b/src/network/access/qnetworkrequest.h @@ -63,6 +63,7 @@ public: AutoDeleteReplyOnFinishAttribute, ConnectionCacheExpiryTimeoutSecondsAttribute, Http2CleartextAllowedAttribute, + UseCredentialsAttribute, User = 1000, UserMax = 32767