Skip to content

Add metadata overrides for sensitive connection string values (URL and DSN support)#3825

Merged
yaron2 merged 4 commits into
dapr:mainfrom
nelson-parente:oss-125-postgresql-state-store-add-separate-metadata-options-for
Jun 3, 2025
Merged

Add metadata overrides for sensitive connection string values (URL and DSN support)#3825
yaron2 merged 4 commits into
dapr:mainfrom
nelson-parente:oss-125-postgresql-state-store-add-separate-metadata-options-for

Conversation

@nelson-parente

@nelson-parente nelson-parente commented May 20, 2025

Copy link
Copy Markdown
Contributor

Description

This introduces support for overriding sensitive connection string values via metadata. Both URL-style and DSN-style connection strings are supported.

Currently supported overrides asked in the issue:

  • host
  • database
  • user
  • password
  • sslrootcert

Happy to add support for additional fields if needed.

Docs PR: dapr/docs#4664

Issue reference

#3809

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

@nelson-parente
nelson-parente force-pushed the oss-125-postgresql-state-store-add-separate-metadata-options-for branch from ca9e8e6 to c7fef3d Compare May 20, 2025 20:51
@nelson-parente
nelson-parente marked this pull request as ready for review May 20, 2025 21:00
@nelson-parente
nelson-parente requested review from a team as code owners May 20, 2025 21:00
@nelson-parente nelson-parente changed the title feat: add auth metadata options and connectionstring builder Add metadata overrides for sensitive connection string values (URL and DSN support) May 20, 2025
@nelson-parente
nelson-parente force-pushed the oss-125-postgresql-state-store-add-separate-metadata-options-for branch 3 times, most recently from 4d7d390 to 16901ee Compare May 21, 2025 08:44
Comment on lines +108 to +111
func (m *PostgresAuthMetadata) buildConnectionString() (string, error) {
if m.ConnectionString == "" {
return "", errors.New("connection string is required")
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is an error here intended? The below method buildDSNConnectionString appears to build a suitable connection string

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Initially, I didn't add all the props so you couldn't build a valid connection with metadata only. Since I've now added more props to the metadata we can allow to build only from meta.

Comment thread common/authentication/postgresql/metadata.go
@alicejgibbons

Copy link
Copy Markdown

So the logic here should be the broken out (potentially sensitive) values can be used along with values in the dns connection string. If the values are present in their own metadata property then they should overwrite the same value in the DNS connection string. Of course we hope the user won't provide them twice but the precedence should always be the individual value over the connection string one. Looking at the other potential connection string values, we should also add hostaddr, looking here - this is c lib but assuming its similar.

We also don't have to support this in v1, only v2 for State.

Comment thread common/authentication/postgresql/metadata_test.go
@nelson-parente
nelson-parente force-pushed the oss-125-postgresql-state-store-add-separate-metadata-options-for branch from a6e6bfe to 790af47 Compare May 22, 2025 10:01
}

// buildConnectionString builds the connection string from the metadata.
// It supports both DSN-style and URL-style connection strings.

@alicejgibbons alicejgibbons May 22, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ah yeah ignore me - deleted

Signed-off-by: nelson.parente <[email protected]>

@mikeee mikeee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm!

@alicejgibbons alicejgibbons left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Logic lgtm, only im unsure if we want to continue to support v1, would confirm with the community

@nelson-parente

Copy link
Copy Markdown
Contributor Author

Logic lgtm, only im unsure if we want to continue to support v1, would confirm with the community

Logic is the same for v1/v2 I don't think there is harm in adding this to v1 too

@yaron2
yaron2 added this pull request to the merge queue May 27, 2025
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 27, 2025
@nelson-parente

Copy link
Copy Markdown
Contributor Author

@yaron2 can we merge this? I don't think merge queue is working so we need manual merge.

@yaron2
yaron2 merged commit 3525032 into dapr:main Jun 3, 2025
@marcduiker

Copy link
Copy Markdown
Contributor

@holopin-bot @nelson-parente Thank you! Here's a digital badge as a small token of appreciation.

@holopin-bot

holopin-bot Bot commented Jun 11, 2025

Copy link
Copy Markdown

Congratulations @nelson-parente, the maintainer of this repository has issued you a badge! Here it is: https://holopin.io/claim/cmbs0d6sr1630907l5s58im4e2

This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account.
Or if you're new to Holopin, you can simply sign up with GitHub, which will do the trick!

passuied pushed a commit to passuied/components-contrib that referenced this pull request Feb 14, 2026
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