From 741afe8c930f988eb8d2b715540cfc598b12c38a Mon Sep 17 00:00:00 2001 From: Andrii Shyshkalov Date: Thu, 19 Apr 2018 14:32:18 -0700 Subject: [PATCH] [auth] cleanup old code.google.com oauth scope usage. R=vadimsh@chromium.org Change-Id: Iab38f0cf29594e20883e62e1ed113bc36a884ea4 Reviewed-on: https://chromium-review.googlesource.com/1020298 Commit-Queue: Andrii Shyshkalov Reviewed-by: Vadim Shtayura --- auth.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/auth.py b/auth.py index a2ee60e45..5547316b6 100644 --- a/auth.py +++ b/auth.py @@ -52,11 +52,6 @@ OAUTH_SCOPE_GERRIT = 'https://www.googleapis.com/auth/gerritcodereview' # Deprecated. Use OAUTH_SCOPE_EMAIL instead. OAUTH_SCOPES = OAUTH_SCOPE_EMAIL -# Additional OAuth scopes. -ADDITIONAL_SCOPES = { - 'code.google.com': 'https://www.googleapis.com/auth/projecthosting', -} - # Path to a file with cached OAuth2 credentials used by default relative to the # home dir (see _get_token_cache_path). It should be a safe location accessible # only to a current user: knowing content of this file is roughly equivalent to @@ -389,13 +384,14 @@ def auth_config_to_command_options(auth_config): return opts -def get_authenticator_for_host(hostname, config): +def get_authenticator_for_host(hostname, config, scopes=OAUTH_SCOPE_EMAIL): """Returns Authenticator instance to access given host. Args: hostname: a naked hostname or http(s)://[/] URL. Used to derive a cache key for token cache. config: AuthConfig instance. + scopes: space separated oauth scopes. Defaults to OAUTH_SCOPE_EMAIL. Returns: Authenticator object. @@ -407,11 +403,7 @@ def get_authenticator_for_host(hostname, config): # Append some scheme, otherwise urlparse puts hostname into parsed.path. if '://' not in hostname: hostname = 'https://' + hostname - # TODO(tandrii): this is horrible. - scopes = OAUTH_SCOPES parsed = urlparse.urlparse(hostname) - if parsed.netloc in ADDITIONAL_SCOPES: - scopes = "%s %s" % (scopes, ADDITIONAL_SCOPES[parsed.netloc]) if parsed.path or parsed.params or parsed.query or parsed.fragment: raise AuthenticationError(