Commit c80a3f81 authored by David Douard's avatar David Douard
Browse files

[server/utils] update passlib API to 1.7 (closes #17054805)

while keeping bw-compat with 1.6 - 2.7 is not available for all distributions,
e.g. jessie.

The dependancy has been bumped in 6186cd15a46d because of a change in
bc9d901cb9e6. We may easily use the appropriate method depending on the version
installed.

--HG--
branch : 3.25
parent 7ce838e67a61
......@@ -27,7 +27,7 @@ Requires: %{python}-logilab-mtconverter >= 0.8.0
Requires: %{python}-rql >= 0.34.0
Requires: %{python}-yams >= 0.45.0
Requires: %{python}-logilab-database >= 1.15.0
Requires: %{python}-passlib => 1.7.0
Requires: %{python}-passlib
Requires: %{python}-lxml
Requires: %{python}-twisted-web < 16.0.0
Requires: %{python}-markdown
......
......@@ -54,14 +54,15 @@ class CustomMD5Crypt(uh.HasSalt, uh.GenericHandler):
def to_string(self):
return to_hash_str(u'%s$%s' % (self.salt, self.checksum or u''))
# passlib 1.5 wants calc_checksum, 1.6 wants _calc_checksum
def calc_checksum(self, secret):
def _calc_checksum(self, secret):
return md5crypt(secret, self.salt.encode('ascii')).decode('utf-8')
_calc_checksum = calc_checksum
_CRYPTO_CTX = CryptContext(['sha512_crypt', CustomMD5Crypt, 'des_crypt', 'ldap_salted_sha1'],
deprecated=['cubicwebmd5crypt', 'des_crypt'])
# for bw compat with passlib < 1.7
if not hasattr(_CRYPTO_CTX, 'hash'):
_CRYPTO_CTX.hash = _CRYPTO_CTX.encrypt
verify_and_update = _CRYPTO_CTX.verify_and_update
......
......@@ -25,7 +25,7 @@ Build-Depends:
python-pyramid,
python-pyramid-multiauth,
python-waitress,
python-passlib (>= 1.7.0),
python-passlib,
python-repoze.lru,
python-wsgicors,
sphinx-common,
......
......@@ -199,7 +199,7 @@ setup(
'yams >= 0.45.0',
'lxml',
'logilab-database >= 1.15.0',
'passlib >= 1.7.0',
'passlib',
'pytz',
'Markdown',
'unittest2 >= 0.7.0',
......
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