update googleapiclient, httplib2, oauth2client and passlib to latest versions

This commit is contained in:
Jay Lee
2015-09-30 09:07:28 -04:00
parent 6ba62b66b4
commit 8b19040e45
85 changed files with 6642 additions and 4911 deletions

View File

@@ -188,7 +188,7 @@ class _CommonFile(object):
@property
def mtime(self):
"modify time when last loaded (if bound to a local file)"
"""modify time when last loaded (if bound to a local file)"""
return self._mtime
#===================================================================
@@ -240,13 +240,13 @@ class _CommonFile(object):
return True
def load_string(self, data):
"Load state from unicode or bytes string, replacing current state"
"""Load state from unicode or bytes string, replacing current state"""
data = to_bytes(data, self.encoding, "data")
self._mtime = 0
self._load_lines(BytesIO(data))
def _load_lines(self, lines):
"load from sequence of lists"
"""load from sequence of lists"""
# XXX: found reference that "#" comment lines may be supported by
# htpasswd, should verify this, and figure out how to handle them.
# if true, this would also affect what can be stored in user field.
@@ -262,15 +262,15 @@ class _CommonFile(object):
if key not in records:
records[key] = value
def _parse_record(cls, record, lineno): # pragma: no cover - abstract method
"parse line of file into (key, value) pair"
def _parse_record(self, record, lineno): # pragma: no cover - abstract method
"""parse line of file into (key, value) pair"""
raise NotImplementedError("should be implemented in subclass")
#===================================================================
# saving
#===================================================================
def _autosave(self):
"subclass helper to call save() after any changes"
"""subclass helper to call save() after any changes"""
if self.autosave and self._path:
self.save()
@@ -289,26 +289,26 @@ class _CommonFile(object):
self.__class__.__name__)
def to_string(self):
"Export current state as a string of bytes"
"""Export current state as a string of bytes"""
return join_bytes(self._iter_lines())
def _iter_lines(self):
"iterator yielding lines of database"
"""iterator yielding lines of database"""
return (self._render_record(key,value) for key,value in iteritems(self._records))
def _render_record(cls, key, value): # pragma: no cover - abstract method
"given key/value pair, encode as line of file"
def _render_record(self, key, value): # pragma: no cover - abstract method
"""given key/value pair, encode as line of file"""
raise NotImplementedError("should be implemented in subclass")
#===================================================================
# field encoding
#===================================================================
def _encode_user(self, user):
"user-specific wrapper for _encode_field()"
"""user-specific wrapper for _encode_field()"""
return self._encode_field(user, "user")
def _encode_realm(self, realm): # pragma: no cover - abstract method
"realm-specific wrapper for _encode_field()"
"""realm-specific wrapper for _encode_field()"""
return self._encode_field(realm, "realm")
def _encode_field(self, value, param="field"):
@@ -370,19 +370,39 @@ class _CommonFile(object):
# htpasswd editing
#=============================================================================
# FIXME: apr_md5_crypt technically the default only for windows, netware and tpf.
# TODO: find out if htpasswd's "crypt" mode is a crypt() *call* or just des_crypt implementation.
# if the former, we can support anything supported by passlib.hosts.host_context,
# allowing more secure hashes than apr_md5_crypt to be used.
# could perhaps add this behavior as an option to the constructor.
#: default CryptContext used by HtpasswdFile
# TODO: update this to support everything in host_context (where available),
# and note in the documentation that the default is no longer guaranteed to be portable
# across platforms.
# c.f. http://httpd.apache.org/docs/2.2/programs/htpasswd.html
htpasswd_context = CryptContext([
"apr_md5_crypt", # man page notes supported everywhere, default on Windows, Netware, TPF
"des_crypt", # man page notes server does NOT support this on Windows, Netware, TPF
"ldap_sha1", # man page notes only for transitioning <-> ldap
"plaintext" # man page notes server ONLY supports this on Windows, Netware, TPF
# man page notes supported everywhere; is default on Windows, Netware, TPF
"apr_md5_crypt",
# [added in passlib 1.6.3]
# apache requires host crypt() support; but can generate natively
# (as of https://bz.apache.org/bugzilla/show_bug.cgi?id=49288)
"bcrypt",
# [added in passlib 1.6.3]
# apache requires host crypt() support; and can't generate natively
"sha256_crypt",
"sha512_crypt",
# man page notes apache does NOT support this on Windows, Netware, TPF
"des_crypt",
# man page notes intended only for transitioning htpasswd <-> ldap
"ldap_sha1",
# man page notes apache ONLY supports this on Windows, Netware, TPF
"plaintext"
])
#: scheme that will be used when 'portable' is requested.
portable_scheme = "apr_md5_crypt"
class HtpasswdFile(_CommonFile):
"""class for reading & writing Htpasswd files.
@@ -444,13 +464,23 @@ class HtpasswdFile(_CommonFile):
:type default_scheme: str
:param default_scheme:
Optionally specify default scheme to use when encoding new passwords.
Must be one of ``"apr_md5_crypt"``, ``"des_crypt"``, ``"ldap_sha1"``,
``"plaintext"``. It defaults to ``"apr_md5_crypt"``.
May be any of ``"bcrypt"``, ``"sha256_crypt"``, ``"apr_md5_crypt"``, ``"des_crypt"``,
``"ldap_sha1"``, ``"plaintext"``. It defaults to ``"apr_md5_crypt"``.
.. note::
Some hashes are only supported by apache / htpasswd on certain operating systems
(e.g. bcrypt on BSD, sha256_crypt on linux). To get the strongest
hash that's still portable, applications can specify ``default_scheme="portable"``.
.. versionadded:: 1.6
This keyword was previously named ``default``. That alias
has been deprecated, and will be removed in Passlib 1.8.
.. versionchanged:: 1.6.3
Added support for ``"bcrypt"``, ``"sha256_crypt"``, and ``"portable"``.
:type context: :class:`~passlib.context.CryptContext`
:param context:
:class:`!CryptContext` instance used to encrypt
@@ -464,7 +494,7 @@ class HtpasswdFile(_CommonFile):
This option may be used to add support for non-standard hash
formats to an htpasswd file. However, the resulting file
will probably not be usuable by another application,
will probably not be usable by another application,
and particularly not by Apache.
:param autoload:
@@ -546,6 +576,8 @@ class HtpasswdFile(_CommonFile):
DeprecationWarning, stacklevel=2)
default_scheme = kwds.pop("default")
if default_scheme:
if default_scheme == "portable":
default_scheme = portable_scheme
context = context.copy(default=default_scheme)
self.context = context
super(HtpasswdFile, self).__init__(path, **kwds)
@@ -566,7 +598,7 @@ class HtpasswdFile(_CommonFile):
#===================================================================
def users(self):
"Return list of all users in database"
"""Return list of all users in database"""
return [self._decode_field(user) for user in self._records]
##def has_user(self, user):
@@ -605,7 +637,7 @@ class HtpasswdFile(_CommonFile):
@deprecated_method(deprecated="1.6", removed="1.8",
replacement="set_password")
def update(self, user, password):
"set password for user"
"""set password for user"""
return self.set_password(user, password)
def get_hash(self, user):
@@ -624,7 +656,7 @@ class HtpasswdFile(_CommonFile):
@deprecated_method(deprecated="1.6", removed="1.8",
replacement="get_hash")
def find(self, user):
"return hash for user"
"""return hash for user"""
return self.get_hash(user)
# XXX: rename to something more explicit, like delete_user()?
@@ -673,7 +705,7 @@ class HtpasswdFile(_CommonFile):
@deprecated_method(deprecated="1.6", removed="1.8",
replacement="check_password")
def verify(self, user, password):
"verify password for user"
"""verify password for user"""
return self.check_password(user, password)
#===================================================================
@@ -931,7 +963,7 @@ class HtdigestFile(_CommonFile):
@deprecated_method(deprecated="1.6", removed="1.8",
replacement="set_password")
def update(self, user, realm, password):
"set password for user"
"""set password for user"""
return self.set_password(user, realm, password)
# XXX: rename to something more explicit, like get_hash()?
@@ -957,7 +989,7 @@ class HtdigestFile(_CommonFile):
@deprecated_method(deprecated="1.6", removed="1.8",
replacement="get_hash")
def find(self, user, realm):
"return hash for user"
"""return hash for user"""
return self.get_hash(user, realm)
# XXX: rename to something more explicit, like delete_user()?
@@ -1025,7 +1057,7 @@ class HtdigestFile(_CommonFile):
@deprecated_method(deprecated="1.6", removed="1.8",
replacement="check_password")
def verify(self, user, realm, password):
"verify password for user"
"""verify password for user"""
return self.check_password(user, realm, password)
#===================================================================