Commit c0cb2f6f authored by Dawit Alemayehu's avatar Dawit Alemayehu
Browse files

Make sure HTTP authentication is properly cached in persistent storage whenever

the user has checked the 'Remember password' checkbox in the password dialog.

This commit correctly addresses the issue reported in
https://git.reviewboard.kde.org/r/102729/.

CCMAIL: bcooksley@kde.org
parent 2812a130
......@@ -3075,10 +3075,13 @@ endParsing:
if (auth->realm().isEmpty() && !auth->supportsPathMatching())
setMetaData(QLatin1String("{internal~allhosts}proxy-auth-realm"), authinfo.realmValue);
}
kDebug(7113) << "Cache authentication info ?" << authinfo.keepPassword;
if (authinfo.keepPassword) {
cacheAuthentication(authinfo);
kDebug(7113) << "Cached authentication for" << m_request.url;
}
kDebug(7113) << "Caching authentication for" << m_request.url;
}
// Update our server connection state which includes www and proxy username and password.
m_server.updateCredentials(m_request);
......@@ -3494,6 +3497,7 @@ endParsing:
if (generateAuthorization) {
(*auth)->generateResponse(username, password);
(*auth)->setCachePasswordEnabled(authinfo.keepPassword);
kDebug(7113) << "Auth State: isError=" << (*auth)->isError()
<< "needCredentials=" << (*auth)->needCredentials()
......@@ -5310,10 +5314,12 @@ void HTTPProtocol::proxyAuthenticationForSocket(const QNetworkProxy &proxy, QAut
if (!dataEntered) {
kDebug(7103) << "looks like the user canceled proxy authentication.";
error(ERR_USER_CANCELED, m_request.proxyUrl.host());
return;
}
}
authenticator->setUser(info.username);
authenticator->setPassword(info.password);
authenticator->setOption(QLatin1String("keepalive"), info.keepPassword);
if (m_socketProxyAuth) {
*m_socketProxyAuth = *authenticator;
......@@ -5340,6 +5346,7 @@ void HTTPProtocol::saveProxyAuthenticationForSocket()
a.realmValue = m_socketProxyAuth->realm();
a.username = m_socketProxyAuth->user();
a.password = m_socketProxyAuth->password();
a.keepPassword = m_socketProxyAuth->option(QLatin1String("keepalive")).toBool();
cacheAuthentication(a);
}
delete m_socketProxyAuth;
......
......@@ -315,6 +315,7 @@ void KAbstractHttpAuthentication::reset()
m_needCredentials = true;
m_forceKeepAlive = false;
m_forceDisconnect = false;
m_keepPassword = false;
m_headerFragment.clear();
m_username.clear();
m_password.clear();
......@@ -352,6 +353,7 @@ void KAbstractHttpAuthentication::authInfoBoilerplate(KIO::AuthInfo *a) const
a->verifyPath = supportsPathMatching();
a->realmValue = realm();
a->digestInfo = QLatin1String(authDataToCache());
a->keepPassword = m_keepPassword;
}
......
......@@ -138,6 +138,11 @@ public:
*/
QString realm() const;
/**
* Sets the cache password flag to @p enable.
*/
void setCachePasswordEnabled(bool enable) { m_keepPassword = enable; }
#ifdef ENABLE_HTTP_AUTH_NONCE_SETTER
// NOTE: FOR USE in unit testing ONLY.
virtual void setDigestNonceValue(const QByteArray&) {}
......@@ -160,6 +165,7 @@ protected:
bool m_forceKeepAlive;
bool m_forceDisconnect;
bool m_finalAuthStage;
bool m_keepPassword;
QByteArray m_headerFragment;
QString m_username;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment