Add support for SCRAM password changes (requires psycopg2 >= 2.8). Fixes #2214

This commit is contained in:
Akshay Joshi
2018-07-23 15:03:44 +01:00
committed by Dave Page
parent 2d1e835d32
commit 213cb440d0
3 changed files with 51 additions and 1 deletions

View File

@@ -1245,7 +1245,16 @@ class ServerNode(PGChildNodeView):
return unauthorized(gettext("Incorrect password."))
# Hash new password before saving it.
password = pqencryptpassword(data['newPassword'], manager.user)
if manager.sversion >= 100000:
password = conn.pq_encrypt_password_conn(data['newPassword'],
manager.user)
if password is None:
# Unable to encrypt the password so used the
# old method of encryption
password = pqencryptpassword(data['newPassword'],
manager.user)
else:
password = pqencryptpassword(data['newPassword'], manager.user)
SQL = render_template(
"/servers/sql/#{0}#/change_password.sql".format(