-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support a password function for the client configuration #2396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This feature has been available for a while. Here's proper TypeScript declaration from type DynamicPassword = string | (() => string) | (() => Promise<string>); and the connection object: const cn = {
//...
password?: DynamicPassword
//...
}; Copied from here. |
Then the types are still wrong...
|
Oh yeah, you betcha! They have always been wrong, that's why I had to write my own declaration for this library, one that I could update properly, in a timely manner (it is only a sub-set that I need). |
Hey,
I'm using |
@mikicho HBA (Host Base Access control) rules get applied by the server before requesting client authentication. So if your connection is rejected for HBA reasons then it will not invoke your client side password function. Check the pg_hba.conf file of your server and ensure that it has an entry allowing you to connect from the machine where you client is running. |
@sehrope Thanks. I succeed to connect to the DB with the token via |
Make sure to enable SSL in your pg client config. RDS does not let you connect with auth tokens over plaintext connections. That's the " It works from psql because psql defaults to trying with SSL first. |
@sehrope Thanks.
Does |
psql defaults to enabling SSL but not checking the server's certificate: https://www.postgresql.org/docs/current/libpq-ssl.html ("prefer" mode) This driver was changed a few versions back to be more secure by default so the default is to reject untrusted certificates. To mimic the "prefer" behavior, set the |
I guess you mean |
If you use e.g. AWS Aurora Postgres with IAM authentication it is hard to deal with it in the code.
It would be nice that I can use a function to return the password, like this:
The text was updated successfully, but these errors were encountered: