In some instances, credentials for the redis client will be short-lived and need to be fetched on-demand when connecting to redis. This is the case when connecting in AWS using IAM authentication or Entra ID in Azure.
This feature allows for a credentialProvider to be provided which is a callable function returning a Promise that resolves to a username/password object.
Closes #821
A potential enhancement to this feature could be to also return a TTL with the credentials and then automatically attempt to re-auth the client before the credentials expire; however I've assumed that logic will be the responsibility of the consumer rather than the library. Worst case scenario is that the socket disconnects due to authentication error and then re-authenticates on a future reconnection retry attempt.
Something else that is missing is an explicit decision on how errors from the credentialProvider should be surfaced.
Checklist
[ ] Does npm test pass with this change (including linting)?
[x] Is the new or changed code fully tested?
[x] Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
Description
In some instances, credentials for the redis client will be short-lived and need to be fetched on-demand when connecting to redis. This is the case when connecting in AWS using IAM authentication or Entra ID in Azure.
This feature allows for a credentialProvider to be provided which is a callable function returning a Promise that resolves to a username/password object.
Closes #821
A potential enhancement to this feature could be to also return a TTL with the credentials and then automatically attempt to re-auth the client before the credentials expire; however I've assumed that logic will be the responsibility of the consumer rather than the library. Worst case scenario is that the socket disconnects due to authentication error and then re-authenticates on a future reconnection retry attempt.
Something else that is missing is an explicit decision on how errors from the credentialProvider should be surfaced.
Checklist
npm test
pass with this change (including linting)?