generic: effectively revert 972b231e4a

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-06-01 11:58:40 +03:00
parent 87686b2b7f
commit 631ba7bb15
2 changed files with 13 additions and 28 deletions

View file

@ -80,7 +80,7 @@ static QString authInfoUrl(const KUrl &authinfourl, const bool removeuser)
cleanurl.setPath(nullstring); cleanurl.setPath(nullstring);
cleanurl.setQuery(nullstring); cleanurl.setQuery(nullstring);
cleanurl.setFragment(nullstring); cleanurl.setFragment(nullstring);
return cleanurl.prettyUrl(); return cleanurl.url();
} }
static QByteArray authInfoKey(const AuthInfo &authinfo) static QByteArray authInfoKey(const AuthInfo &authinfo)
@ -571,18 +571,6 @@ void SlaveBase::reparseConfiguration()
bool SlaveBase::openPasswordDialog(AuthInfo& info, const QString &errorMsg) bool SlaveBase::openPasswordDialog(AuthInfo& info, const QString &errorMsg)
{ {
KPasswdStore* passwdstore = d->passwdStore();
Q_ASSERT(passwdstore);
if (!passwdstore->isOpen() && passwdstore->openStore()) {
kDebug(7019) << "opening store for authorization" << info.url.prettyUrl();
if (checkCachedAuthentication(info)) {
// do not store the authorization, it was just pulled from the cache
info.keepPassword = false;
return true;
}
}
if (metaData(QLatin1String("no-auth-prompt")).compare(QLatin1String("true"), Qt::CaseInsensitive) == 0) { if (metaData(QLatin1String("no-auth-prompt")).compare(QLatin1String("true"), Qt::CaseInsensitive) == 0) {
kDebug(7019) << "not asking for authorization" << info.url.prettyUrl(); kDebug(7019) << "not asking for authorization" << info.url.prettyUrl();
return false; return false;
@ -936,12 +924,6 @@ bool SlaveBase::checkCachedAuthentication(AuthInfo &info)
{ {
KPasswdStore* passwdstore = d->passwdStore(); KPasswdStore* passwdstore = d->passwdStore();
Q_ASSERT(passwdstore); Q_ASSERT(passwdstore);
if (!passwdstore->isOpen() && !passwdstore->cacheOnly()) {
// let it fail the first time, if authorization is really required openPasswordDialog()
// will open the store and call this method
kDebug(7019) << "initial cache check rejected" << info.url.prettyUrl();
return false;
}
const qlonglong windowId = metaData(QLatin1String("window-id")).toLongLong(); const qlonglong windowId = metaData(QLatin1String("window-id")).toLongLong();
QByteArray authkey = authInfoKey(info); QByteArray authkey = authInfoKey(info);

View file

@ -1069,22 +1069,25 @@ bool CurlProtocol::setupCurl(const KUrl &url, const bool ftp)
CURLcode CurlProtocol::performCurl(const KUrl &url, KUrl *redirecturl) CURLcode CurlProtocol::performCurl(const KUrl &url, KUrl *redirecturl)
{ {
CURLcode curlresult = CURLE_OK;
KIO::AuthInfo kioauthinfo; KIO::AuthInfo kioauthinfo;
kioauthinfo.url = url; kioauthinfo.url = url;
kioauthinfo.username = url.userName(); kioauthinfo.username = url.userName();
kioauthinfo.password = url.password(); kioauthinfo.password = url.password();
if (checkCachedAuthentication(kioauthinfo)) { CURLcode curlresult = curl_easy_perform(m_curl);
kDebug(7103) << "Authorizing from cache" << url.prettyUrl(); if (curlresult != CURLE_OK) {
curlresult = setupAuth(kioauthinfo.username, kioauthinfo.password); const KIO::Error kioerror = curlToKIOError(curlresult, m_curl);
if (curlresult != CURLE_OK) { if (kioerror == KIO::ERR_COULD_NOT_LOGIN) {
return curlresult; if (checkCachedAuthentication(kioauthinfo)) {
kDebug(7103) << "Authorizing from cache" << url.prettyUrl();
curlresult = setupAuth(kioauthinfo.username, kioauthinfo.password);
if (curlresult != CURLE_OK) {
return curlresult;
}
curlresult = curl_easy_perform(m_curl);
}
} }
} else {
kDebug(7103) << "No cached authorization" << url.prettyUrl();
} }
curlresult = curl_easy_perform(m_curl);
if (curlresult != CURLE_OK) { if (curlresult != CURLE_OK) {
const KIO::Error kioerror = curlToKIOError(curlresult, m_curl); const KIO::Error kioerror = curlToKIOError(curlresult, m_curl);
if (kioerror == KIO::ERR_COULD_NOT_LOGIN) { if (kioerror == KIO::ERR_COULD_NOT_LOGIN) {