Make sure gpg actually does something (#182)

This commit is contained in:
Alexandre Aubin 2018-12-18 16:17:17 +01:00 committed by GitHub
parent 76a3256ded
commit 1e90dd4bb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -137,9 +137,13 @@ class BaseAuthenticator(object):
"""Store a session and its associated password""" """Store a session and its associated password"""
gpg = gnupg.GPG() gpg = gnupg.GPG()
gpg.encoding = 'utf-8' gpg.encoding = 'utf-8'
# Encrypt the password using the session hash
s = str(gpg.encrypt(password, None, symmetric=True, passphrase=session_hash))
assert len(s), "For some reason GPG can't perform encryption, maybe check /root/.gnupg/gpg.conf or re-run with gpg = gnupg.GPG(verbose=True) ?"
with self._open_sessionfile(session_id, 'w') as f: with self._open_sessionfile(session_id, 'w') as f:
f.write(str(gpg.encrypt(password, None, symmetric=True, f.write(s)
passphrase=session_hash)))
def _retrieve_session(self, session_id, session_hash): def _retrieve_session(self, session_id, session_hash):
"""Retrieve a session and return its associated password""" """Retrieve a session and return its associated password"""