Skip to content

Relax client_id, client_secret regex/pattern validation on reset endpoint call#3276

Merged
dimas-b merged 1 commit intoapache:mainfrom
rmannibucau:dev/make-client-id-secret-pattern-configurable
Jan 19, 2026
Merged

Relax client_id, client_secret regex/pattern validation on reset endpoint call#3276
dimas-b merged 1 commit intoapache:mainfrom
rmannibucau:dev/make-client-id-secret-pattern-configurable

Conversation

@rmannibucau
Copy link
Contributor

client_id/client_secret patterns are validated when calling reset endpoint but the pattern is hardcoded which can be too rigid.
this PR just enables to configure it.

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

Copy link
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution, @rmannibucau ! Please see my comment about not performing these checks. If you agree, the other comments can be ignored.

*/
public abstract class PolarisConfiguration<T> {

private static final Logger LOGGER = LoggerFactory.getLogger(PolarisConfiguration.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: if you find "dead code", it's generally preferable to cleanup in a dedicated PR and avoid mixing cleanup with feature changes :)

private void validateClientId(String clientId) {
if (!clientId.matches("^[0-9a-f]{16}$")) {
if (!clientId.matches(
realmConfig.getConfig(FeatureConfiguration.CREDENTIAL_RESET_CLIENT_ID_PATTERN))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should validate the value of CREDENTIAL_RESET_CLIENT_ID_PATTERN on startup to avoid deferred RegEx syntax errors (it's an admin mistake, not the API client's mistake)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, it will be per realm so no sure it can be done at startup properly, do you have a code pointer in mind? would bootstrap realm fulfill your expectation?

default is known valid - same as before, it is hardcoded

Copy link
Contributor

Choose a reason for hiding this comment

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

Cf.

public ProductionReadinessCheck checkTokenBrokers(AuthenticationConfiguration configuration) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, not sure i'm a fan of this one, feature is quite specific and we would make the realm down for it? 🤔

let's drop the validation for now then

private void validateClientSecret(String clientSecret) {
if (!clientSecret.matches("^[0-9a-f]{32}$")) {
if (!clientSecret.matches(
realmConfig.getConfig(FeatureConfiguration.CREDENTIAL_RESET_CLIENT_SECRET_PATTERN))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If validating client ID/secret format is becoming a nuisance to users, from my POV this check can just be removed completely. I do not think Polaris code relies on these values following a particular format.

If backward compatibility is a concern, I'd rather add a simple boolean flag to disable these checks (defaulting to enabled). WDYT?

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'm fine dropping the feature (the two validateClientX methods) too

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to @dimas-b suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's try removing the checks completely and get some more reviews. If people raise concerns we can add an on/off flag then.

@rmannibucau rmannibucau force-pushed the dev/make-client-id-secret-pattern-configurable branch from 548e086 to cd0bd7c Compare December 16, 2025 18:02
}
}

private PolarisServiceImpl noAdminResetCredentialPolarisService() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this method still used?

@rmannibucau rmannibucau force-pushed the dev/make-client-id-secret-pattern-configurable branch 2 times, most recently from b842b06 to 8dfbac6 Compare December 16, 2025 22:00
Copy link
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

Code change LGTM 👍 The PR title probably needs to be adjusted now 🙂

@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Dec 17, 2025
@rmannibucau rmannibucau changed the title Ensure client_id/client_secret patterns are configurable Ensure client_id/client_secret patterns are not enforced as before Dec 17, 2025
@github-actions
Copy link

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Jan 17, 2026
@dimas-b dimas-b changed the title Ensure client_id/client_secret patterns are not enforced as before Relax client_id, client_secret regex/pattern validation on reset endpoint call Jan 19, 2026
dimas-b
dimas-b previously approved these changes Jan 19, 2026
@dimas-b
Copy link
Contributor

dimas-b commented Jan 19, 2026

@rmannibucau : sorry that this PR got forgotten. I think it still makes sense to merge it. Could you resolve conflicts, please?

@dimas-b dimas-b removed the Stale label Jan 19, 2026
@rmannibucau rmannibucau force-pushed the dev/make-client-id-secret-pattern-configurable branch from 8dfbac6 to 49afa41 Compare January 19, 2026 22:21
@rmannibucau
Copy link
Contributor Author

@dimas-b sure, done

@dimas-b dimas-b merged commit 7bd71e0 into apache:main Jan 19, 2026
15 checks passed
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board Jan 19, 2026
@rmannibucau rmannibucau deleted the dev/make-client-id-secret-pattern-configurable branch January 20, 2026 09:41
evindj pushed a commit to evindj/polaris that referenced this pull request Jan 26, 2026
…dpoint call (apache#3276)

client_id/client_secret patterns are validated when calling reset endpoint but the pattern is hardcoded which can be too rigid.
snazy added a commit to snazy/polaris that referenced this pull request Feb 11, 2026
* Use injected RealmConfig in JdbcMetaStoreManagerFactory (apache#3412)

* Use injected RealmConfig in JdbcMetaStoreManagerFactory

* Improve code isolation by using `RealmConfig` (like most other code)
  instead of the lower-level `PolarisConfigurationStore`

* This also enabled proper CDI request-scoped injection in concert with apache#3411

* Additionally, this enables further code cleanup in `PolarisConfigurationStore`
  as discussed in apache#3324 with the goal of using this interface for the backend
  configuration code, while `RealmConfig` becomes the corresponding frontend
  interface.

* Fix `ServiceProducers.realmConfig()` to make a `RealmConfigImpl` directly from
  its dependencies (not from `CallContext`) to avoid cycles in CDI.

* Fix renovate syntax (apache#3471)

* Remove client_id, client_secret regex/pattern validation on reset endpoint call (apache#3276)

client_id/client_secret patterns are validated when calling reset endpoint but the pattern is hardcoded which can be too rigid.

* Use typed config for `TABLE_METADATA_CLEANUP_BATCH_SIZE` (apache#3478)

Add a typed `FeatureConfiguration` with the same config name and default value.

* chore(deps): update docker.io/adobe/s3mock docker tag to v4.11.0 (apache#3492)

* fix(deps): update dependency io.smallrye.config:smallrye-config-core to v3.15.1 (apache#3490)

* fix(deps): update dependency ch.qos.logback:logback-classic to v1.5.25 (apache#3489)

* chore(deps): update plugin com.gradle.develocity to v4.3.1 (apache#3452)

* Last merged commit 738bce9

---------

Co-authored-by: Dmitri Bourlatchkov <dmitri.bourlatchkov@gmail.com>
Co-authored-by: Yong Zheng <yongzheng0809@gmail.com>
Co-authored-by: Romain Manni-Bucau <rmannibucau@gmail.com>
Co-authored-by: Mend Renovate <bot@renovateapp.com>
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.

3 participants