Skip to content

Commit

Permalink
Remove command-line flags for OAuth scopes.
Browse files Browse the repository at this point in the history
There is no reason why one would want to switch to alternate OAuth
scopes, because these are identifiers and not URLs to make requests
to.

BUG=chromium:350299
TBR=bauerb@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256541 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mnissler@chromium.org committed Mar 12, 2014
1 parent a7789f2 commit 95ea945
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 57 deletions.
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/login/oauth2_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class OAuth2Test : public OobeBaseTest {

FakeGaia::AccessTokenInfo auth_login_token_info;
auth_login_token_info.token = kTestAuthLoginToken;
auth_login_token_info.scopes.insert(gaia_urls->oauth1_login_scope());
auth_login_token_info.scopes.insert(GaiaConstants::kOAuth1LoginScope);
auth_login_token_info.audience = gaia_urls->oauth2_chrome_client_id();
fake_gaia_->IssueOAuthToken(kTestRefreshToken, auth_login_token_info);
}
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/chromeos/login/oauth2_login_verifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "chromeos/network/network_state_handler.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h"
#include "third_party/cros_system_api/dbus/service_constants.h"

using content::BrowserThread;
Expand Down Expand Up @@ -102,7 +101,7 @@ void OAuth2LoginVerifier::VerifyProfileTokens(Profile* profile) {

void OAuth2LoginVerifier::StartFetchingOAuthLoginAccessToken(Profile* profile) {
OAuth2TokenService::ScopeSet scopes;
scopes.insert(GaiaUrls::GetInstance()->oauth1_login_scope());
scopes.insert(GaiaConstants::kOAuth1LoginScope);
ProfileOAuth2TokenService* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
SigninManagerBase* signin_manager =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ void PolicyOAuth2TokenFetcher::StartFetchingRefreshToken() {
void PolicyOAuth2TokenFetcher::StartFetchingAccessToken() {
std::vector<std::string> scopes;
scopes.push_back(GaiaConstants::kDeviceManagementServiceOAuth);
scopes.push_back(
GaiaUrls::GetInstance()->oauth_wrap_bridge_user_info_scope());
scopes.push_back(GaiaConstants::kOAuthWrapBridgeUserInfoScope);
access_token_fetcher_.reset(
new OAuth2AccessTokenFetcherImpl(this, system_context_getter_.get()));
access_token_fetcher_->Start(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ class UserCloudPolicyManagerChromeOSTest : public testing::Test {
EXPECT_TRUE(token_service);
OAuth2TokenService::ScopeSet scopes;
scopes.insert(GaiaConstants::kDeviceManagementServiceOAuth);
scopes.insert(
GaiaUrls::GetInstance()->oauth_wrap_bridge_user_info_scope());
scopes.insert(GaiaConstants::kOAuthWrapBridgeUserInfoScope);
token_service->IssueTokenForScope(
scopes, "5678",
base::Time::Now() + base::TimeDelta::FromSeconds(3600));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "components/policy/core/common/cloud/cloud_policy_core.h"
#include "content/public/browser/notification_source.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h"

namespace policy {

Expand Down Expand Up @@ -91,7 +90,7 @@ void UserCloudPolicyTokenForwarder::Initialize() {
void UserCloudPolicyTokenForwarder::RequestAccessToken() {
OAuth2TokenService::ScopeSet scopes;
scopes.insert(GaiaConstants::kDeviceManagementServiceOAuth);
scopes.insert(GaiaUrls::GetInstance()->oauth_wrap_bridge_user_info_scope());
scopes.insert(GaiaConstants::kOAuthWrapBridgeUserInfoScope);
request_ = token_service_->StartRequest(
signin_manager_->GetAuthenticatedAccountId(), scopes, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "chrome/browser/chromeos/settings/token_encryptor.h"
#include "chrome/common/pref_names.h"
#include "chromeos/cryptohome/system_salt_getter.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "policy/proto/device_management_backend.pb.h"
Expand Down Expand Up @@ -318,8 +319,7 @@ void DeviceOAuth2TokenService::StartValidation() {
gaia_oauth_client_->RefreshToken(
client_info,
refresh_token_,
std::vector<std::string>(1,
gaia_urls->oauth_wrap_bridge_user_info_scope()),
std::vector<std::string>(1, GaiaConstants::kOAuthWrapBridgeUserInfoScope),
max_refresh_token_validation_retries_,
this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_status.h"

using GaiaConstants::kChromeSyncManagedOAuth2Scope;
using base::Time;
using gaia::GaiaOAuthClient;
using GaiaConstants::kChromeSyncManagedOAuth2Scope;
using net::URLFetcher;
using net::URLFetcherDelegate;
using net::URLRequestContextGetter;
Expand Down Expand Up @@ -129,7 +129,7 @@ void ManagedUserRefreshTokenFetcherImpl::Start(

void ManagedUserRefreshTokenFetcherImpl::StartFetching() {
OAuth2TokenService::ScopeSet scopes;
scopes.insert(GaiaUrls::GetInstance()->oauth1_login_scope());
scopes.insert(GaiaConstants::kOAuth1LoginScope);
access_token_request_ = oauth2_token_service_->StartRequest(
account_id_, scopes, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_oauth_client.h"
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/gaia/google_service_auth_error.h"
Expand Down Expand Up @@ -79,8 +80,7 @@ void VerifyTokenRequest(
std::vector<FakeProfileOAuth2TokenService::PendingRequest> requests) {
ASSERT_EQ(1u, requests.size());
EXPECT_EQ(1u, requests[0].scopes.size());
EXPECT_EQ(1u, requests[0].scopes.count(
GaiaUrls::GetInstance()->oauth1_login_scope()));
EXPECT_EQ(1u, requests[0].scopes.count(GaiaConstants::kOAuth1LoginScope));
}

} // namespace
Expand Down
5 changes: 3 additions & 2 deletions google_apis/gaia/fake_gaia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/base/url_util.h"
#include "net/cookies/parsed_cookie.h"
Expand Down Expand Up @@ -263,7 +264,7 @@ void FakeGaia::HandleProgramaticAuth(
GaiaUrls* gaia_urls = GaiaUrls::GetInstance();
std::string scope;
if (!GetQueryParameter(request.content, "scope", &scope) ||
gaia_urls->oauth1_login_scope() != scope) {
GaiaConstants::kOAuth1LoginScope != scope) {
return;
}

Expand Down Expand Up @@ -434,7 +435,7 @@ void FakeGaia::HandleAuthToken(const HttpRequest& request,
return;
}

if (GaiaUrls::GetInstance()->oauth1_login_scope() != scope) {
if (GaiaConstants::kOAuth1LoginScope != scope) {
http_response->set_code(net::HTTP_BAD_REQUEST);
LOG(ERROR) << "Invalid scope for /o/oauth2/token - " << scope;
return;
Expand Down
4 changes: 2 additions & 2 deletions google_apis/gaia/gaia_auth_fetcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ std::string GaiaAuthFetcher::MakeIssueAuthTokenBody(
// static
std::string GaiaAuthFetcher::MakeGetAuthCodeBody() {
std::string encoded_scope = net::EscapeUrlEncodedData(
GaiaUrls::GetInstance()->oauth1_login_scope(), true);
GaiaConstants::kOAuth1LoginScope, true);
std::string encoded_client_id = net::EscapeUrlEncodedData(
GaiaUrls::GetInstance()->oauth2_chrome_client_id(), true);
return base::StringPrintf(kClientLoginToOAuth2BodyFormat,
Expand All @@ -317,7 +317,7 @@ std::string GaiaAuthFetcher::MakeGetAuthCodeBody() {
std::string GaiaAuthFetcher::MakeGetTokenPairBody(
const std::string& auth_code) {
std::string encoded_scope = net::EscapeUrlEncodedData(
GaiaUrls::GetInstance()->oauth1_login_scope(), true);
GaiaConstants::kOAuth1LoginScope, true);
std::string encoded_client_id = net::EscapeUrlEncodedData(
GaiaUrls::GetInstance()->oauth2_chrome_client_id(), true);
std::string encoded_client_secret = net::EscapeUrlEncodedData(
Expand Down
5 changes: 5 additions & 0 deletions google_apis/gaia/gaia_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ const char kSyncService[] = "chromiumsync";
// Service name for remoting.
const char kRemotingService[] = "chromoting";

// OAuth scopes.
const char kOAuth1LoginScope[] = "https://www.google.com/accounts/OAuthLogin";
const char kOAuthWrapBridgeUserInfoScope[] =
"https://www.googleapis.com/auth/userinfo.email";

// Service/scope names for device management (cloud-based policy) server.
const char kDeviceManagementServiceOAuth[] =
"https://www.googleapis.com/auth/chromeosdevicemanagement";
Expand Down
2 changes: 2 additions & 0 deletions google_apis/gaia/gaia_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ extern const char kGaiaService[]; // uber token
extern const char kPicasaService[];
extern const char kSyncService[];
extern const char kRemotingService[];
extern const char kOAuth1LoginScope[];
extern const char kOAuthWrapBridgeUserInfoScope[];
extern const char kDeviceManagementServiceOAuth[];
extern const char kAnyApiOAuth2Scope[];
extern const char kChromeSyncOAuth2Scope[];
Expand Down
3 changes: 0 additions & 3 deletions google_apis/gaia/gaia_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ const char kClientLoginToOAuth2Url[] = "client-login-to-oauth2-url";
const char kGaiaUrl[] = "gaia-url";
const char kGoogleApisUrl[] = "google-apis-url";
const char kLsoUrl[] = "lso-url";
const char kOAuth1LoginScope[] = "oauth1-login-scope";
const char kOAuthWrapBridgeUserInfoScope[] =
"oauth-wrap-bridge-user-info-scope";
const char kOAuth2ClientID[] = "oauth2-client-id";
const char kOAuth2ClientSecret[] = "oauth2-client-secret";

Expand Down
6 changes: 0 additions & 6 deletions google_apis/gaia/gaia_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ extern const char kGoogleApisUrl[];
// "https://accounts.google.com".
extern const char kLsoUrl[];

// Specifies custom OAuth1 login scope for testing purposes.
extern const char kOAuth1LoginScope[];

// Overrides OAuth wrap bridge user info scope.
extern const char kOAuthWrapBridgeUserInfoScope[];

// Specifies custom OAuth2 client id for testing purposes.
extern const char kOAuth2ClientID[];

Expand Down
21 changes: 0 additions & 21 deletions google_apis/gaia/gaia_urls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ const char kListAccountsSuffix[] = "ListAccounts?json=standard";
const char kEmbeddedSigninSuffix[] = "EmbeddedSignIn";
const char kAddAccountSuffix[] = "AddSession";

// OAuth scopes
const char kOAuth1LoginScope[] = "https://www.google.com/accounts/OAuthLogin";
const char kOAuthWrapBridgeUserInfoScope[] =
"https://www.googleapis.com/auth/userinfo.email";

// API calls from accounts.google.com (LSO)
const char kGetOAuthTokenUrlSuffix[] = "o/oauth/GetOAuthToken/";
const char kClientLoginToOAuth2UrlSuffix[] = "o/oauth2/programmatic_auth";
Expand Down Expand Up @@ -127,14 +122,6 @@ GaiaUrls::GaiaUrls() {
google_apis_origin_url_.Resolve(kOAuthUserInfoUrlSuffix);

gaia_login_form_realm_ = gaia_url_;

// OAuth scopes.
GetSwitchValueWithDefault(switches::kOAuthWrapBridgeUserInfoScope,
kOAuthWrapBridgeUserInfoScope,
&oauth_wrap_bridge_user_info_scope_);
GetSwitchValueWithDefault(switches::kOAuth1LoginScope,
kOAuth1LoginScope,
&oauth1_login_scope_);
}

GaiaUrls::~GaiaUrls() {
Expand Down Expand Up @@ -216,14 +203,6 @@ const GURL& GaiaUrls::add_account_url() const {
return add_account_url_;
}

const std::string& GaiaUrls::oauth1_login_scope() const {
return oauth1_login_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 {
return oauth2_chrome_client_id_;
}
Expand Down
6 changes: 0 additions & 6 deletions google_apis/gaia/gaia_urls.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ class GaiaUrls {
const GURL& embedded_signin_url() const;
const GURL& add_account_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 GURL& client_login_to_oauth2_url() const;
Expand Down Expand Up @@ -80,9 +77,6 @@ class GaiaUrls {
GURL embedded_signin_url_;
GURL add_account_url_;

std::string oauth1_login_scope_;
std::string oauth_wrap_bridge_user_info_scope_;

std::string oauth2_chrome_client_id_;
std::string oauth2_chrome_client_secret_;

Expand Down
3 changes: 1 addition & 2 deletions google_apis/gaia/ubertoken_fetcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "base/logging.h"
#include "google_apis/gaia/gaia_auth_fetcher.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "google_apis/gaia/oauth2_token_service.h"

Expand All @@ -31,7 +30,7 @@ UbertokenFetcher::~UbertokenFetcher() {

void UbertokenFetcher::StartFetchingToken(const std::string& account_id) {
OAuth2TokenService::ScopeSet scopes;
scopes.insert(GaiaUrls::GetInstance()->oauth1_login_scope());
scopes.insert(GaiaConstants::kOAuth1LoginScope);
access_token_request_ =
token_service_->StartRequest(account_id, scopes, this);
}
Expand Down

0 comments on commit 95ea945

Please sign in to comment.