Skip to content
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

Enhanced credentials service to support dynamically retrieved auth tokens (e.g. IAM RDS ) #2102

Closed
1 of 2 tasks
cartucciam opened this issue Mar 20, 2021 · 14 comments
Closed
1 of 2 tasks

Comments

@cartucciam
Copy link

New feature request

Hi All,

I am proposing adding a credentials service to allow for a more sophisticated way to set user credentials. The main use case for this would be solutions like IAM RDS auth token where the password is retrieved dynamically at runtime.

The idea would be to add an easily extensible Credential Service similarly to what the MariaDB connector got here.

This change would remove the duplication of the logic retrieving credentials dynamically, which otherwise must be implemented in every client accessing the database.

Regards,
Matteo

  • bug report
  • feature request
@davecramer
Copy link
Member

So are you proposing to implement this ?

@cartucciam
Copy link
Author

So are you proposing to implement this ?

Yes, I am. I would like to hear opinions from the maintainers as I suspect this has already been discussed since RDS IAM was released a while ago although I couldn't find anything in this repo.

@davecramer
Copy link
Member

Well until we see a concrete implementation there's not much to comment on. In general I'd say it would be a welcome addition.

@cartucciam
Copy link
Author

Well until we see a concrete implementation there's not much to comment on. In general I'd say it would be a welcome addition.

Thanks Dave, I wanted to rule out this having been discussed already and rejected for some reason before putting together a PR.

@bokken
Copy link
Member

bokken commented Mar 30, 2021

So the need is basically just a callback to provide the password (and maybe username)?

@sehrope
Copy link
Member

sehrope commented Mar 30, 2021

I think we only need it for password. The username is required in the startup packet and the password only comes into play after the server requests password based authentication.

I haven't looked at the wire messages, but from testing this a while back I remember that RDS requires you to be connecting over TLS to use this auth method. I bet that they're sending back an AuthenticationCleartextPassword message so they can get the raw value of the auth token for further processing.

@cartucciam
Copy link
Author

cartucciam commented Apr 1, 2021

So the need is basically just a callback to provide the password (and maybe username)?

yes, this is only for the password and we might want a caching mechanism as it expires after 15 minutes preventing new connections to be instantiated. In the MariaDB driver they went for caching it for 10 minutes.

I have been looking at adding it to the driver but not sure where the project is going, adding an abstraction layer to the credentials to allow different implementations like this to be used seems like a good idea but the current code appears pretty opinionated in keeping this aspect as simple as possible.

@kamatvishal
Copy link

@cartucciam Can you please let us know if this driver now supports the IAM RDS auth tokens just like mariadb driver does? From the comments so far, I see there is a discussion on making this change but not clear if its implemented and available in some version?

@sehrope
Copy link
Member

sehrope commented Nov 18, 2022

@kamatvishal Yes the feature was added in v42.3.3: REL42.3.1...REL42.3.2

Here's the release notes for that release: https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md#4232-2022-02-01-073541--0500

@kamatvishal
Copy link

Thanks @sehrope. Just to understand this feature, it basically added a way to provide a custom class which fetches the dynamic password. The postgres driver itself will not handle this natively like the MariaDB connector. Is this understanding correct?

@sehrope
Copy link
Member

sehrope commented Nov 18, 2022

Yes that is correct. You would supply your own implementation of a class that implements the plugin interface.

To match the behavior of the MariaDB driver, you could have it pull the base credentials from DefaultAWSCredentialsProviderChain and then generate an auth token to use as the password.

@davecramer
Copy link
Member

shameless plug https://github.com/awslabs/aws-advanced-jdbc-wrapper has the ability to do IAM authentication

@ecki
Copy link

ecki commented Nov 25, 2023

shameless plug

Or this, it includes less code but depends on your SDK instead. But both do not yet provide a authenticatorFactory compatible class.

https://github.com/magJ/iam-jdbc-driver

@davecramer
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants