ioredis icon indicating copy to clipboard operation
ioredis copied to clipboard

feat(auth): add support for function for password

Open slukes opened this issue 6 months ago • 5 comments

When working with elasticache with IAM (and probably other providers), it is necessary to use a token that is only valid for 15 minutes as a password, as a result subsequent reconnects need to be done with a newly generated password.

There are at least these two issues discussing this:

https://github.com/redis/ioredis/issues/1738 https://github.com/redis/ioredis/issues/1810

Up until now we had been using an on('ready,...) event listener to manage this in our code, but since migrating from bull to bullmq which uses duplicate method which does not copy the event listeners and what is more applies it's own on ready listener which makes this option unusable.

Rather than continuing with the (quite hacky) work around suggested in the above two issues, I would like to propose that we accept a function instead of a string for the password.

slukes avatar Jun 10 '25 12:06 slukes

Yes please.

artman avatar Jun 26 '25 07:06 artman

Hello 👋 any chance of a review please

slukes avatar Jun 30 '25 08:06 slukes

Please review the pr, the feature is very needed

MykhailoMatiiasevych avatar Aug 08 '25 07:08 MykhailoMatiiasevych

Would this work properly in case of reconnects? I was thinking to bring password resolution closer to AUTH, ie in connectHandler

MykhailoMatiiasevych avatar Aug 08 '25 08:08 MykhailoMatiiasevych

At first glance this looks okay, however the checks are failing

@slukes please make sure the tests pass and then request a review again

PavelPashov avatar Aug 12 '25 10:08 PavelPashov