I have a flyway script which creates a User in postgres with an encrypted password. I want flyway to create the user account, and then use the account with a springboot java application. I want to use an encrypted password because the script will be stored in a git repository, and I dont want to store it as plain-text. The process therefore involves encrypting the desired password so it can be added to the flyway sql script, and then adding the password as a secret which can be read as a property by the java application:
CREATE USER special_user ENCRYPTED PASSWORD 'ab2843414119e861a2202b6e77bb4c48b4d32172a23a0268e31b972985754e3e';
I believe the postgres instance is using the default (sha256sum) for encryption:
show password_encryption;
> scram-sha-256
The password used in the sql was encrypted as follows:
➜ workspace echo Password! > input.txt
➜ workspace sha256sum input.txt
ab2843414119e861a2202b6e77bb4c48b4d32172a23a0268e31b972985754e3e input.txt
However when I try to use the username+password combination to authenticate I get errors. This appears to be due to the password being incorrect. If I set the password without specifying encryption (as plain text) the username-password works ok.
What am I doing wrong? I have seen other posts where the encrypted password is prefixed with SCRAM-SHA-256$4096:
but I have tried this and it did not work either (I cant find any mention of the format in the documentation)
thanks