Support retrieving db password via callback
See original GitHub issueRDS postgres supports connecting via an “IAM Authentication Token”, which lasts 15 minutes, and is used as the password when connecting to the database. I can’t see any way to connect like this with pg, since the password is a static value passed at pool creation time. Ideally, the pool would be able to retrieve a new password whenever it needs to create a new connection.
I think the ideal API for this would be something like this - note the getPassword function needs to be asynchronous:
const { Pool } = require('pg')
const pool = new Pool({
user: 'dbuser',
host: 'database.server.com',
database: 'mydb',
getPassword: function () {
// return a promise which resolves with the generated password
},
port: 3211,
})
I am most likely available to work on this issue, but keen to get maintainer approval first before I write any code.
More details here: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.Connecting.AWSCLI.PostgreSQL.html
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Custom Database Action Script Execution Best Practices - Auth0
Learn about best practices for custom database action script execution.
Read more >Password Reset with ASP.NET Core Identity - Code Maze
In this article, we are going to learn about the Password Reset functionality with ASP.NET Core Identity with detailed examples.
Read more >Retrieving Data | Firebase Realtime Database - Google
This document covers the basics of retrieving database data, how data is ordered, and how to perform simple queries on data. Data retrieval...
Read more >11 Creating and Managing Oracle Wallet
This chapter describes how to create and manage an Oracle Wallet to store database credentials for WebLogic Server 12.1.3 datasource definitions.
Read more >Callback failure error when deploying and validating a new ...
In some circumstances deleting the database installer agent and recreating it manually on the same agent manager (FglAM) can help this ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@kellertobias That wouldn’t work if retrieving the password is an async operation. You would need to wait for it to complete prior to continuing the callback.
I took a peek at the code and turns out this wasn’t that bad to add. See https://github.com/brianc/node-postgres/pull/1926 for a PR that adds this feature. It’ll need at least one test added prior to being merged, but would be good if you can try it out and see if it works for your use case.
@vitaly-t Existing connections