Commit 2adfdb69 authored by zelidrag@chromium.org's avatar zelidrag@chromium.org

Added --lso-host switch that lets us override hosts for LSO URLs.

BUG=168602
TEST=existing unittests

Review URL: https://codereview.chromium.org/11786006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175900 0039d316-1c4b-4281-b951-d872f2087c98
parent 5a20b0a8
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"name": "GaiaTestAuthExtension", "name": "GaiaTestAuthExtension",
"version": "0.0.1", "version": "0.0.1",
"manifest_version": 2, "manifest_version": 2,
"content_security_policy": "default-src 'self'; script-src 'self'; frame-src 'self' https://insecure.com https://www.google.com/accounts/ https://accounts.google.com https://gaiastaging.corp.google.com", "content_security_policy": "default-src 'self'; script-src 'self'; frame-src 'self' https://insecure.com https://www.google.com/accounts/ https://accounts.google.com https://accounts.youtube.com https://gaiastaging.corp.google.com",
"description": "GAIA Test Component Extension", "description": "GAIA Test Component Extension",
"content_scripts": [ "content_scripts": [
{ {
......
...@@ -9,6 +9,8 @@ namespace switches { ...@@ -9,6 +9,8 @@ namespace switches {
const char kClientLoginToOAuth2Url[] = "client-login-to-oauth2-url"; const char kClientLoginToOAuth2Url[] = "client-login-to-oauth2-url";
const char kGaiaHost[] = "gaia-host"; const char kGaiaHost[] = "gaia-host";
const char kGaiaUrlPath[] = "gaia-url-path"; const char kGaiaUrlPath[] = "gaia-url-path";
const char kGoogleApisHost[] = "google-apis-host";
const char kLsoHost[] = "lso-host";
const char kOAuth1LoginScope[] = "oauth1-login-scope"; const char kOAuth1LoginScope[] = "oauth1-login-scope";
const char kOAuth2IssueTokenUrl[] = "oauth2-issue-token-url"; const char kOAuth2IssueTokenUrl[] = "oauth2-issue-token-url";
const char kOAuth2TokenUrl[] = "oauth2-token-url"; const char kOAuth2TokenUrl[] = "oauth2-token-url";
......
...@@ -12,7 +12,7 @@ extern const char kClientLoginToOAuth2Url[]; ...@@ -12,7 +12,7 @@ extern const char kClientLoginToOAuth2Url[];
// Specifies the backend server used for gaia authentications, like sync or // Specifies the backend server used for gaia authentications, like sync or
// policies for example. The https:// prefix and the trailing slash should be // policies for example. The https:// prefix and the trailing slash should be
// omitted. The default value is "www.google.com". // omitted. The default value is "accounts.google.com".
extern const char kGaiaHost[]; extern const char kGaiaHost[];
// Specifies the path prefix for GAIA authentication URL. It should be used // Specifies the path prefix for GAIA authentication URL. It should be used
...@@ -20,6 +20,19 @@ extern const char kGaiaHost[]; ...@@ -20,6 +20,19 @@ extern const char kGaiaHost[];
// used in production. // used in production.
extern const char kGaiaUrlPath[]; extern const char kGaiaUrlPath[];
// Specifies the backend server used for Google API calls. The https:// prefix
// and the trailing slash should be omitted.
// The default value is "www.googleapis.com".
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[];
// TODO(zelidrag): Get rid of all following since all URLs should be
// controlled only with --gaia-host, --lso-host and --google-apis-host.
// Specifies custom OAuth1 login scope for testing purposes. // Specifies custom OAuth1 login scope for testing purposes.
extern const char kOAuth1LoginScope[]; extern const char kOAuth1LoginScope[];
......
...@@ -12,35 +12,34 @@ namespace { ...@@ -12,35 +12,34 @@ namespace {
// Gaia service constants // Gaia service constants
const char kDefaultGaiaBaseUrl[] = "accounts.google.com"; const char kDefaultGaiaBaseUrl[] = "accounts.google.com";
const char kDefaultGoogleApisBaseUrl[] = "www.googleapis.com";
const char kCaptchaUrlPrefixSuffix[] = "/"; const char kCaptchaUrlPrefixSuffix[] = "/";
// API calls from accounts.google.com
const char kClientLoginUrlSuffix[] = "/ClientLogin"; const char kClientLoginUrlSuffix[] = "/ClientLogin";
const char kServiceLoginUrlSuffix[] = "/ServiceLogin"; const char kServiceLoginUrlSuffix[] = "/ServiceLogin";
const char kIssueAuthTokenUrlSuffix[] = "/IssueAuthToken"; const char kIssueAuthTokenUrlSuffix[] = "/IssueAuthToken";
const char kGetUserInfoUrlSuffix[] = "/GetUserInfo"; const char kGetUserInfoUrlSuffix[] = "/GetUserInfo";
const char kTokenAuthUrlSuffix[] = "/TokenAuth"; const char kTokenAuthUrlSuffix[] = "/TokenAuth";
const char kMergeSessionUrlSuffix[] = "/MergeSession"; const char kMergeSessionUrlSuffix[] = "/MergeSession";
const char kOAuthGetAccessTokenUrlSuffix[] = "/OAuthGetAccessToken"; const char kOAuthGetAccessTokenUrlSuffix[] = "/OAuthGetAccessToken";
const char kOAuthWrapBridgeUrlSuffix[] = "/OAuthWrapBridge"; const char kOAuthWrapBridgeUrlSuffix[] = "/OAuthWrapBridge";
const char kOAuth1LoginUrlSuffix[] = "/OAuthLogin"; const char kOAuth1LoginUrlSuffix[] = "/OAuthLogin";
const char kOAuthRevokeTokenUrlSuffix[] = "/AuthSubRevokeToken"; const char kOAuthRevokeTokenUrlSuffix[] = "/AuthSubRevokeToken";
// Federated login constants // API calls from accounts.google.com (LSO)
const char kDefaultFederatedLoginHost[] = "www.google.com";
const char kDefaultFederatedLoginPath[] = "/accounts";
const char kGetOAuthTokenUrlSuffix[] = "/o/oauth/GetOAuthToken/"; const char kGetOAuthTokenUrlSuffix[] = "/o/oauth/GetOAuthToken/";
const char kClientLoginToOAuth2UrlSuffix[] = "/o/oauth2/programmatic_auth";
const char kOAuth2TokenUrlSuffix[] = "/o/oauth2/token";
const char kClientOAuthUrlSuffix[] = "/ClientOAuth";
// API calls from www.googleapis.com
const char kOAuth2IssueTokenUrlSuffix[] = "/oauth2/v2/IssueToken";
const char kOAuthUserInfoUrlSuffix[] = "/oauth2/v1/userinfo";
const char kOAuthWrapBridgeUserInfoScopeUrlSuffix[] = "/auth/userinfo.email";
const char kClientLoginToOAuth2Url[] =
"https://accounts.google.com/o/oauth2/programmatic_auth";
const char kOAuth2TokenUrl[] =
"https://accounts.google.com/o/oauth2/token";
const char kOAuth2IssueTokenUrl[] =
"https://www.googleapis.com/oauth2/v2/IssueToken";
const char kOAuth1LoginScope[] = const char kOAuth1LoginScope[] =
"https://www.google.com/accounts/OAuthLogin"; "https://www.google.com/accounts/OAuthLogin";
const char kOAuthUserInfoUrl[] =
"https://www.googleapis.com/oauth2/v1/userinfo";
void GetSwitchValueWithDefault(const char* switch_value, void GetSwitchValueWithDefault(const char* switch_value,
const char* default_value, const char* default_value,
...@@ -65,8 +64,19 @@ GaiaUrls::GaiaUrls() { ...@@ -65,8 +64,19 @@ GaiaUrls::GaiaUrls() {
GetSwitchValueWithDefault(switches::kGaiaHost, kDefaultGaiaBaseUrl, GetSwitchValueWithDefault(switches::kGaiaHost, kDefaultGaiaBaseUrl,
&host_base); &host_base);
std::string lso_base;
GetSwitchValueWithDefault(switches::kLsoHost, kDefaultGaiaBaseUrl,
&lso_base);
std::string google_apis_base;
GetSwitchValueWithDefault(switches::kGoogleApisHost,
kDefaultGoogleApisBaseUrl,
&google_apis_base);
captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix; captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix;
gaia_origin_url_ = "https://" + host_base; 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_; std::string gaia_url_base = gaia_origin_url_;
if (command_line->HasSwitch(switches::kGaiaUrlPath)) { if (command_line->HasSwitch(switches::kGaiaUrlPath)) {
std::string path = std::string path =
...@@ -79,49 +89,58 @@ GaiaUrls::GaiaUrls() { ...@@ -79,49 +89,58 @@ GaiaUrls::GaiaUrls() {
} }
} }
oauth2_chrome_client_id_ =
google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
oauth2_chrome_client_secret_ =
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; client_login_url_ = gaia_url_base + kClientLoginUrlSuffix;
service_login_url_ = gaia_url_base + kServiceLoginUrlSuffix; service_login_url_ = gaia_url_base + kServiceLoginUrlSuffix;
issue_auth_token_url_ = gaia_url_base + kIssueAuthTokenUrlSuffix; issue_auth_token_url_ = gaia_url_base + kIssueAuthTokenUrlSuffix;
get_user_info_url_ = gaia_url_base + kGetUserInfoUrlSuffix; get_user_info_url_ = gaia_url_base + kGetUserInfoUrlSuffix;
token_auth_url_ = gaia_url_base + kTokenAuthUrlSuffix; token_auth_url_ = gaia_url_base + kTokenAuthUrlSuffix;
merge_session_url_ = gaia_url_base + kMergeSessionUrlSuffix; merge_session_url_ = gaia_url_base + kMergeSessionUrlSuffix;
get_oauth_token_url_ = gaia_url_base + kGetOAuthTokenUrlSuffix;
oauth_get_access_token_url_ = gaia_url_base + oauth_get_access_token_url_ = gaia_url_base +
kOAuthGetAccessTokenUrlSuffix; kOAuthGetAccessTokenUrlSuffix;
oauth_wrap_bridge_url_ = gaia_url_base + kOAuthWrapBridgeUrlSuffix; oauth_wrap_bridge_url_ = gaia_url_base + kOAuthWrapBridgeUrlSuffix;
oauth_revoke_token_url_ = gaia_url_base + kOAuthRevokeTokenUrlSuffix; oauth_revoke_token_url_ = gaia_url_base + kOAuthRevokeTokenUrlSuffix;
oauth1_login_url_ = gaia_url_base + kOAuth1LoginUrlSuffix; oauth1_login_url_ = gaia_url_base + kOAuth1LoginUrlSuffix;
client_oauth_url_ = gaia_url_base + kClientOAuthUrlSuffix;
// URLs from accounts.google.com (LSO).
get_oauth_token_url_ = lso_origin_url_ + kGetOAuthTokenUrlSuffix;
std::string client_login_to_oauth2_url = lso_origin_url_ +
kClientLoginToOAuth2UrlSuffix;
std::string oauth2_token_url = lso_origin_url_ + kOAuth2TokenUrlSuffix;
// URLs from www.googleapis.com.
oauth_wrap_bridge_user_info_scope_ = google_apis_origin_url_ +
kOAuthWrapBridgeUserInfoScopeUrlSuffix;
std::string oauth2_issue_token_url = google_apis_origin_url_ +
kOAuth2IssueTokenUrlSuffix;
std::string oauth_user_info_url = google_apis_origin_url_ +
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.
GetSwitchValueWithDefault(switches::kOAuth1LoginScope, GetSwitchValueWithDefault(switches::kOAuth1LoginScope,
kOAuth1LoginScope, kOAuth1LoginScope,
&oauth1_login_scope_); &oauth1_login_scope_);
// TODO(joaodasilva): these aren't configurable for now, but are managed here
// so that users of Gaia URLs don't have to use static constants.
// http://crbug.com/97126
oauth_wrap_bridge_user_info_scope_ =
"https://www.googleapis.com/auth/userinfo.email";
client_oauth_url_ = "https://accounts.google.com/ClientOAuth";
oauth2_chrome_client_id_ =
google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
oauth2_chrome_client_secret_ =
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
GetSwitchValueWithDefault(switches::kClientLoginToOAuth2Url, GetSwitchValueWithDefault(switches::kClientLoginToOAuth2Url,
kClientLoginToOAuth2Url, client_login_to_oauth2_url.c_str(),
&client_login_to_oauth2_url_); &client_login_to_oauth2_url_);
GetSwitchValueWithDefault(switches::kOAuth2TokenUrl, GetSwitchValueWithDefault(switches::kOAuth2TokenUrl,
kOAuth2TokenUrl, oauth2_token_url.c_str(),
&oauth2_token_url_); &oauth2_token_url_);
GetSwitchValueWithDefault(switches::kOAuth2IssueTokenUrl, GetSwitchValueWithDefault(switches::kOAuth2IssueTokenUrl,
kOAuth2IssueTokenUrl, oauth2_issue_token_url.c_str(),
&oauth2_issue_token_url_); &oauth2_issue_token_url_);
GetSwitchValueWithDefault(switches::kOAuthUserInfoUrl, GetSwitchValueWithDefault(switches::kOAuthUserInfoUrl,
kOAuthUserInfoUrl, oauth_user_info_url.c_str(),
&oauth_user_info_url_); &oauth_user_info_url_);
gaia_login_form_realm_ = "https://accounts.google.com/";
} }
GaiaUrls::~GaiaUrls() { GaiaUrls::~GaiaUrls() {
......
...@@ -52,6 +52,8 @@ class GaiaUrls { ...@@ -52,6 +52,8 @@ class GaiaUrls {
std::string captcha_url_prefix_; std::string captcha_url_prefix_;
std::string gaia_origin_url_; std::string gaia_origin_url_;
std::string lso_origin_url_;
std::string google_apis_origin_url_;
std::string client_login_url_; std::string client_login_url_;
std::string service_login_url_; std::string service_login_url_;
std::string issue_auth_token_url_; std::string issue_auth_token_url_;
......
...@@ -622,6 +622,12 @@ void URLFetcherCore::OnReadCompleted(URLRequest* request, ...@@ -622,6 +622,12 @@ void URLFetcherCore::OnReadCompleted(URLRequest* request,
} }
} }
void URLFetcherCore::OnCertificateRequested(
URLRequest* request,
SSLCertRequestInfo* cert_request_info) {
request->ContinueWithCertificate(NULL);
}
void URLFetcherCore::OnConnectionTypeChanged( void URLFetcherCore::OnConnectionTypeChanged(
NetworkChangeNotifier::ConnectionType type) { NetworkChangeNotifier::ConnectionType type) {
DCHECK_GT(num_retries_on_network_changes_, 0); DCHECK_GT(num_retries_on_network_changes_, 0);
......
...@@ -124,6 +124,9 @@ class URLFetcherCore ...@@ -124,6 +124,9 @@ class URLFetcherCore
virtual void OnResponseStarted(URLRequest* request) OVERRIDE; virtual void OnResponseStarted(URLRequest* request) OVERRIDE;
virtual void OnReadCompleted(URLRequest* request, virtual void OnReadCompleted(URLRequest* request,
int bytes_read) OVERRIDE; int bytes_read) OVERRIDE;
virtual void OnCertificateRequested(
URLRequest* request,
SSLCertRequestInfo* cert_request_info) OVERRIDE;
// Overridden from NetworkChangeNotifier::ConnectionTypeObserver: // Overridden from NetworkChangeNotifier::ConnectionTypeObserver:
virtual void OnConnectionTypeChanged( virtual void OnConnectionTypeChanged(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment