diff options
author | achuith@chromium.org <achuith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-18 09:09:13 +0000 |
---|---|---|
committer | achuith@chromium.org <achuith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-18 09:09:13 +0000 |
commit | e519c435d39e453f532b1ba352ad2944c75895d8 (patch) | |
tree | 212e7ec56c2277b43946724ead049adfc8470c8e /google_apis | |
parent | 6b9aa60aca15ddf94387b208c2a91380cca4ca55 (diff) | |
download | chromium_src-e519c435d39e453f532b1ba352ad2944c75895d8.zip chromium_src-e519c435d39e453f532b1ba352ad2944c75895d8.tar.gz chromium_src-e519c435d39e453f532b1ba352ad2944c75895d8.tar.bz2 |
Deprecate switches gaia-host and gaia-url-path in favor of gaia-url
* Deprecate lso-host to replace with lso-url, which is the complete origin (not just the host).
* Allow for http access of gaia-urls, not just https.
* Add data member gaia_url_ and accessor to GaiaUrls, replacing gaia_origin_url_
* Replace javascript params gaiaOrigin and gaiaUrlPath with gaiaUrl.
* Replace SetGaiaOriginForTesting with SetGaiaUrlForTesting.
BUG=239151
TEST=manual with telemetry auth server. on linux and on the device with GAIA_FLAGS="--gaia-url=https://gaiastaging.corp.google.com --lso-url=https://test-sandbox.auth.corp.google.com --google-apis-host=www.googleapis-test.sandbox.google.com --oauth2-client-id=236834563817.apps.googleusercontent.com --oauth2-client-secret=RsKv5AwFKSzNgE0yjnurkPVI"
Review URL: https://chromiumcodereview.appspot.com/14786022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200977 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/gaia/gaia_auth_util.cc | 2 | ||||
-rw-r--r-- | google_apis/gaia/gaia_switches.cc | 5 | ||||
-rw-r--r-- | google_apis/gaia/gaia_switches.h | 17 | ||||
-rw-r--r-- | google_apis/gaia/gaia_urls.cc | 117 | ||||
-rw-r--r-- | google_apis/gaia/gaia_urls.h | 61 |
5 files changed, 93 insertions, 109 deletions
diff --git a/google_apis/gaia/gaia_auth_util.cc b/google_apis/gaia/gaia_auth_util.cc index 7f6e9c8..6122589 100644 --- a/google_apis/gaia/gaia_auth_util.cc +++ b/google_apis/gaia/gaia_auth_util.cc @@ -69,7 +69,7 @@ bool IsGaiaSignonRealm(const GURL& url) { if (!url.SchemeIsSecure()) return false; - return url == GURL(GaiaUrls::GetInstance()->gaia_origin_url()); + return url == GaiaUrls::GetInstance()->gaia_url(); } } // namespace gaia diff --git a/google_apis/gaia/gaia_switches.cc b/google_apis/gaia/gaia_switches.cc index eb3f85e..c2430b0 100644 --- a/google_apis/gaia/gaia_switches.cc +++ b/google_apis/gaia/gaia_switches.cc @@ -7,10 +7,9 @@ namespace switches { const char kClientLoginToOAuth2Url[] = "client-login-to-oauth2-url"; -const char kGaiaHost[] = "gaia-host"; -const char kGaiaUrlPath[] = "gaia-url-path"; +const char kGaiaUrl[] = "gaia-url"; const char kGoogleApisHost[] = "google-apis-host"; -const char kLsoHost[] = "lso-host"; +const char kLsoUrl[] = "lso-url"; const char kOAuth1LoginScope[] = "oauth1-login-scope"; const char kOAuth2IssueTokenUrl[] = "oauth2-issue-token-url"; const char kOAuth2TokenUrl[] = "oauth2-token-url"; diff --git a/google_apis/gaia/gaia_switches.h b/google_apis/gaia/gaia_switches.h index 52680dd..727a355 100644 --- a/google_apis/gaia/gaia_switches.h +++ b/google_apis/gaia/gaia_switches.h @@ -10,15 +10,9 @@ namespace switches { // Supplies custom client login to OAuth2 URL for testing purposes. extern const char kClientLoginToOAuth2Url[]; -// Specifies the backend server used for gaia authentications, like sync or -// policies for example. The https:// prefix and the trailing slash should be -// omitted. The default value is "accounts.google.com". -extern const char kGaiaHost[]; - -// Specifies the path prefix for GAIA authentication URL. It should be used -// for testing in cases where authentication path prefix differs from the one -// used in production. -extern const char kGaiaUrlPath[]; +// Specifies the path for GAIA authentication URL. The default value is +// "https://accounts.google.com". +extern const char kGaiaUrl[]; // Specifies the backend server used for Google API calls. The https:// prefix // and the trailing slash should be omitted. @@ -26,9 +20,8 @@ extern const char kGaiaUrlPath[]; extern const char kGoogleApisHost[]; // Specifies the backend server used for lso authentication calls. -// The https:// prefix and the trailing slash should be -// omitted. The default value is "accounts.google.com". -extern const char kLsoHost[]; +// "https://accounts.google.com". +extern const char kLsoUrl[]; // TODO(zelidrag): Get rid of all following since all URLs should be // controlled only with --gaia-host, --lso-host and --google-apis-host. diff --git a/google_apis/gaia/gaia_urls.cc b/google_apis/gaia/gaia_urls.cc index 2135c31..4cd0be8a 100644 --- a/google_apis/gaia/gaia_urls.cc +++ b/google_apis/gaia/gaia_urls.cc @@ -5,13 +5,14 @@ #include "google_apis/gaia/gaia_urls.h" #include "base/command_line.h" +#include "base/logging.h" #include "google_apis/gaia/gaia_switches.h" #include "google_apis/google_api_keys.h" namespace { // Gaia service constants -const char kDefaultGaiaBaseUrl[] = "accounts.google.com"; +const char kDefaultGaiaUrl[] = "https://accounts.google.com"; const char kDefaultGoogleApisBaseUrl[] = "www.googleapis.com"; const char kCaptchaUrlPrefixSuffix[] = "/"; @@ -62,36 +63,27 @@ GaiaUrls* GaiaUrls::GetInstance() { } GaiaUrls::GaiaUrls() { - CommandLine* command_line = CommandLine::ForCurrentProcess(); - std::string host_base; - GetSwitchValueWithDefault(switches::kGaiaHost, kDefaultGaiaBaseUrl, - &host_base); + std::string gaia_url_str; + GetSwitchValueWithDefault(switches::kGaiaUrl, + kDefaultGaiaUrl, + &gaia_url_str); + gaia_url_ = GURL(gaia_url_str); + DCHECK(gaia_url_.is_valid()); - std::string lso_base; - GetSwitchValueWithDefault(switches::kLsoHost, kDefaultGaiaBaseUrl, - &lso_base); + GetSwitchValueWithDefault(switches::kLsoUrl, + kDefaultGaiaUrl, + &lso_origin_url_); std::string google_apis_base; GetSwitchValueWithDefault(switches::kGoogleApisHost, kDefaultGoogleApisBaseUrl, &google_apis_base); - captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix; - gaia_origin_url_ = "https://" + host_base; - lso_origin_url_ = "https://" + lso_base; - google_apis_origin_url_ = "https://" + google_apis_base; - std::string gaia_url_base = gaia_origin_url_; - if (command_line->HasSwitch(switches::kGaiaUrlPath)) { - std::string path = - command_line->GetSwitchValueASCII(switches::kGaiaUrlPath); - if (!path.empty()) { - if (path[0] != '/') - gaia_url_base.append("/"); - - gaia_url_base.append(path); - } - } + captcha_url_prefix_ = "http://" + gaia_url_.host() + + (gaia_url_.has_port() ? ":" + gaia_url_.port() : "") + + kCaptchaUrlPrefixSuffix; + google_apis_origin_url_ = "https://" + google_apis_base; oauth2_chrome_client_id_ = google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN); @@ -99,19 +91,18 @@ GaiaUrls::GaiaUrls() { google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN); // URLs from accounts.google.com. - gaia_login_form_realm_ = gaia_url_base + "/"; - client_login_url_ = gaia_url_base + kClientLoginUrlSuffix; - service_login_url_ = gaia_url_base + kServiceLoginUrlSuffix; - service_logout_url_ = gaia_url_base + kServiceLogoutUrlSuffix; - issue_auth_token_url_ = gaia_url_base + kIssueAuthTokenUrlSuffix; - get_user_info_url_ = gaia_url_base + kGetUserInfoUrlSuffix; - token_auth_url_ = gaia_url_base + kTokenAuthUrlSuffix; - merge_session_url_ = gaia_url_base + kMergeSessionUrlSuffix; - oauth_get_access_token_url_ = gaia_url_base + - kOAuthGetAccessTokenUrlSuffix; - oauth_wrap_bridge_url_ = gaia_url_base + kOAuthWrapBridgeUrlSuffix; - oauth_revoke_token_url_ = gaia_url_base + kOAuthRevokeTokenUrlSuffix; - oauth1_login_url_ = gaia_url_base + kOAuth1LoginUrlSuffix; + gaia_login_form_realm_ = gaia_url_str + "/"; + client_login_url_ = gaia_url_str + kClientLoginUrlSuffix; + service_login_url_ = gaia_url_str + kServiceLoginUrlSuffix; + service_logout_url_ = gaia_url_str + kServiceLogoutUrlSuffix; + issue_auth_token_url_ = gaia_url_str + kIssueAuthTokenUrlSuffix; + get_user_info_url_ = gaia_url_str + kGetUserInfoUrlSuffix; + token_auth_url_ = gaia_url_str + kTokenAuthUrlSuffix; + merge_session_url_ = gaia_url_str + kMergeSessionUrlSuffix; + oauth_get_access_token_url_ = gaia_url_str + kOAuthGetAccessTokenUrlSuffix; + oauth_wrap_bridge_url_ = gaia_url_str + kOAuthWrapBridgeUrlSuffix; + oauth_revoke_token_url_ = gaia_url_str + kOAuthRevokeTokenUrlSuffix; + oauth1_login_url_ = gaia_url_str + kOAuth1LoginUrlSuffix; // URLs from accounts.google.com (LSO). get_oauth_token_url_ = lso_origin_url_ + kGetOAuthTokenUrlSuffix; @@ -130,7 +121,7 @@ GaiaUrls::GaiaUrls() { kOAuthUserInfoUrlSuffix; // TODO(zelidrag): Get rid of all these switches since all URLs should be - // controlled only with --gaia-host, --lso-host and --google-apis-host. + // controlled only with --gaia-url, --lso-url and --google-apis-host. GetSwitchValueWithDefault(switches::kOAuth1LoginScope, kOAuth1LoginScope, &oauth1_login_scope_); @@ -151,102 +142,102 @@ GaiaUrls::GaiaUrls() { GaiaUrls::~GaiaUrls() { } -const std::string& GaiaUrls::captcha_url_prefix() { +const std::string& GaiaUrls::captcha_url_prefix() const { return captcha_url_prefix_; } -const std::string& GaiaUrls::gaia_origin_url() { - return gaia_origin_url_; +const GURL& GaiaUrls::gaia_url() const { + return gaia_url_; } -const std::string& GaiaUrls::client_login_url() { +const std::string& GaiaUrls::client_login_url() const { return client_login_url_; } -const std::string& GaiaUrls::service_login_url() { +const std::string& GaiaUrls::service_login_url() const { return service_login_url_; } -const std::string& GaiaUrls::service_logout_url() { +const std::string& GaiaUrls::service_logout_url() const { return service_logout_url_; } -const std::string& GaiaUrls::issue_auth_token_url() { +const std::string& GaiaUrls::issue_auth_token_url() const { return issue_auth_token_url_; } -const std::string& GaiaUrls::get_user_info_url() { +const std::string& GaiaUrls::get_user_info_url() const { return get_user_info_url_; } -const std::string& GaiaUrls::token_auth_url() { +const std::string& GaiaUrls::token_auth_url() const { return token_auth_url_; } -const std::string& GaiaUrls::merge_session_url() { +const std::string& GaiaUrls::merge_session_url() const { return merge_session_url_; } -const std::string& GaiaUrls::get_oauth_token_url() { +const std::string& GaiaUrls::get_oauth_token_url() const { return get_oauth_token_url_; } -const std::string& GaiaUrls::oauth_get_access_token_url() { +const std::string& GaiaUrls::oauth_get_access_token_url() const { return oauth_get_access_token_url_; } -const std::string& GaiaUrls::oauth_wrap_bridge_url() { +const std::string& GaiaUrls::oauth_wrap_bridge_url() const { return oauth_wrap_bridge_url_; } -const std::string& GaiaUrls::oauth_user_info_url() { +const std::string& GaiaUrls::oauth_user_info_url() const { return oauth_user_info_url_; } -const std::string& GaiaUrls::oauth_revoke_token_url() { +const std::string& GaiaUrls::oauth_revoke_token_url() const { return oauth_revoke_token_url_; } -const std::string& GaiaUrls::oauth1_login_url() { +const std::string& GaiaUrls::oauth1_login_url() const { return oauth1_login_url_; } -const std::string& GaiaUrls::oauth1_login_scope() { +const std::string& GaiaUrls::oauth1_login_scope() const { return oauth1_login_scope_; } -const std::string& GaiaUrls::oauth_wrap_bridge_user_info_scope() { +const std::string& GaiaUrls::oauth_wrap_bridge_user_info_scope() const { return oauth_wrap_bridge_user_info_scope_; } -const std::string& GaiaUrls::oauth2_chrome_client_id() { +const std::string& GaiaUrls::oauth2_chrome_client_id() const { return oauth2_chrome_client_id_; } -const std::string& GaiaUrls::oauth2_chrome_client_secret() { +const std::string& GaiaUrls::oauth2_chrome_client_secret() const { return oauth2_chrome_client_secret_; } -const std::string& GaiaUrls::client_login_to_oauth2_url() { +const std::string& GaiaUrls::client_login_to_oauth2_url() const { return client_login_to_oauth2_url_; } -const std::string& GaiaUrls::oauth2_auth_url() { +const std::string& GaiaUrls::oauth2_auth_url() const { return oauth2_auth_url_; } -const std::string& GaiaUrls::oauth2_token_url() { +const std::string& GaiaUrls::oauth2_token_url() const { return oauth2_token_url_; } -const std::string& GaiaUrls::oauth2_issue_token_url() { +const std::string& GaiaUrls::oauth2_issue_token_url() const { return oauth2_issue_token_url_; } -const std::string& GaiaUrls::oauth2_revoke_url() { +const std::string& GaiaUrls::oauth2_revoke_url() const { return oauth2_revoke_url_; } -const std::string& GaiaUrls::gaia_login_form_realm() { +const std::string& GaiaUrls::gaia_login_form_realm() const { return gaia_login_form_realm_; } diff --git a/google_apis/gaia/gaia_urls.h b/google_apis/gaia/gaia_urls.h index 3b434e4b..605aa64 100644 --- a/google_apis/gaia/gaia_urls.h +++ b/google_apis/gaia/gaia_urls.h @@ -8,6 +8,7 @@ #include <string> #include "base/memory/singleton.h" +#include "googleurl/src/gurl.h" // A signleton that provides all the URLs that are used for connecting to GAIA. class GaiaUrls { @@ -15,35 +16,35 @@ class GaiaUrls { static GaiaUrls* GetInstance(); // The URLs for different calls in the Google Accounts programmatic login API. - const std::string& captcha_url_prefix(); - - const std::string& gaia_origin_url(); - const std::string& client_login_url(); - const std::string& service_login_url(); - const std::string& service_logout_url(); - const std::string& issue_auth_token_url(); - const std::string& get_user_info_url(); - const std::string& token_auth_url(); - const std::string& merge_session_url(); - const std::string& get_oauth_token_url(); - const std::string& oauth_get_access_token_url(); - const std::string& oauth_wrap_bridge_url(); - const std::string& oauth_user_info_url(); - const std::string& oauth_revoke_token_url(); - const std::string& oauth1_login_url(); - - const std::string& oauth1_login_scope(); - const std::string& oauth_wrap_bridge_user_info_scope(); - - const std::string& oauth2_chrome_client_id(); - const std::string& oauth2_chrome_client_secret(); - const std::string& client_login_to_oauth2_url(); - const std::string& oauth2_auth_url(); - const std::string& oauth2_token_url(); - const std::string& oauth2_issue_token_url(); - const std::string& oauth2_revoke_url(); - - const std::string& gaia_login_form_realm(); + const std::string& captcha_url_prefix() const; + + const GURL& gaia_url() const; + const std::string& client_login_url() const; + const std::string& service_login_url() const; + const std::string& service_logout_url() const; + const std::string& issue_auth_token_url() const; + const std::string& get_user_info_url() const; + const std::string& token_auth_url() const; + const std::string& merge_session_url() const; + const std::string& get_oauth_token_url() const; + const std::string& oauth_get_access_token_url() const; + const std::string& oauth_wrap_bridge_url() const; + const std::string& oauth_user_info_url() const; + const std::string& oauth_revoke_token_url() const; + const std::string& oauth1_login_url() const; + + const std::string& oauth1_login_scope() const; + const std::string& oauth_wrap_bridge_user_info_scope() const; + + const std::string& oauth2_chrome_client_id() const; + const std::string& oauth2_chrome_client_secret() const; + const std::string& client_login_to_oauth2_url() const; + const std::string& oauth2_auth_url() const; + const std::string& oauth2_token_url() const; + const std::string& oauth2_issue_token_url() const; + const std::string& oauth2_revoke_url() const; + + const std::string& gaia_login_form_realm() const; private: GaiaUrls(); @@ -53,7 +54,7 @@ class GaiaUrls { std::string captcha_url_prefix_; - std::string gaia_origin_url_; + GURL gaia_url_; std::string lso_origin_url_; std::string google_apis_origin_url_; std::string client_login_url_; |