Revert of Upgrade 3rd packages (patchset #4 id:60001 of https://codereview.chromium.org/1085893002/)
Reason for revert: This might have broken some internal tryserver bots. Original issue's description: > Upgrade 3rd packages > > BUG=461614 > R=nodir@chromium.org > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=294835 TBR=nodir@chromium.org,sheyang@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=461614 Review URL: https://codereview.chromium.org/1094533003 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@294841 0039d316-1c4b-4281-b951-d872f2087c98changes/01/332501/1
parent
7e3b6fdd79
commit
82c0fb126a
@ -1,125 +0,0 @@
|
||||
diff --git a/third_party/google_api_python_client/apiclient/__init__.py b/third_party/google_api_python_client/apiclient/__init__.py
|
||||
index 5efb142..acb1a23 100644
|
||||
--- a/third_party/google_api_python_client/apiclient/__init__.py
|
||||
+++ b/third_party/google_api_python_client/apiclient/__init__.py
|
||||
@@ -3,7 +3,7 @@
|
||||
import googleapiclient
|
||||
|
||||
try:
|
||||
- import oauth2client
|
||||
+ from third_party import oauth2client
|
||||
except ImportError:
|
||||
raise RuntimeError(
|
||||
'Previous version of google-api-python-client detected; due to a '
|
||||
diff --git a/third_party/google_api_python_client/googleapiclient/channel.py b/third_party/google_api_python_client/googleapiclient/channel.py
|
||||
index 68a3b89..4626094 100644
|
||||
--- a/third_party/google_api_python_client/googleapiclient/channel.py
|
||||
+++ b/third_party/google_api_python_client/googleapiclient/channel.py
|
||||
@@ -60,7 +60,7 @@ import datetime
|
||||
import uuid
|
||||
|
||||
from googleapiclient import errors
|
||||
-from ...oauth2client import util
|
||||
+from third_party.oauth2client import util
|
||||
|
||||
|
||||
# The unix time epoch starts at midnight 1970.
|
||||
diff --git a/third_party/google_api_python_client/googleapiclient/discovery.py b/third_party/google_api_python_client/googleapiclient/discovery.py
|
||||
index 3ddac57..0e9e5cf 100644
|
||||
--- a/third_party/google_api_python_client/googleapiclient/discovery.py
|
||||
+++ b/third_party/google_api_python_client/googleapiclient/discovery.py
|
||||
@@ -47,9 +47,9 @@ except ImportError:
|
||||
from cgi import parse_qsl
|
||||
|
||||
# Third-party imports
|
||||
-from ... import httplib2
|
||||
+from third_party import httplib2
|
||||
+from third_party.uritemplate import uritemplate
|
||||
import mimeparse
|
||||
-from ... import uritemplate
|
||||
|
||||
# Local imports
|
||||
from googleapiclient.errors import HttpError
|
||||
@@ -65,9 +65,9 @@ from googleapiclient.model import JsonModel
|
||||
from googleapiclient.model import MediaModel
|
||||
from googleapiclient.model import RawModel
|
||||
from googleapiclient.schema import Schemas
|
||||
-from oauth2client.client import GoogleCredentials
|
||||
-from oauth2client.util import _add_query_parameter
|
||||
-from oauth2client.util import positional
|
||||
+from third_party.oauth2client.client import GoogleCredentials
|
||||
+from third_party.oauth2client.util import _add_query_parameter
|
||||
+from third_party.oauth2client.util import positional
|
||||
|
||||
|
||||
# The client library requires a version of httplib2 that supports RETRIES.
|
||||
diff --git a/third_party/google_api_python_client/googleapiclient/errors.py b/third_party/google_api_python_client/googleapiclient/errors.py
|
||||
index a1999fd..18c52e6 100644
|
||||
--- a/third_party/google_api_python_client/googleapiclient/errors.py
|
||||
+++ b/third_party/google_api_python_client/googleapiclient/errors.py
|
||||
@@ -24,7 +24,7 @@ __author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
||||
|
||||
import json
|
||||
|
||||
-from ...oauth2client import util
|
||||
+from third_party.oauth2client import util
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
diff --git a/third_party/google_api_python_client/googleapiclient/http.py b/third_party/google_api_python_client/googleapiclient/http.py
|
||||
index 8638279..d2ce70c 100644
|
||||
--- a/third_party/google_api_python_client/googleapiclient/http.py
|
||||
+++ b/third_party/google_api_python_client/googleapiclient/http.py
|
||||
@@ -25,7 +25,6 @@ import StringIO
|
||||
import base64
|
||||
import copy
|
||||
import gzip
|
||||
-import httplib2
|
||||
import json
|
||||
import logging
|
||||
import mimeparse
|
||||
@@ -49,7 +48,8 @@ from errors import ResumableUploadError
|
||||
from errors import UnexpectedBodyError
|
||||
from errors import UnexpectedMethodError
|
||||
from model import JsonModel
|
||||
-from ...oauth2client import util
|
||||
+from third_party import httplib2
|
||||
+from third_party.oauth2client import util
|
||||
|
||||
|
||||
DEFAULT_CHUNK_SIZE = 512*1024
|
||||
diff --git a/third_party/google_api_python_client/googleapiclient/sample_tools.py b/third_party/google_api_python_client/googleapiclient/sample_tools.py
|
||||
index cbd6d6f..cc0790b 100644
|
||||
--- a/third_party/google_api_python_client/googleapiclient/sample_tools.py
|
||||
+++ b/third_party/google_api_python_client/googleapiclient/sample_tools.py
|
||||
@@ -22,13 +22,13 @@ __all__ = ['init']
|
||||
|
||||
|
||||
import argparse
|
||||
-import httplib2
|
||||
import os
|
||||
|
||||
from googleapiclient import discovery
|
||||
-from ...oauth2client import client
|
||||
-from ...oauth2client import file
|
||||
-from ...oauth2client import tools
|
||||
+from third_party import httplib2
|
||||
+from third_party.oauth2client import client
|
||||
+from third_party.oauth2client import file
|
||||
+from third_party.oauth2client import tools
|
||||
|
||||
|
||||
def init(argv, name, version, doc, filename, scope=None, parents=[], discovery_filename=None):
|
||||
diff --git a/third_party/google_api_python_client/googleapiclient/schema.py b/third_party/google_api_python_client/googleapiclient/schema.py
|
||||
index af41317..92543ec 100644
|
||||
--- a/third_party/google_api_python_client/googleapiclient/schema.py
|
||||
+++ b/third_party/google_api_python_client/googleapiclient/schema.py
|
||||
@@ -63,7 +63,7 @@ __author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
||||
|
||||
import copy
|
||||
|
||||
-from oauth2client import util
|
||||
+from third_party.oauth2client import util
|
||||
|
||||
|
||||
class Schemas(object):
|
@ -1,8 +1,5 @@
|
||||
"""Client library for using OAuth2, especially with Google APIs."""
|
||||
|
||||
__version__ = '1.4.7'
|
||||
__version__ = "1.2"
|
||||
|
||||
GOOGLE_AUTH_URI = 'https://accounts.google.com/o/oauth2/auth'
|
||||
GOOGLE_DEVICE_URI = 'https://accounts.google.com/o/oauth2/device/code'
|
||||
GOOGLE_REVOKE_URI = 'https://accounts.google.com/o/oauth2/revoke'
|
||||
GOOGLE_TOKEN_URI = 'https://accounts.google.com/o/oauth2/token'
|
@ -0,0 +1,32 @@
|
||||
# Copyright (C) 2010 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Utility module to import a JSON module
|
||||
|
||||
Hides all the messy details of exactly where
|
||||
we get a simplejson module from.
|
||||
"""
|
||||
|
||||
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
||||
|
||||
|
||||
try: # pragma: no cover
|
||||
# Should work for Python2.6 and higher.
|
||||
import json as simplejson
|
||||
except ImportError: # pragma: no cover
|
||||
try:
|
||||
import simplejson
|
||||
except ImportError:
|
||||
# Try to import from django, should work on App Engine
|
||||
from django.utils import simplejson
|
File diff suppressed because it is too large
Load Diff
@ -1,135 +0,0 @@
|
||||
# Copyright 2015 Google Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""OAuth 2.0 utitilies for Google Developer Shell environment."""
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from . import client
|
||||
|
||||
|
||||
DEVSHELL_ENV = 'DEVSHELL_CLIENT_PORT'
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
"""Errors for this module."""
|
||||
pass
|
||||
|
||||
|
||||
class CommunicationError(Error):
|
||||
"""Errors for communication with the Developer Shell server."""
|
||||
|
||||
|
||||
class NoDevshellServer(Error):
|
||||
"""Error when no Developer Shell server can be contacted."""
|
||||
|
||||
|
||||
# The request for credential information to the Developer Shell client socket is
|
||||
# always an empty PBLite-formatted JSON object, so just define it as a constant.
|
||||
CREDENTIAL_INFO_REQUEST_JSON = '[]'
|
||||
|
||||
|
||||
class CredentialInfoResponse(object):
|
||||
"""Credential information response from Developer Shell server.
|
||||
|
||||
The credential information response from Developer Shell socket is a
|
||||
PBLite-formatted JSON array with fields encoded by their index in the array:
|
||||
* Index 0 - user email
|
||||
* Index 1 - default project ID. None if the project context is not known.
|
||||
* Index 2 - OAuth2 access token. None if there is no valid auth context.
|
||||
"""
|
||||
|
||||
def __init__(self, json_string):
|
||||
"""Initialize the response data from JSON PBLite array."""
|
||||
pbl = json.loads(json_string)
|
||||
if not isinstance(pbl, list):
|
||||
raise ValueError('Not a list: ' + str(pbl))
|
||||
pbl_len = len(pbl)
|
||||
self.user_email = pbl[0] if pbl_len > 0 else None
|
||||
self.project_id = pbl[1] if pbl_len > 1 else None
|
||||
self.access_token = pbl[2] if pbl_len > 2 else None
|
||||
|
||||
|
||||
def _SendRecv():
|
||||
"""Communicate with the Developer Shell server socket."""
|
||||
|
||||
port = int(os.getenv(DEVSHELL_ENV, 0))
|
||||
if port == 0:
|
||||
raise NoDevshellServer()
|
||||
|
||||
import socket
|
||||
|
||||
sock = socket.socket()
|
||||
sock.connect(('localhost', port))
|
||||
|
||||
data = CREDENTIAL_INFO_REQUEST_JSON
|
||||
msg = '%s\n%s' % (len(data), data)
|
||||
sock.sendall(msg.encode())
|
||||
|
||||
header = sock.recv(6).decode()
|
||||
if '\n' not in header:
|
||||
raise CommunicationError('saw no newline in the first 6 bytes')
|
||||
len_str, json_str = header.split('\n', 1)
|
||||
to_read = int(len_str) - len(json_str)
|
||||
if to_read > 0:
|
||||
json_str += sock.recv(to_read, socket.MSG_WAITALL).decode()
|
||||
|
||||
return CredentialInfoResponse(json_str)
|
||||
|
||||
|
||||
class DevshellCredentials(client.GoogleCredentials):
|
||||
"""Credentials object for Google Developer Shell environment.
|
||||
|
||||
This object will allow a Google Developer Shell session to identify its user
|
||||
to Google and other OAuth 2.0 servers that can verify assertions. It can be
|
||||
used for the purpose of accessing data stored under the user account.
|
||||
|
||||
This credential does not require a flow to instantiate because it represents
|
||||
a two legged flow, and therefore has all of the required information to
|
||||
generate and refresh its own access tokens.
|
||||
"""
|
||||
|
||||
def __init__(self, user_agent=None):
|
||||
super(DevshellCredentials, self).__init__(
|
||||
None, # access_token, initialized below
|
||||
None, # client_id
|
||||
None, # client_secret
|
||||
None, # refresh_token
|
||||
None, # token_expiry
|
||||
None, # token_uri
|
||||
user_agent)
|
||||
self._refresh(None)
|
||||
|
||||
def _refresh(self, http_request):
|
||||
self.devshell_response = _SendRecv()
|
||||
self.access_token = self.devshell_response.access_token
|
||||
|
||||
@property
|
||||
def user_email(self):
|
||||
return self.devshell_response.user_email
|
||||
|
||||
@property
|
||||
def project_id(self):
|
||||
return self.devshell_response.project_id
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_data):
|
||||
raise NotImplementedError(
|
||||
'Cannot load Developer Shell credentials from JSON.')
|
||||
|
||||
@property
|
||||
def serialization_data(self):
|
||||
raise NotImplementedError(
|
||||
'Cannot serialize Developer Shell credentials.')
|
@ -1,139 +0,0 @@
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""A service account credentials class.
|
||||
|
||||
This credentials class is implemented on top of rsa library.
|
||||
"""
|
||||
|
||||
import base64
|
||||
import json
|
||||
import time
|
||||
|
||||
from pyasn1.codec.ber import decoder
|
||||
from pyasn1_modules.rfc5208 import PrivateKeyInfo
|
||||
import rsa
|
||||
|
||||
from . import GOOGLE_REVOKE_URI
|
||||
from . import GOOGLE_TOKEN_URI
|
||||
from . import util
|
||||
from client import AssertionCredentials
|
||||
from third_party import six
|
||||
|
||||
|
||||
class _ServiceAccountCredentials(AssertionCredentials):
|
||||
"""Class representing a service account (signed JWT) credential."""
|
||||
|
||||
MAX_TOKEN_LIFETIME_SECS = 3600 # 1 hour in seconds
|
||||
|
||||
def __init__(self, service_account_id, service_account_email, private_key_id,
|
||||
private_key_pkcs8_text, scopes, user_agent=None,
|
||||
token_uri=GOOGLE_TOKEN_URI, revoke_uri=GOOGLE_REVOKE_URI,
|
||||
**kwargs):
|
||||
|
||||
super(_ServiceAccountCredentials, self).__init__(
|
||||
None, user_agent=user_agent, token_uri=token_uri, revoke_uri=revoke_uri)
|
||||
|
||||
self._service_account_id = service_account_id
|
||||
self._service_account_email = service_account_email
|
||||
self._private_key_id = private_key_id
|
||||
self._private_key = _get_private_key(private_key_pkcs8_text)
|
||||
self._private_key_pkcs8_text = private_key_pkcs8_text
|
||||
self._scopes = util.scopes_to_string(scopes)
|
||||
self._user_agent = user_agent
|
||||
self._token_uri = token_uri
|
||||
self._revoke_uri = revoke_uri
|
||||
self._kwargs = kwargs
|
||||
|
||||
def _generate_assertion(self):
|
||||
"""Generate the assertion that will be used in the request."""
|
||||
|
||||
header = {
|
||||
'alg': 'RS256',
|
||||
'typ': 'JWT',
|
||||
'kid': self._private_key_id
|
||||
}
|
||||
|
||||
now = int(time.time())
|
||||
payload = {
|
||||
'aud': self._token_uri,
|
||||
'scope': self._scopes,
|
||||
'iat': now,
|
||||
'exp': now + _ServiceAccountCredentials.MAX_TOKEN_LIFETIME_SECS,
|
||||
'iss': self._service_account_email
|
||||
}
|
||||
payload.update(self._kwargs)
|
||||
|
||||
assertion_input = (_urlsafe_b64encode(header) + b'.' +
|
||||
_urlsafe_b64encode(payload))
|
||||
|
||||
# Sign the assertion.
|
||||
rsa_bytes = rsa.pkcs1.sign(assertion_input, self._private_key, 'SHA-256')
|
||||
signature = base64.urlsafe_b64encode(rsa_bytes).rstrip(b'=')
|
||||
|
||||
return assertion_input + b'.' + signature
|
||||
|
||||
def sign_blob(self, blob):
|
||||
# Ensure that it is bytes
|
||||
try:
|
||||
blob = blob.encode('utf-8')
|
||||
except AttributeError:
|
||||
pass
|
||||
return (self._private_key_id,
|
||||
rsa.pkcs1.sign(blob, self._private_key, 'SHA-256'))
|
||||
|
||||
@property
|
||||
def service_account_email(self):
|
||||
return self._service_account_email
|
||||
|
||||
@property
|
||||
def serialization_data(self):
|
||||
return {
|
||||
'type': 'service_account',
|
||||
'client_id': self._service_account_id,
|
||||
'client_email': self._service_account_email,
|
||||
'private_key_id': self._private_key_id,
|
||||
'private_key': self._private_key_pkcs8_text
|
||||
}
|
||||
|
||||
def create_scoped_required(self):
|
||||
return not self._scopes
|
||||
|
||||
def create_scoped(self, scopes):
|
||||
return _ServiceAccountCredentials(self._service_account_id,
|
||||
self._service_account_email,
|
||||
self._private_key_id,
|
||||
self._private_key_pkcs8_text,
|
||||
scopes,
|
||||
user_agent=self._user_agent,
|
||||
token_uri=self._token_uri,
|
||||
revoke_uri=self._revoke_uri,
|
||||
**self._kwargs)
|
||||
|
||||
|
||||
def _urlsafe_b64encode(data):
|
||||
return base64.urlsafe_b64encode(
|
||||
json.dumps(data, separators=(',', ':')).encode('UTF-8')).rstrip(b'=')
|
||||
|
||||
|
||||
def _get_private_key(private_key_pkcs8_text):
|
||||
"""Get an RSA private key object from a pkcs8 representation."""
|
||||
|
||||
if not isinstance(private_key_pkcs8_text, six.binary_type):
|
||||
private_key_pkcs8_text = private_key_pkcs8_text.encode('ascii')
|
||||
der = rsa.pem.load_pem(private_key_pkcs8_text, 'PRIVATE KEY')
|
||||
asn1_private_key, _ = decoder.decode(der, asn1Spec=PrivateKeyInfo())
|
||||
return rsa.PrivateKey.load_pkcs1(
|
||||
asn1_private_key.getComponentByName('privateKey').asOctets(),
|
||||
format='DER')
|
Loading…
Reference in New Issue