Closed esmeetu closed 7 years ago
I'm not sure why you have 'basic_auth.hmac', it should just be 'hmac' unless you installed pgcypto into the same schema, I presume you did something like that since the function is being called.
@esmeetu try this:
select basic_auth.hmac('foo', 'secret', 'sha384');
You should get:
\x0edb7068ecbf4de2c47b8819fd534333379f208f989c51018d03ee1155e4c0740a418ec220d4260eabcb2d090b16de6e
If not, then it sounds like your pgcypto is not correctly installed.
Thanks for your reply!
Well, I install pgcypto
in the same schema basic_auth.
Under your code, i still get the error: [22023] ERROR: Cannot use "sha384": No such hash algorithm
I reinstall pgcrypto and pgjwt, there is error as before. But the extension works fine a few days before, I don't know what's wrong.
Are you reinstall pgcrypto by a os package like apt or rpm or did you build it from source? If you built it you might be missing some libraries.
After you reinstalled did you restart postgres? 'hmac' comes from pycrypto, so I'm not really an expert in building it, I installed it from an ubuntu package.
I use datagrip, enter this CREATE EXTENSION pgjwt CASCADE
in my console. It has pgcrypto default, and i drop it, recreate it. As you say, i should try down the source code, and rebuild it.
@michelp I find the reason, It my fault thati forget that i updated my postgresql today. After reboot the system, It works fine! But i am not clear why it fails, may be pgcrypto has some changes. Thanks you again. Good extention. :)
when i run:
select basic_auth.sign('{"sub":"1234567890","name":"John Doe","admin":true}', 'secret', 'HS384')
output this:
other hash algorithms are same.
This is my
algorithm_sign
function: