From b48275047a902eb242225148abcb40c6859f6208 Mon Sep 17 00:00:00 2001 From: Sergey Beryozkin Date: Tue, 2 Jul 2024 15:09:07 +0100 Subject: [PATCH] Add OIDC clientName property --- .../oidc/common/runtime/OidcCommonConfig.java | 17 +++++++++++++++++ .../runtime/CodeAuthenticationMechanism.java | 5 ++++- .../io/quarkus/oidc/runtime/OidcProvider.java | 5 ++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonConfig.java b/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonConfig.java index 59520713f129f..d744d88358f84 100644 --- a/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonConfig.java +++ b/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonConfig.java @@ -51,6 +51,15 @@ public class OidcCommonConfig { @ConfigItem public Optional 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 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. @@ -736,6 +745,14 @@ public void setClientId(String clientId) { this.clientId = Optional.of(clientId); } + public Optional getClientName() { + return clientName; + } + + public void setClientName(String clientName) { + this.clientName = Optional.of(clientName); + } + public Credentials getCredentials() { return credentials; } diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java index 5edbb3e0fd948..7ce98b9559606 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java @@ -611,7 +611,10 @@ public Uni apply(TenantConfigContext tenantContext) { } public Uni 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); diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProvider.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProvider.java index 2953422f3871c..dde4e3d77d34d 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProvider.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProvider.java @@ -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); }