0

[FedCM] Parse config field for supporting multiple accounts

Tentatively called "supports_multiple_accounts" in the root of the
config dictionary.

R=npm@chromium.org

Bug: 1498628
Change-Id: If96e99d1b2dc0c320b94930f441eb2b2f2b5adbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5002071
Auto-Submit: Christian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1219610}
This commit is contained in:
Christian Biesinger
2023-11-03 18:04:03 +00:00
committed by Chromium LUCI CQ
parent 537cf83937
commit 1cabbbd495
3 changed files with 34 additions and 0 deletions

@@ -69,6 +69,7 @@ constexpr char kIdAssertionEndpoint[] = "id_assertion_endpoint";
constexpr char kClientMetadataEndpointKey[] = "client_metadata_endpoint";
constexpr char kMetricsEndpoint[] = "metrics_endpoint";
constexpr char kRevocationEndpoint[] = "revocation_endpoint";
constexpr char kSupportsAddAccountKey[] = "supports_add_account";
// Shared between the well-known files and config files
constexpr char kAccountsEndpointKey[] = "accounts_endpoint";
@@ -532,6 +533,8 @@ void OnConfigParsed(const GURL& provider,
}
idp_metadata.idp_login_url =
ExtractEndpoint(provider, response, kLoginUrlKey);
idp_metadata.supports_add_account =
response.FindBool(kSupportsAddAccountKey).value_or(false);
std::move(callback).Run({ParseStatus::kSuccess, fetch_status.response_code},
endpoints, std::move(idp_metadata));
}

@@ -838,6 +838,35 @@ TEST_F(IdpNetworkRequestManagerTest, ParseConfigBrandingMinSize) {
}
}
TEST_F(IdpNetworkRequestManagerTest, ParseConfigSupportsAddAccount) {
const char test_json[] = R"({
"supports_add_account": true
})";
FetchStatus fetch_status;
IdentityProviderMetadata idp_metadata;
std::tie(fetch_status, idp_metadata) =
SendConfigRequestAndWaitForResponse(test_json);
EXPECT_EQ(ParseStatus::kSuccess, fetch_status.parse_status);
EXPECT_EQ(net::HTTP_OK, fetch_status.response_code);
EXPECT_EQ(true, idp_metadata.supports_add_account);
}
TEST_F(IdpNetworkRequestManagerTest, ParseConfigSupportsAddAccountMissing) {
const char test_json[] = R"({
})";
FetchStatus fetch_status;
IdentityProviderMetadata idp_metadata;
std::tie(fetch_status, idp_metadata) =
SendConfigRequestAndWaitForResponse(test_json);
EXPECT_EQ(ParseStatus::kSuccess, fetch_status.parse_status);
EXPECT_EQ(net::HTTP_OK, fetch_status.response_code);
EXPECT_EQ(false, idp_metadata.supports_add_account);
}
// Tests that we send the correct origin for account requests.
TEST_F(IdpNetworkRequestManagerTest, AccountRequestOrigin) {
bool called = false;

@@ -47,6 +47,8 @@ struct CONTENT_EXPORT IdentityProviderMetadata {
// IdentityProviderMetadata so that the UI code can pass it along when an
// Account is selected by the user.
GURL config_url;
// Whether this IdP supports signing in to additional accounts.
bool supports_add_account{false};
};
struct CONTENT_EXPORT IdentityProviderData {