summaryrefslogtreecommitdiffstats
path: root/google_apis
diff options
context:
space:
mode:
authorrmsousa@chromium.org <rmsousa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-16 05:18:38 +0000
committerrmsousa@chromium.org <rmsousa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-16 05:18:38 +0000
commitd66d817427d21599245fedf4c60c6472be4b3552 (patch)
treeb47b19d9d38b4f515951cf7f2a70070a9a9a7138 /google_apis
parent788e9517ef2bef436cac7267dd75d5f356d35975 (diff)
downloadchromium_src-d66d817427d21599245fedf4c60c6472be4b3552.zip
chromium_src-d66d817427d21599245fedf4c60c6472be4b3552.tar.gz
chromium_src-d66d817427d21599245fedf4c60c6472be4b3552.tar.bz2
Support service accounts in the chromoting host.
This change allows running a host *already configured* with service account credentials. Support for obtaining service account credentails during host setup will come in follow up CLs. BUG=224742 Review URL: https://chromiumcodereview.appspot.com/19796006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217941 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r--google_apis/google_api_keys.cc23
-rw-r--r--google_apis/google_api_keys.h1
-rwxr-xr-xgoogle_apis/google_api_keys.py3
-rw-r--r--google_apis/google_api_keys_unittest.cc63
4 files changed, 88 insertions, 2 deletions
diff --git a/google_apis/google_api_keys.cc b/google_apis/google_api_keys.cc
index fc4b547..0baf00d 100644
--- a/google_apis/google_api_keys.cc
+++ b/google_apis/google_api_keys.cc
@@ -49,6 +49,14 @@
#define GOOGLE_CLIENT_SECRET_REMOTING DUMMY_API_TOKEN
#endif
+#if !defined(GOOGLE_CLIENT_ID_REMOTING_HOST)
+#define GOOGLE_CLIENT_ID_REMOTING_HOST DUMMY_API_TOKEN
+#endif
+
+#if !defined(GOOGLE_CLIENT_SECRET_REMOTING_HOST)
+#define GOOGLE_CLIENT_SECRET_REMOTING_HOST DUMMY_API_TOKEN
+#endif
+
// These are used as shortcuts for developers and users providing
// OAuth credentials via preprocessor defines or environment
// variables. If set, they will be used to replace any of the client
@@ -152,6 +160,21 @@ class APIKeyCache {
default_client_secret,
environment.get(),
command_line);
+
+ client_ids_[CLIENT_REMOTING_HOST] = CalculateKeyValue(
+ GOOGLE_CLIENT_ID_REMOTING_HOST,
+ STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_ID_REMOTING_HOST),
+ NULL,
+ default_client_id,
+ environment.get(),
+ command_line);
+ client_secrets_[CLIENT_REMOTING_HOST] = CalculateKeyValue(
+ GOOGLE_CLIENT_SECRET_REMOTING_HOST,
+ STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_SECRET_REMOTING_HOST),
+ NULL,
+ default_client_secret,
+ environment.get(),
+ command_line);
}
std::string api_key() const { return api_key_; }
diff --git a/google_apis/google_api_keys.h b/google_apis/google_api_keys.h
index 28421e8..8f4bc7e 100644
--- a/google_apis/google_api_keys.h
+++ b/google_apis/google_api_keys.h
@@ -71,6 +71,7 @@ enum OAuth2Client {
CLIENT_MAIN, // Several different features use this.
CLIENT_CLOUD_PRINT,
CLIENT_REMOTING,
+ CLIENT_REMOTING_HOST,
CLIENT_NUM_ITEMS // Must be last item.
};
diff --git a/google_apis/google_api_keys.py b/google_apis/google_api_keys.py
index 6776aae..a756cac 100755
--- a/google_apis/google_api_keys.py
+++ b/google_apis/google_api_keys.py
@@ -88,3 +88,6 @@ if __name__ == "__main__":
print 'GOOGLE_CLIENT_SECRET_CLOUD_PRINT=%s' % GetClientSecret('CLOUD_PRINT')
print 'GOOGLE_CLIENT_ID_REMOTING=%s' % GetClientID('REMOTING')
print 'GOOGLE_CLIENT_SECRET_REMOTING=%s' % GetClientSecret('REMOTING')
+ print 'GOOGLE_CLIENT_ID_REMOTING_HOST=%s' % GetClientID('REMOTING_HOST')
+ print 'GOOGLE_CLIENT_SECRET_REMOTING_HOST=%s' % GetClientSecret(
+ 'REMOTING_HOST')
diff --git a/google_apis/google_api_keys_unittest.cc b/google_apis/google_api_keys_unittest.cc
index 4d338f5..7432f93 100644
--- a/google_apis/google_api_keys_unittest.cc
+++ b/google_apis/google_api_keys_unittest.cc
@@ -59,8 +59,10 @@ class GoogleAPIKeysTest : public testing::Test {
env_cache_[4].variable_name = "GOOGLE_CLIENT_SECRET_CLOUD_PRINT";
env_cache_[5].variable_name = "GOOGLE_CLIENT_ID_REMOTING";
env_cache_[6].variable_name = "GOOGLE_CLIENT_SECRET_REMOTING";
- env_cache_[7].variable_name = "GOOGLE_DEFAULT_CLIENT_ID";
- env_cache_[8].variable_name = "GOOGLE_DEFAULT_CLIENT_SECRET";
+ env_cache_[7].variable_name = "GOOGLE_CLIENT_ID_REMOTING_HOST";
+ env_cache_[8].variable_name = "GOOGLE_CLIENT_SECRET_REMOTING_HOST";
+ env_cache_[9].variable_name = "GOOGLE_DEFAULT_CLIENT_ID";
+ env_cache_[10].variable_name = "GOOGLE_DEFAULT_CLIENT_SECRET";
}
virtual void SetUp() {
@@ -114,6 +116,8 @@ namespace official_build {
#undef GOOGLE_CLIENT_SECRET_CLOUD_PRINT
#undef GOOGLE_CLIENT_ID_REMOTING
#undef GOOGLE_CLIENT_SECRET_REMOTING
+#undef GOOGLE_CLIENT_ID_REMOTING_HOST
+#undef GOOGLE_CLIENT_SECRET_REMOTING_HOST
#undef GOOGLE_DEFAULT_CLIENT_ID
#undef GOOGLE_DEFAULT_CLIENT_SECRET
@@ -150,6 +154,11 @@ TEST_F(GoogleAPIKeysTest, OfficialKeys) {
std::string secret_remoting =
testcase::g_api_key_cache.Get().GetClientSecret(
testcase::CLIENT_REMOTING);
+ std::string id_remoting_host = testcase::g_api_key_cache.Get().GetClientID(
+ testcase::CLIENT_REMOTING_HOST);
+ std::string secret_remoting_host =
+ testcase::g_api_key_cache.Get().GetClientSecret(
+ testcase::CLIENT_REMOTING_HOST);
EXPECT_NE(0u, api_key.size());
EXPECT_NE(DUMMY_API_TOKEN, api_key);
@@ -180,6 +189,14 @@ TEST_F(GoogleAPIKeysTest, OfficialKeys) {
EXPECT_NE(0u, secret_remoting.size());
EXPECT_NE(DUMMY_API_TOKEN, secret_remoting);
EXPECT_NE(kDummyToken, secret_remoting);
+
+ EXPECT_NE(0u, id_remoting_host.size());
+ EXPECT_NE(DUMMY_API_TOKEN, id_remoting_host);
+ EXPECT_NE(kDummyToken, id_remoting_host);
+
+ EXPECT_NE(0u, secret_remoting_host.size());
+ EXPECT_NE(DUMMY_API_TOKEN, secret_remoting_host);
+ EXPECT_NE(kDummyToken, secret_remoting_host);
}
#endif // defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS)
@@ -201,6 +218,8 @@ namespace default_keys {
#undef GOOGLE_CLIENT_SECRET_CLOUD_PRINT
#undef GOOGLE_CLIENT_ID_REMOTING
#undef GOOGLE_CLIENT_SECRET_REMOTING
+#undef GOOGLE_CLIENT_ID_REMOTING_HOST
+#undef GOOGLE_CLIENT_SECRET_REMOTING_HOST
#undef GOOGLE_DEFAULT_CLIENT_ID
#undef GOOGLE_DEFAULT_CLIENT_SECRET
@@ -232,6 +251,11 @@ TEST_F(GoogleAPIKeysTest, DefaultKeys) {
std::string secret_remoting =
testcase::g_api_key_cache.Get().GetClientSecret(
testcase::CLIENT_REMOTING);
+ std::string id_remoting_host = testcase::g_api_key_cache.Get().GetClientID(
+ testcase::CLIENT_REMOTING_HOST);
+ std::string secret_remoting_host =
+ testcase::g_api_key_cache.Get().GetClientSecret(
+ testcase::CLIENT_REMOTING_HOST);
EXPECT_EQ(kDummyToken, api_key);
EXPECT_EQ(kDummyToken, id_main);
@@ -240,6 +264,8 @@ TEST_F(GoogleAPIKeysTest, DefaultKeys) {
EXPECT_EQ(kDummyToken, secret_cloud_print);
EXPECT_EQ(kDummyToken, id_remoting);
EXPECT_EQ(kDummyToken, secret_remoting);
+ EXPECT_EQ(kDummyToken, id_remoting_host);
+ EXPECT_EQ(kDummyToken, secret_remoting_host);
}
// Override a couple of keys, leave the rest default.
@@ -255,6 +281,8 @@ namespace override_some_keys {
#undef GOOGLE_CLIENT_SECRET_CLOUD_PRINT
#undef GOOGLE_CLIENT_ID_REMOTING
#undef GOOGLE_CLIENT_SECRET_REMOTING
+#undef GOOGLE_CLIENT_ID_REMOTING_HOST
+#undef GOOGLE_CLIENT_SECRET_REMOTING_HOST
#undef GOOGLE_DEFAULT_CLIENT_ID
#undef GOOGLE_DEFAULT_CLIENT_SECRET
@@ -289,6 +317,11 @@ TEST_F(GoogleAPIKeysTest, OverrideSomeKeys) {
std::string secret_remoting =
testcase::g_api_key_cache.Get().GetClientSecret(
testcase::CLIENT_REMOTING);
+ std::string id_remoting_host = testcase::g_api_key_cache.Get().GetClientID(
+ testcase::CLIENT_REMOTING_HOST);
+ std::string secret_remoting_host =
+ testcase::g_api_key_cache.Get().GetClientSecret(
+ testcase::CLIENT_REMOTING_HOST);
EXPECT_EQ("API_KEY override", api_key);
EXPECT_EQ(kDummyToken, id_main);
@@ -297,6 +330,8 @@ TEST_F(GoogleAPIKeysTest, OverrideSomeKeys) {
EXPECT_EQ(kDummyToken, secret_cloud_print);
EXPECT_EQ("CLIENT_ID_REMOTING override", id_remoting);
EXPECT_EQ(kDummyToken, secret_remoting);
+ EXPECT_EQ(kDummyToken, id_remoting_host);
+ EXPECT_EQ(kDummyToken, secret_remoting_host);
}
// Override all keys.
@@ -312,6 +347,8 @@ namespace override_all_keys {
#undef GOOGLE_CLIENT_SECRET_CLOUD_PRINT
#undef GOOGLE_CLIENT_ID_REMOTING
#undef GOOGLE_CLIENT_SECRET_REMOTING
+#undef GOOGLE_CLIENT_ID_REMOTING_HOST
+#undef GOOGLE_CLIENT_SECRET_REMOTING_HOST
#undef GOOGLE_DEFAULT_CLIENT_ID
#undef GOOGLE_DEFAULT_CLIENT_SECRET
@@ -322,6 +359,8 @@ namespace override_all_keys {
#define GOOGLE_CLIENT_SECRET_CLOUD_PRINT "SECRET_CLOUD_PRINT"
#define GOOGLE_CLIENT_ID_REMOTING "ID_REMOTING"
#define GOOGLE_CLIENT_SECRET_REMOTING "SECRET_REMOTING"
+#define GOOGLE_CLIENT_ID_REMOTING_HOST "ID_REMOTING_HOST"
+#define GOOGLE_CLIENT_SECRET_REMOTING_HOST "SECRET_REMOTING_HOST"
// Undef include guard so things get defined again, within this namespace.
#undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
@@ -351,6 +390,11 @@ TEST_F(GoogleAPIKeysTest, OverrideAllKeys) {
std::string secret_remoting =
testcase::g_api_key_cache.Get().GetClientSecret(
testcase::CLIENT_REMOTING);
+ std::string id_remoting_host = testcase::g_api_key_cache.Get().GetClientID(
+ testcase::CLIENT_REMOTING_HOST);
+ std::string secret_remoting_host =
+ testcase::g_api_key_cache.Get().GetClientSecret(
+ testcase::CLIENT_REMOTING_HOST);
EXPECT_EQ("API_KEY", api_key);
EXPECT_EQ("ID_MAIN", id_main);
@@ -359,6 +403,8 @@ TEST_F(GoogleAPIKeysTest, OverrideAllKeys) {
EXPECT_EQ("SECRET_CLOUD_PRINT", secret_cloud_print);
EXPECT_EQ("ID_REMOTING", id_remoting);
EXPECT_EQ("SECRET_REMOTING", secret_remoting);
+ EXPECT_EQ("ID_REMOTING_HOST", id_remoting_host);
+ EXPECT_EQ("SECRET_REMOTING_HOST", secret_remoting_host);
}
// Override all keys using both preprocessor defines and environment
@@ -375,6 +421,8 @@ namespace override_all_keys_env {
#undef GOOGLE_CLIENT_SECRET_CLOUD_PRINT
#undef GOOGLE_CLIENT_ID_REMOTING
#undef GOOGLE_CLIENT_SECRET_REMOTING
+#undef GOOGLE_CLIENT_ID_REMOTING_HOST
+#undef GOOGLE_CLIENT_SECRET_REMOTING_HOST
#undef GOOGLE_DEFAULT_CLIENT_ID
#undef GOOGLE_DEFAULT_CLIENT_SECRET
@@ -385,6 +433,8 @@ namespace override_all_keys_env {
#define GOOGLE_CLIENT_SECRET_CLOUD_PRINT "SECRET_CLOUD_PRINT"
#define GOOGLE_CLIENT_ID_REMOTING "ID_REMOTING"
#define GOOGLE_CLIENT_SECRET_REMOTING "SECRET_REMOTING"
+#define GOOGLE_CLIENT_ID_REMOTING_HOST "ID_REMOTING_HOST"
+#define GOOGLE_CLIENT_SECRET_REMOTING_HOST "SECRET_REMOTING_HOST"
// Undef include guard so things get defined again, within this namespace.
#undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
@@ -401,9 +451,11 @@ TEST_F(GoogleAPIKeysTest, OverrideAllKeysUsingEnvironment) {
env->SetVar("GOOGLE_CLIENT_ID_MAIN", "env-ID_MAIN");
env->SetVar("GOOGLE_CLIENT_ID_CLOUD_PRINT", "env-ID_CLOUD_PRINT");
env->SetVar("GOOGLE_CLIENT_ID_REMOTING", "env-ID_REMOTING");
+ env->SetVar("GOOGLE_CLIENT_ID_REMOTING_HOST", "env-ID_REMOTING_HOST");
env->SetVar("GOOGLE_CLIENT_SECRET_MAIN", "env-SECRET_MAIN");
env->SetVar("GOOGLE_CLIENT_SECRET_CLOUD_PRINT", "env-SECRET_CLOUD_PRINT");
env->SetVar("GOOGLE_CLIENT_SECRET_REMOTING", "env-SECRET_REMOTING");
+ env->SetVar("GOOGLE_CLIENT_SECRET_REMOTING_HOST", "env-SECRET_REMOTING_HOST");
EXPECT_TRUE(testcase::HasKeysConfigured());
@@ -425,6 +477,11 @@ TEST_F(GoogleAPIKeysTest, OverrideAllKeysUsingEnvironment) {
std::string secret_remoting =
testcase::g_api_key_cache.Get().GetClientSecret(
testcase::CLIENT_REMOTING);
+ std::string id_remoting_host = testcase::g_api_key_cache.Get().GetClientID(
+ testcase::CLIENT_REMOTING_HOST);
+ std::string secret_remoting_host =
+ testcase::g_api_key_cache.Get().GetClientSecret(
+ testcase::CLIENT_REMOTING_HOST);
EXPECT_EQ("env-API_KEY", api_key);
EXPECT_EQ("env-ID_MAIN", id_main);
@@ -433,6 +490,8 @@ TEST_F(GoogleAPIKeysTest, OverrideAllKeysUsingEnvironment) {
EXPECT_EQ("env-SECRET_CLOUD_PRINT", secret_cloud_print);
EXPECT_EQ("env-ID_REMOTING", id_remoting);
EXPECT_EQ("env-SECRET_REMOTING", secret_remoting);
+ EXPECT_EQ("env-ID_REMOTING_HOST", id_remoting_host);
+ EXPECT_EQ("env-SECRET_REMOTING_HOST", secret_remoting_host);
}
#endif // defined(OS_LINUX) || defined(OS_MACOSX)