summaryrefslogtreecommitdiffstats
path: root/chrome/browser/password_manager
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/password_manager')
-rw-r--r--chrome/browser/password_manager/native_backend_gnome_x.cc40
-rw-r--r--chrome/browser/password_manager/native_backend_gnome_x_unittest.cc8
-rw-r--r--chrome/browser/password_manager/native_backend_libsecret.cc39
-rw-r--r--chrome/browser/password_manager/native_backend_libsecret_unittest.cc8
4 files changed, 63 insertions, 32 deletions
diff --git a/chrome/browser/password_manager/native_backend_gnome_x.cc b/chrome/browser/password_manager/native_backend_gnome_x.cc
index 53c671b..a0d4f1f 100644
--- a/chrome/browser/password_manager/native_backend_gnome_x.cc
+++ b/chrome/browser/password_manager/native_backend_gnome_x.cc
@@ -185,6 +185,10 @@ ScopedVector<PasswordForm> ConvertFormList(GList* found,
ScopedVector<PasswordForm> forms;
password_manager::PSLDomainMatchMetric psl_domain_match_metric =
password_manager::PSL_DOMAIN_MATCH_NONE;
+ const bool allow_psl_match =
+ lookup_form && password_manager::ShouldPSLDomainMatchingApply(
+ password_manager::GetRegistryControlledDomain(
+ GURL(lookup_form->signon_realm)));
for (GList* element = g_list_first(found); element;
element = g_list_next(element)) {
GnomeKeyringFound* data = static_cast<GnomeKeyringFound*>(element->data);
@@ -193,15 +197,21 @@ ScopedVector<PasswordForm> ConvertFormList(GList* found,
scoped_ptr<PasswordForm> form(FormFromAttributes(attrs));
if (form) {
if (lookup_form && form->signon_realm != lookup_form->signon_realm) {
- // This is not an exact match, we try PSL matching.
if (lookup_form->scheme != PasswordForm::SCHEME_HTML ||
- form->scheme != PasswordForm::SCHEME_HTML ||
- !(password_manager::IsPublicSuffixDomainMatch(
- lookup_form->signon_realm, form->signon_realm))) {
+ form->scheme != PasswordForm::SCHEME_HTML)
+ continue; // Ignore non-HTML matches.
+ // This is not an exact match, we try PSL matching and federated match.
+ if (allow_psl_match &&
+ password_manager::IsPublicSuffixDomainMatch(
+ form->signon_realm, lookup_form->signon_realm)) {
+ psl_domain_match_metric = password_manager::PSL_DOMAIN_MATCH_FOUND;
+ form->is_public_suffix_match = true;
+ } else if (!form->federation_origin.unique() &&
+ password_manager::IsFederatedMatch(form->signon_realm,
+ lookup_form->origin)) {
+ } else {
continue;
}
- psl_domain_match_metric = password_manager::PSL_DOMAIN_MATCH_FOUND;
- form->is_public_suffix_match = true;
}
if (data->secret) {
form->password_value = UTF8ToUTF16(data->secret);
@@ -214,15 +224,11 @@ ScopedVector<PasswordForm> ConvertFormList(GList* found,
}
}
if (lookup_form) {
- const GURL signon_realm(lookup_form->signon_realm);
- std::string registered_domain =
- password_manager::GetRegistryControlledDomain(signon_realm);
- UMA_HISTOGRAM_ENUMERATION(
- "PasswordManager.PslDomainMatchTriggering",
- password_manager::ShouldPSLDomainMatchingApply(registered_domain)
- ? psl_domain_match_metric
- : password_manager::PSL_DOMAIN_MATCH_NOT_USED,
- password_manager::PSL_DOMAIN_MATCH_COUNT);
+ UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering",
+ allow_psl_match
+ ? psl_domain_match_metric
+ : password_manager::PSL_DOMAIN_MATCH_NOT_USED,
+ password_manager::PSL_DOMAIN_MATCH_COUNT);
}
return forms;
}
@@ -426,7 +432,9 @@ void GKRMethod::GetLogins(const PasswordForm& form, const char* app_string) {
ScopedAttributeList attrs(gnome_keyring_attribute_list_new());
if (!password_manager::ShouldPSLDomainMatchingApply(
password_manager::GetRegistryControlledDomain(
- GURL(form.signon_realm)))) {
+ GURL(form.signon_realm))) &&
+ form.scheme != PasswordForm::SCHEME_HTML) {
+ // Don't retrieve the PSL matched and federated credentials.
AppendString(&attrs, "signon_realm", form.signon_realm);
}
AppendString(&attrs, "application", app_string);
diff --git a/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc b/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc
index 36c0a36..85e027c 100644
--- a/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc
+++ b/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc
@@ -884,6 +884,14 @@ TEST_F(NativeBackendGnomeTest, PSLUpdatingStrictAddLogin) {
CheckPSLUpdate(UPDATE_BY_ADDLOGIN);
}
+TEST_F(NativeBackendGnomeTest, FetchFederatedCredential) {
+ other_auth_.signon_realm = "federation://www.example.com/google.com";
+ other_auth_.federation_origin = url::Origin(GURL("https://google.com/"));
+ EXPECT_TRUE(CheckCredentialAvailability(other_auth_,
+ GURL("http://www.example.com/"),
+ PasswordForm::SCHEME_HTML, nullptr));
+}
+
TEST_F(NativeBackendGnomeTest, BasicUpdateLogin) {
NativeBackendGnome backend(42);
backend.Init();
diff --git a/chrome/browser/password_manager/native_backend_libsecret.cc b/chrome/browser/password_manager/native_backend_libsecret.cc
index 8c65356..9887500 100644
--- a/chrome/browser/password_manager/native_backend_libsecret.cc
+++ b/chrome/browser/password_manager/native_backend_libsecret.cc
@@ -541,7 +541,8 @@ bool NativeBackendLibsecret::GetLoginsList(
if (lookup_form &&
!password_manager::ShouldPSLDomainMatchingApply(
password_manager::GetRegistryControlledDomain(
- GURL(lookup_form->signon_realm))))
+ GURL(lookup_form->signon_realm))) &&
+ lookup_form->scheme != PasswordForm::SCHEME_HTML)
attrs.Append("signon_realm", lookup_form->signon_realm);
GError* error = nullptr;
@@ -631,6 +632,10 @@ ScopedVector<autofill::PasswordForm> NativeBackendLibsecret::ConvertFormList(
password_manager::PSLDomainMatchMetric psl_domain_match_metric =
password_manager::PSL_DOMAIN_MATCH_NONE;
GError* error = nullptr;
+ const bool allow_psl_match =
+ lookup_form && password_manager::ShouldPSLDomainMatchingApply(
+ password_manager::GetRegistryControlledDomain(
+ GURL(lookup_form->signon_realm)));
for (GList* element = g_list_first(found); element != nullptr;
element = g_list_next(element)) {
SecretItem* secretItem = static_cast<SecretItem*>(element->data);
@@ -646,15 +651,21 @@ ScopedVector<autofill::PasswordForm> NativeBackendLibsecret::ConvertFormList(
g_hash_table_unref(attrs);
if (form) {
if (lookup_form && form->signon_realm != lookup_form->signon_realm) {
- // This is not an exact match, we try PSL matching.
if (lookup_form->scheme != PasswordForm::SCHEME_HTML ||
- form->scheme != PasswordForm::SCHEME_HTML ||
- !(password_manager::IsPublicSuffixDomainMatch(
- lookup_form->signon_realm, form->signon_realm))) {
+ form->scheme != PasswordForm::SCHEME_HTML)
+ continue;
+ // This is not an exact match, we try PSL matching and federated match.
+ if (allow_psl_match &&
+ password_manager::IsPublicSuffixDomainMatch(
+ form->signon_realm, lookup_form->signon_realm)) {
+ psl_domain_match_metric = password_manager::PSL_DOMAIN_MATCH_FOUND;
+ form->is_public_suffix_match = true;
+ } else if (!form->federation_origin.unique() &&
+ password_manager::IsFederatedMatch(form->signon_realm,
+ lookup_form->origin)) {
+ } else {
continue;
}
- psl_domain_match_metric = password_manager::PSL_DOMAIN_MATCH_FOUND;
- form->is_public_suffix_match = true;
}
SecretValue* secretValue = secret_item_get_secret(secretItem);
if (secretValue) {
@@ -670,15 +681,11 @@ ScopedVector<autofill::PasswordForm> NativeBackendLibsecret::ConvertFormList(
}
if (lookup_form) {
- const GURL signon_realm(lookup_form->signon_realm);
- std::string registered_domain =
- password_manager::GetRegistryControlledDomain(signon_realm);
- UMA_HISTOGRAM_ENUMERATION(
- "PasswordManager.PslDomainMatchTriggering",
- password_manager::ShouldPSLDomainMatchingApply(registered_domain)
- ? psl_domain_match_metric
- : password_manager::PSL_DOMAIN_MATCH_NOT_USED,
- password_manager::PSL_DOMAIN_MATCH_COUNT);
+ UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering",
+ allow_psl_match
+ ? psl_domain_match_metric
+ : password_manager::PSL_DOMAIN_MATCH_NOT_USED,
+ password_manager::PSL_DOMAIN_MATCH_COUNT);
}
g_list_free(found);
return forms;
diff --git a/chrome/browser/password_manager/native_backend_libsecret_unittest.cc b/chrome/browser/password_manager/native_backend_libsecret_unittest.cc
index 2fa1cf4..d032803 100644
--- a/chrome/browser/password_manager/native_backend_libsecret_unittest.cc
+++ b/chrome/browser/password_manager/native_backend_libsecret_unittest.cc
@@ -694,6 +694,14 @@ TEST_F(NativeBackendLibsecretTest, PSLUpdatingStrictAddLogin) {
CheckPSLUpdate(UPDATE_BY_ADDLOGIN);
}
+TEST_F(NativeBackendLibsecretTest, FetchFederatedCredential) {
+ other_auth_.signon_realm = "federation://www.example.com/google.com";
+ other_auth_.federation_origin = url::Origin(GURL("https://google.com/"));
+ EXPECT_TRUE(CheckCredentialAvailability(other_auth_,
+ GURL("http://www.example.com/"),
+ PasswordForm::SCHEME_HTML, nullptr));
+}
+
TEST_F(NativeBackendLibsecretTest, BasicUpdateLogin) {
NativeBackendLibsecret backend(42);