Skip to content

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 [email protected])
  • πŸ”— 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 from cd0bd7c to b842b06 Compare December 16, 2025 21:02
@rmannibucau rmannibucau force-pushed the dev/make-client-id-secret-pattern-configurable branch 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
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