Skip to content

Make new dashboard client credentials configurable on bootstrap#1185

Open
SteDev2 wants to merge 27 commits intodevelopfrom
init-dashboard
Open

Make new dashboard client credentials configurable on bootstrap#1185
SteDev2 wants to merge 27 commits intodevelopfrom
init-dashboard

Conversation

@SteDev2
Copy link
Contributor

@SteDev2 SteDev2 commented Mar 9, 2026

No description provided.

@rmiccoli rmiccoli moved this to In Progress in v1.14.0 Mar 9, 2026
@SteDev2 SteDev2 marked this pull request as ready for review March 13, 2026 16:33
Copy link
Member

@enricovianello enricovianello left a comment

Choose a reason for hiding this comment

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

Minor fixes

@sonarqubecloud
Copy link

@enricovianello enricovianello changed the title Init new dashboard deploy Make new dashboard client credentials configurable on bootstrap Mar 24, 2026
Copy link
Member

@enricovianello enricovianello left a comment

Choose a reason for hiding this comment

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

Probably some safer comparisons could be done and a missing ClientUpdatedEvent to be fixed. Also minor things about log messages.
But from the point of view of the logic it's ok.
Theres's also a question for @giacomini about supporting or not a configurable list of redirect URIs in order to allow different hostnames (different from the issuer).

}

boolean isValid = dashboardConfigService.init();
if (!isValid) {
Copy link
Member

Choose a reason for hiding this comment

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

checking the code of the service, I see false is returned after an Exception is thrown on db entry creation. I think we can raise another error here saying something like "Error during dashboard client initialization. Startup failed. Please check the logged error."

public void run(ApplicationArguments args) {
if (!dashboardConfigService.isEnabled()) {
LOG.info(
"Dashboard client is disabled, skipping checks for the dashboard client properties and the presence of the record for the dashboard client");
Copy link
Member

Choose a reason for hiding this comment

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

I'd simplify this message into "Skipping dashboard client initialization." The perfect message should include something like "Read more info about here: " + URL of an updated IAM documentation.

Optional<ClientDetailsEntity> dashboardRecord = clientRepository.findByClientId(clientId);

if (!dashboardRecord.isPresent()) {
LOG.info("The client record for dashboard does not exist. Creating record with default configuration...");
Copy link
Member

Choose a reason for hiding this comment

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

"Dashboard client does not exist and it will be created."

ClientDetailsEntity client = dashboardRecord.get();
boolean isValid = checkRecordConfiguration(client, clientSecret, url);
if (!isValid) {
LOG.warn("The record is not properly configured. Updating Dashboard client.");
Copy link
Member

Choose a reason for hiding this comment

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

"Changes on default dashboard client configuration found: restoring expected configuration."

I know it's a database record but I'd like to communicate an higher level concept to the final admins :)

}

private boolean usesClientSecretBasicAuth(ClientDetailsEntity client) {
return client.getTokenEndpointAuthMethod().equals(AuthMethod.SECRET_BASIC);
Copy link
Member

Choose a reason for hiding this comment

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

same as above

}

private boolean usesPKCES256(ClientDetailsEntity client) {
return client.getCodeChallengeMethod().getName().equals(PKCEAlgorithm.S256.toString());
Copy link
Member

Choose a reason for hiding this comment

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

same as above

}

private boolean hasValidClientSecret(ClientDetailsEntity client, String clientSecret) {
return client.getClientSecret().equals(clientSecret);
Copy link
Member

Choose a reason for hiding this comment

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

same as below

}

private boolean hasAllRequiredScopes(ClientDetailsEntity client) {
return client.getScope().containsAll(DASHBOARD_SCOPES);
Copy link
Member

Choose a reason for hiding this comment

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

I'd add a safer:

client.getScope() != null && before

to protect from null pointer exceptions

client.setRedirectUris(Set.of(url));
client.setTokenEndpointAuthMethod(AuthMethod.SECRET_BASIC);

clientRepository.save(client);
Copy link
Member

Choose a reason for hiding this comment

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

We're not using client service so we need to add a ClientUpdatedEvent here

Copy link
Member

Choose a reason for hiding this comment

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

Or simply use clientService.updateClient() which also evicts cached values

@enricovianello enricovianello moved this from On Review to Changes Requested in v1.14.0 Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Changes Requested

Development

Successfully merging this pull request may close these issues.

5 participants