Implemented a CredentialsStorage class with optional persistency. Two global

objects are used for session and persistent storage of credentials with the
appropriate locking. Passwords are stored on disk insecurely. If the user
uses the checkmark in the authentication window to remember the credentials,
the persistent storage will be used, otherwise the session storage. In another
words, even if not asked to remember the credentials, the same user/pass never
needs to be entered more than once per session, unlike before. WebCore already
contains a CredentialStorage class, but we don't use it. It could be used via
the CURL networking backend implementation, only the CF backend uses it at all.
Since we don't have a "keyring" OS level service, this solution was more
convenient for the time being.

Note all this has nothing to do with storage of form data entered by the user.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@478 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi
2012-07-03 15:43:51 +02:00
committed by Alexandre Deckner
parent ea992272d7
commit 9f30678a67
4 changed files with 406 additions and 1 deletions
+31 -1
View File
@@ -37,6 +37,7 @@
#include "BaseURL.h"
#include "BrowserApp.h"
#include "BrowsingHistory.h"
#include "CredentialsStorage.h"
#include "IconButton.h"
#include "NavMenu.h"
#include "SettingsKeys.h"
@@ -1151,6 +1152,27 @@ BrowserWindow::AuthenticationChallenge(BString message, BString& inOutUser,
BString& inOutPassword, bool& inOutRememberCredentials, uint32 failureCount,
BWebView* view)
{
CredentialsStorage* persistentStorage
= CredentialsStorage::PersistentInstance();
CredentialsStorage* sessionStorage
= CredentialsStorage::SessionInstance();
// TODO: Using the message as key here is not so smart.
HashKeyString key(message);
if (failureCount == 0) {
if (persistentStorage->Contains(key)) {
Credentials credentials = persistentStorage->GetCredentials(key);
inOutUser = credentials.Username();
inOutPassword = credentials.Password();
return true;
} else if (sessionStorage->Contains(key)) {
Credentials credentials = sessionStorage->GetCredentials(key);
inOutUser = credentials.Username();
inOutPassword = credentials.Password();
return true;
}
}
// Switch to the page for which this authentication is required.
if (view != CurrentWebView()) {
int32 tabIndex = fTabManager->TabForView(view);
@@ -1164,9 +1186,17 @@ BrowserWindow::AuthenticationChallenge(BString message, BString& inOutUser,
}
AuthenticationPanel* panel = new AuthenticationPanel(Frame());
// Panel auto-destructs.
return panel->getAuthentication(message, inOutUser, inOutPassword,
bool success = panel->getAuthentication(message, inOutUser, inOutPassword,
inOutRememberCredentials, failureCount > 0, inOutUser, inOutPassword,
&inOutRememberCredentials);
if (success) {
Credentials credentials(inOutUser, inOutPassword);
if (inOutRememberCredentials)
persistentStorage->PutCredentials(key, credentials);
else
sessionStorage->PutCredentials(key, credentials);
}
return success;
}