Skip to content

Commit d272074

Browse files
committed
fix: handleResponse logic on handling valid https url.
Signed-off-by: Camila Ayres <[email protected]>
1 parent 0cc6b0e commit d272074

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/gui/creds/flow2auth.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,29 @@ QJsonObject Flow2Auth::handleResponse(QNetworkReply *reply)
225225
const auto jsonData = reply->readAll();
226226
QJsonParseError jsonParseError{};
227227
const auto json = QJsonDocument::fromJson(jsonData, &jsonParseError).object();
228-
229228
if (reply->error() == QNetworkReply::NoError && jsonParseError.error == QJsonParseError::NoError
230229
&& !json.isEmpty()) {
231-
const QUrl serverUrl = json["server"].toString();
232-
if (_enforceHttps && serverUrl.scheme() != QStringLiteral("https")) {
233-
qCWarning(lcFlow2auth) << "Returned server url" << serverUrl << "does not start with https";
234-
emit result(Error, tr("The returned server URL does not start with HTTPS despite the login URL started with HTTPS. Login will not be possible because this might be a security issue. Please contact your administrator."));
230+
const auto isHttps = [&]() {
231+
const auto endpoint = json["server"].toString().isEmpty()
232+
? json.value("poll").toObject().value("endpoint").toString() //from login/v2 endpoint
233+
: json["server"].toString(); //from login/v2/poll endpoint
234+
235+
if (endpoint.isEmpty()) {
236+
return false;
237+
}
238+
239+
qCDebug(lcFlow2auth) << "Server url returned is" << endpoint;
240+
if (QUrl(endpoint).scheme() != QStringLiteral("https")) {
241+
return false;
242+
}
243+
244+
return true;
245+
};
246+
247+
if (_enforceHttps && !isHttps()) {
248+
qCWarning(lcFlow2auth) << "Returned server url | poll endpoint does not start with https";
249+
emit result(Error, tr("The returned server URL does not start with HTTPS despite the login URL started with HTTPS. "
250+
"Login will not be possible because this might be a security issue. Please contact your administrator."));
235251
return {};
236252
}
237253
}

0 commit comments

Comments
 (0)