Skip to content

fix: removing EnvConfigSource keys that are not intended - #51291

Open
shawkins wants to merge 1 commit into
keycloak:mainfrom
shawkins:iss51113
Open

fix: removing EnvConfigSource keys that are not intended#51291
shawkins wants to merge 1 commit into
keycloak:mainfrom
shawkins:iss51113

Conversation

@shawkins

Copy link
Copy Markdown
Contributor

closes: #51113

@shawkins
shawkins marked this pull request as ready for review August 4, 2026 20:03
Copilot AI balanced review requested due to automatic review settings August 4, 2026 20:03
@shawkins
shawkins requested review from a team as code owners August 4, 2026 20:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes #51113 by separating Keycloak environment variables from Quarkus environment handling and masking SPI values in show-config.

Changes:

  • Filters Keycloak-specific environment variables from Quarkus configuration.
  • Masks all SPI option values in show-config.
  • Adds regression tests and upgrade documentation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
KcEnvConfigSource.java Splits Keycloak and Quarkus environment sources.
Configuration.java Manually registers default configuration sources.
ShowConfig.java Masks SPI configuration values.
PicocliTest.java Tests SPI secret masking.
changes-26_8_0.adoc Documents the masking change.

Comment thread docs/documentation/upgrading/topics/changes/changes-26_8_0.adoc Outdated
Comment on lines +110 to +111
.withSources(new DotEnvConfigSourceProvider()
.getConfigSources(Thread.currentThread().getContextClassLoader()))

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.

This is not an issue for two reasons. 1. all spi options are now masked. 2. .env files are not a documented configsource, it is not expected that they will be used.

Copilot AI review requested due to automatic review settings August 4, 2026 20:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (1)

quarkus/runtime/src/test/java/org/keycloak/quarkus/runtime/cli/PicocliTest.java:279

  • The negative-only assertion can also pass if this valid SPI property is accidentally dropped from show-config, so it does not verify the documented “mask” behavior. Assert the property is still emitted with the mask as well as checking that the secret is absent.
        NonRunningPicocli nonRunningPicocli = pseudoLaunch("show-config");
        assertThat(nonRunningPicocli.getOutString(), not(containsString("custom-secret")));

Copilot AI review requested due to automatic review settings August 4, 2026 22:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (1)

docs/documentation/upgrading/topics/changes/changes-26_8_0.adoc:57

  • This repeats the release-note section already added at lines 41–43, causing the same change to appear twice. Remove this second section.
=== `show-conifg` will mask all SPI option values

The `show-config` command will mask all SPI option values. The command is not currently aware of provider factory configuration property metadata, so it cannot determine if a property is marked as `isSecret`.

Copilot AI review requested due to automatic review settings August 5, 2026 11:08
@shawkins

shawkins commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Should be ready for a review. Given that we are now masking all SPI options the logic to change how the env properties are discovered could be reverted - if it seems too risky to take responsibility for this in our code.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Pepo48
Pepo48 previously approved these changes Aug 5, 2026
@Pepo48

Pepo48 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Given that we are now masking all SPI options the logic to change how the env properties are discovered could be reverted - if it seems too risky to take responsibility for this in our code.

@shawkins, I'm not sure the env filtering can be safely reverted. The SPI masking catches kc.spi-* (hyphenated) properties, but SmallRye's EnvConfigSource aliases KC_SPI_VAULT__KEYSTORE__PASS to kc.spi.vault."keystore".pass (dotted), which bypasses the kc.spi- prefix check entirely.

So I guess it's not redundant, but rather complementary.

@shawkins

shawkins commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

So I guess it's not redundant, but rather complementary.

That is correct, the spi masking would need to check for both prefixes.

if (property.startsWith(MicroProfileConfigProvider.SPI_PREFIX)) {
// could be marked as ProviderConfigProperty.isSecret, so the simplest option for now
// is to just mask all direct usage of spi options.
// the most straight-forward alternative is to move show-config to be run after the quarkus start

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@shawkins, correct. To be specific, if we decide to revert the changes in KcEnvConfigSource.java and Configuration.java, I would adjust:

Suggested change
// the most straight-forward alternative is to move show-config to be run after the quarkus start
if (property.startsWith(MicroProfileConfigProvider.SPI_PREFIX)
|| property.startsWith(MicroProfileConfigProvider.NS_KEYCLOAK_PREFIX + "spi.")) {

During the review yesterday, I ran the added tests with this change on top and everything seemed to work.

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.

Correct, I'm not saying that we have to take this approach, just that it's an option if anyone feels the changes to the Configuration creation seem too risky.

Copilot AI review requested due to automatic review settings August 7, 2026 14:00
@shawkins

shawkins commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Squashed and rebased to see if the doc check error will get cleared.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@keycloak-github-bot

Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.cluster.RealmInvalidationClusterTest#crudWithFailover

Keycloak CI - Store IT (oracle)

org.opentest4j.AssertionFailedError: expected: <false> but was: <true>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertFalse.failNotFalse(AssertFalse.java:63)
	at org.junit.jupiter.api.AssertFalse.assertFalse(AssertFalse.java:36)
...

Report flaky test

@keycloak-github-bot keycloak-github-bot Bot 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.

Unreported flaky test detected, please review

closes:keycloak#51113

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
# Conflicts:
#	docs/documentation/upgrading/topics/changes/changes-26_8_0.adoc

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage of second class configuration may not be masked in show-config

3 participants