question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support retrieving db password via callback

See original GitHub issue

RDS 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:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sehropecommented, Jul 17, 2019

@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.

1reaction
charmandercommented, Apr 9, 2019

@vitaly-t Existing connections

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found