Use DatabaseName for Keycloak Postgres JDBC URL#1328
Merged
aaronpowell merged 2 commits intoMay 22, 2026
Merged
Conversation
Updated KeycloakPostgresExtension to use the database resource's DatabaseName property instead of Name when building the JDBC connection string. This ensures the correct database name is used, especially when the resource name and actual database name differ.
Adds a test to verify that Keycloak integration with a Postgres resource correctly applies environment variables when a custom database name is used. The test checks that KC_DB and KC_DB_URL are set as expected and that the database URL ends with the custom name.
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 1328Or
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 1328" |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a bug in KeycloakPostgresExtension where the JDBC connection string used the Aspire resource name instead of the actual Postgres database name, causing Keycloak to fail when connecting to a database whose name differs from its resource name.
Changes:
- Replace
database.Resource.Namewithdatabase.Resource.DatabaseNamewhen building the JDBC URL. - Add an integration test verifying the JDBC URL ends with the custom database name.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/CommunityToolkit.Aspire.Hosting.Keycloak.Extensions/KeycloakPostgresExtension.cs | Use DatabaseName instead of Name for the JDBC URL path segment. |
| tests/CommunityToolkit.Aspire.Hosting.Keycloak.Extensions.Tests/KeycloakWithPostgresIntegrationTest.cs | New integration test asserting the JDBC URL uses the custom database name. |
Contributor
Author
@dotnet-policy-service agree |
aaronpowell
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
**Closes #1327 **
Updated KeycloakPostgresExtension to use the database resource's DatabaseName property instead of Name when building the JDBC connection string. This ensures the correct database name is used, especially when the resource name and actual database name differ.
PR Checklist
Breaking changes (?)
I don't really know if this is considered a breaking change, but i guess existing environments that persists the database somehow (i.e. deployed or persistent volumes) could have their connections broken if the database name is not updated to reflect the change?