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

Support dynamic passwords #1109

Open
ybasket opened this issue Jul 18, 2024 · 3 comments
Open

Support dynamic passwords #1109

ybasket opened this issue Jul 18, 2024 · 3 comments

Comments

@ybasket
Copy link

ybasket commented Jul 18, 2024

Use Case
At $work, we're looking to switch from doobie to skunk. One obstacle on the migration comes from the likely requirement to use AWS RDS IAM. It integrates Postgres authentication with AWS IAM by signing short-lived (15 min) tokens that can be used as password when connecting to RDS Postgres. The problem with skunk is that it expects the password to be static, it's just String in all relevant signatures.

Feature request
Unless I'm overlooking some smart way to deal with a connection pool and a dynamic password in the existing setup, it would be cool if skunk added support. From what I've seen at first glance, taking a F[String] (or maybe more general a F[SomeConnectionParamsIncludingPassword] that is evaluated when the connection is established, would help to support it. The existing (public) method signatures could just lift the password using pure, for RDS IAM, the effect would ask the AWS SDK for a fresh/TTL-aware-cached token.

@ybasket
Copy link
Author

ybasket commented Jul 22, 2024

After further exploration, I was able to inject a dynamic password somewhat OK-ish:

  1. Copy Session.pooledF's implementation
  2. Replace the password parameter by an effect supplying the password
  3. In the inner method called session, evaluate that effect to obtain the current password

Not great UX, but okay. Would still be cool to have a method on Session that did this directly, pooledF could just delegate with a pure effect.

@Jasper-M
Copy link

Jasper-M commented Oct 9, 2024

If that works well, perhaps you could open a PR to add that generalized version of pooledF and pooled to Session.

@ybasket
Copy link
Author

ybasket commented Oct 9, 2024

If that works well, perhaps you could open a PR to add that generalized version of pooledF and pooled to Session.

Unfortunately, at $work we paused migration to both skunk and RDS IAM (for reasons unrelated to skunk itself), so while I know I got it to compile once, I'm currently not in a good position to properly test it. If/When we get back to it and I'm sure it works reliably, I'm happy to contribute as you suggested :)

In the meantime, anyone feel free to pick this up if you like to, it shouldn't be too hard to implement (just a bit of bincompat care and real testing is bit ugly).

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

2 participants