[server/utils] update passlib API to 1.7 (closes #17054805) 3.25
authorDavid Douard <david.douard@logilab.fr>
Wed, 10 May 2017 15:07:18 +0200
branch3.25
changeset 12193 e4ee04d442be
parent 12191 7ce838e67a61
child 12194 2f9da7a8ecb6
[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.
cubicweb.spec
cubicweb/server/utils.py
debian/control
setup.py
--- a/cubicweb.spec	Mon Jul 10 11:41:20 2017 +0200
+++ b/cubicweb.spec	Wed May 10 15:07:18 2017 +0200
@@ -27,7 +27,7 @@
 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
--- a/cubicweb/server/utils.py	Mon Jul 10 11:41:20 2017 +0200
+++ b/cubicweb/server/utils.py	Wed May 10 15:07:18 2017 +0200
@@ -54,14 +54,15 @@
     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
 
 
--- a/debian/control	Mon Jul 10 11:41:20 2017 +0200
+++ b/debian/control	Wed May 10 15:07:18 2017 +0200
@@ -25,7 +25,7 @@
  python-pyramid,
  python-pyramid-multiauth,
  python-waitress,
- python-passlib (>= 1.7.0),
+ python-passlib,
  python-repoze.lru,
  python-wsgicors,
  sphinx-common,
--- a/setup.py	Mon Jul 10 11:41:20 2017 +0200
+++ b/setup.py	Wed May 10 15:07:18 2017 +0200
@@ -199,7 +199,7 @@
         'yams >= 0.45.0',
         'lxml',
         'logilab-database >= 1.15.0',
-        'passlib >= 1.7.0',
+        'passlib',
         'pytz',
         'Markdown',
         'unittest2 >= 0.7.0',