Skip to content

Commit

Permalink
Merge pull request #41630 from sberyozkin/oidc_client_name_config
Browse files Browse the repository at this point in the history
Add OIDC clientName property
  • Loading branch information
sberyozkin authored Jul 2, 2024
2 parents c85f008 + b482750 commit b042038
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ public class OidcCommonConfig {
@ConfigItem
public Optional<String> clientId = Optional.empty();

/**
* The client name of the application. It is meant to represent a human readable description of the application which you
* may provide when an application (client) is registered in an OpenId Connect provider's dashboard.
* For example, you can set this property to have more informative log messages which record an activity of the given
* client.
*/
@ConfigItem
public Optional<String> clientName = Optional.empty();

/**
* The duration to attempt the initial connection to an OIDC server.
* For example, setting the duration to `20S` allows 10 retries, each 2 seconds apart.
Expand Down Expand Up @@ -736,6 +745,14 @@ public void setClientId(String clientId) {
this.clientId = Optional.of(clientId);
}

public Optional<String> getClientName() {
return clientName;
}

public void setClientName(String clientName) {
this.clientName = Optional.of(clientName);
}

public Credentials getCredentials() {
return credentials;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,10 @@ public Uni<ChallengeData> apply(TenantConfigContext tenantContext) {
}

public Uni<ChallengeData> getChallengeInternal(RoutingContext context, TenantConfigContext configContext) {
LOG.debugf("Starting an authentication challenge for tenant %s", configContext.oidcConfig.tenantId.get());
LOG.debugf("Starting an authentication challenge for tenant %s.", configContext.oidcConfig.tenantId.get());
if (configContext.oidcConfig.clientName.isPresent()) {
LOG.debugf(" Client name: %s", configContext.oidcConfig.clientName.get());
}

OidcTenantConfig sessionCookieConfig = configContext.oidcConfig;
String sessionTenantIdSetByCookie = context.get(OidcUtils.TENANT_ID_SET_BY_SESSION_COOKIE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ private TokenVerificationResult verifyJwtTokenInternal(String token,
detail = details.get(0).getErrorMessage();
}
if (oidcConfig.clientId.isPresent()) {
LOG.debugf("Verification of the token issued to client %s has failed: %s", oidcConfig.clientId.get(), detail);
LOG.debugf("Verification of the token issued to client %s has failed: %s.", oidcConfig.clientId.get(), detail);
if (oidcConfig.clientName.isPresent()) {
LOG.debugf(" Client name: %s", oidcConfig.clientName.get());
}
} else {
LOG.debugf("Token verification has failed: %s", detail);
}
Expand Down

0 comments on commit b042038

Please sign in to comment.