When encrypting a sensitive information for a field, we may encrypt the field with pgcrypto
using something like this:
INSERT INTO employees (email, password) VALUES (
'[email protected]',
crypt('mypassword', gen_salt('bf'))
);
but, querying the column we gotta supply the password in plain text like this:
SELECT id
FROM employees
WHERE email = '[email protected]' AND password = crypt('mypassword', password).
I'm using azure postgres, and I'm seeing no way to store this password somewhere securely that postgres provides. One thing that worries me is if full logging of queries is enabled, then the password appears as plain text in the logs, and I'm having to supply the master password everytime I want to see/query the encrypted data. I don't know if postgres has a facility to somewhere securely save the password and just fetch it on run time, like vault is for environment variables?