8000 PostgreSQL backend passwordless authentication in cloud by tauhid621 · Pull Request #30681 · hashicorp/vault · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PostgreSQL backend passwordless authentication in cloud #30681

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

Merged
merged 7 commits into from
Jun 4, 2025

Conversation

tauhid621
Copy link
Contributor
@tauhid621 tauhid621 commented May 20, 2025

Description

What does this PR do?

This PR adds support to authenticate PostgreSQL Backend server with cloud based identities(AWS IAM, Azure MSI and GCP IAM). This will allow users to avoid password based auth in cloud environment.

Note: The changes were merged earlier and were reverted for another round of review.
Slack conversation: https://hashicorp.slack.com/archives/C0287E435NE/p1747085455400359

How

We have replaced the sql driver with pgmultiauth's implementation. pgmultiauth handles cloud authentication and is a wrapper around pgx driver.

Note: The PR also updates some deprecated docker types used in tests.

Added configs

  • auth_mode - Defaults to standard auth. Can be set to aws_iam, azure_msi, gcp_iam or standard.
  • aws_db_region - Specifies the AWS region where DB is situated. Required when auth_mode is set to aws_iam
  • azure_client_id - Client ID of a user-assigned Managed Service Identity. System-assigned Managed Service Identity is used if azure_client_id is not provided and auth_mode is set to azure_msi.

References

Jira: https://hashicorp.atlassian.net/browse/IND-2963
RFC: https://go.hashi.co/rfc/tf-1050

Testing

  • Tested the changes with default flow and AWS auth
  • Unit tests
  • CI

TODO only if you're a HashiCorp employee

  • Backport Labels: If this fix needs to be backported, use the appropriate backport/ label that matches the desired release branch. Note that in the CE repo, the latest release branch will look like backport/x.x.x, but older release branches will be backport/ent/x.x.x+ent.
    • LTS: If this fixes a critical security vulnerability or severity 1 bug, it will also need to be backported to the current LTS versions of Vault. To ensure this, use all available enterprise labels.
  • ENT Breakage: If this PR either 1) removes a public function OR 2) changes the signature
    of a public function, even if that change is in a CE file, double check that
    applying the patch for this PR to the ENT repo and running tests doesn't
    break any tests. Sometimes ENT only tests rely on public functions in CE
    files.
  • Jira: If this change has an associated Jira, it's referenced either
    in the PR description, commit message, or branch name.
  • RFC: If this change has an associated RFC, please link it in the description.
  • ENT PR: If this change has an associated ENT PR, please link it in the
    description. Also, make sure the changelog is in this PR, not in your ENT PR.

@tauhid621 tauhid621 marked this pull request as ready for review May 20, 2025 10:23
@tauhid621 tauhid621 requested review from a team as code owners May 20, 2025 10:23
@tauhid621 tauhid621 requested review from scellef and davidadeleon May 20, 2025 10:23
Copy link
Member
@banks banks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tauhid621

Thanks for this PR. Overall I like this functionality and you've done a great job of updating documentation etc.

Overall I think this looks good but a couple of questions:

  1. Initially I assumed pgmultiauth library was a third party library that presumably is already well used and well tested. It seems like it's a pretty recent library that we wrote ourselves though and I'm guessing hasn't had time in production yet? Could you talk through the testing process for that library? Does it have reasonable integration tests with each provider?
  2. Are there a plans to continue adding new providers to it? One concern with previous libraries like this (see go-discover) is that they ended up adding 100s of MB of bloat to our binaries because they tend to pull in entire SDK for each cloud even though they only hit a single endpoint. I'd be curious what the plans are for broader support for other clouds and whether this increases Vault's binary size any. (It probably won't a lot as I think we probably already pull in these three SDKs).

Actually....

There is a bigger concern that could be a blocker. I don't think that library is in compliance with our internal controls and so can't be included in our releases yet. I'll work with you on this out of band.

We should not merge this until we confirm this.

@@ -174,6 +176,47 @@ func TestConnectionURL(t *testing.T) {
}
}

// TestGetAuthConfig - We only test the standard flow as we would get errors for cloud based auth while fetching token
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to stub out the actual endpoint pgmulti-auth uses for each cloud to test those? I'm not sure it's necessary if it's a huge lift, but it seems like it could be reasonable if they allow you to override the URL for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did think of it initially and realised that it could be very tricky.
I will try to explore this a bit more.

Co-authored-by: Paul Banks <banks@banksco.de>
@tauhid621
Copy link
Contributor Author

@banks . Answering your questions

  1. We do have few integration tests in place for pgmultiauth. However they are not automated and needs to run in each environment manually. We have plans to automated this in future.

  2. We do not have any major plans to add more providers to the library. We may add support of rotating password using a Vault server in future.

I will work on the compliance part. We did had a security review and got the repo added to Compliance Scope. I will explore more on additional needs.

banks
banks previously approved these changes May 28, 2025
Copy link
Member
@banks banks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, we've confirmed necessary compliance controls are in place now.

I'm going to approve this on the basis of your answers above - thanks!

I do think additional testing especially since it's a new library and there are several different integrations should be prioritised, however for now I think we can accept and unblock you.

@JMGoldsmith JMGoldsmith merged commit d9ecd5b into hashicorp:main Jun 4, 2025
85 checks passed
drivera258 pushed a commit that referenced this pull request Jun 11, 2025
* PostgreSQL backend passwordless authentication in cloud

* updated changelog file name

* Update the changelog

Co-authored-by: Paul Banks <banks@banksco.de>

* fix image spec sha

---------

Co-authored-by: Paul Banks <banks@banksco.de>
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

Successfully merging this pull request may close these issues.

5 participants
0