From 1df211ad78790685839a711559ded1af8f492ce9 Mon Sep 17 00:00:00 2001 From: Lance Bragstad Date: Wed, 23 Nov 2016 15:25:06 +0000 Subject: [PATCH] ignore deprecation warning for .encrypt() A new release of passlib 1.7.0 has deprecated the encrypt() method in favor of using hash() instead. This commit updates our usage to use the recommended way by passlib. Change-Id: I69262f2793bfa0c284868a3e6d4aba71ad622ca0 Partial-Bug: 1644263 --- keystone/common/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/keystone/common/utils.py b/keystone/common/utils.py index c624747c10..0c2c9c6063 100644 --- a/keystone/common/utils.py +++ b/keystone/common/utils.py @@ -132,8 +132,13 @@ def hash_user_password(user): def hash_password(password): """Hash a password. Hard.""" password_utf8 = verify_length_and_trunc_password(password).encode('utf-8') - return passlib.hash.sha512_crypt.encrypt( - password_utf8, rounds=CONF.crypt_strength) + try: + return passlib.hash.sha512_crypt.encrypt( + password_utf8, rounds=CONF.crypt_strength) + except DeprecationWarning: + # TODO(stevemar): Remove this warning once we switch over to passlib + # version 1.7.0 and replace encrypt() with hash() + pass def check_password(password, hashed):