diff --git a/extensions/oidc-token-propagation-reactive/runtime/src/main/java/io/quarkus/oidc/token/propagation/reactive/AccessTokenRequestReactiveFilter.java b/extensions/oidc-token-propagation-reactive/runtime/src/main/java/io/quarkus/oidc/token/propagation/reactive/AccessTokenRequestReactiveFilter.java index 4d54705913d5a..10052f4740f97 100644 --- a/extensions/oidc-token-propagation-reactive/runtime/src/main/java/io/quarkus/oidc/token/propagation/reactive/AccessTokenRequestReactiveFilter.java +++ b/extensions/oidc-token-propagation-reactive/runtime/src/main/java/io/quarkus/oidc/token/propagation/reactive/AccessTokenRequestReactiveFilter.java @@ -61,7 +61,8 @@ public AccessTokenRequestReactiveFilter() { public void initExchangeTokenClient() { if (exchangeToken) { OidcClients clients = Arc.container().instance(OidcClients.class).get(); - exchangeTokenClient = oidcClientName.isPresent() ? clients.getClient(oidcClientName.get()) : clients.getClient(); + String clientName = getClientName(); + exchangeTokenClient = clientName != null ? clients.getClient(clientName) : clients.getClient(); Grant.Type exchangeTokenGrantType = ConfigProvider.getConfig() .getValue( "quarkus.oidc-client." + (oidcClientName.isPresent() ? oidcClientName.get() + "." : "") @@ -113,6 +114,10 @@ public void accept(Throwable t) { } } + protected String getClientName() { + return oidcClientName.orElse(null); + } + public void propagateToken(ResteasyReactiveClientRequestContext requestContext, String accessToken) { if (accessToken != null) { requestContext.getHeaders().add(HttpHeaders.AUTHORIZATION, BEARER_SCHEME_WITH_SPACE + accessToken); diff --git a/extensions/oidc-token-propagation/runtime/src/main/java/io/quarkus/oidc/token/propagation/AccessTokenRequestFilter.java b/extensions/oidc-token-propagation/runtime/src/main/java/io/quarkus/oidc/token/propagation/AccessTokenRequestFilter.java index ffffd3cb145a8..1fe17e73ea0f7 100644 --- a/extensions/oidc-token-propagation/runtime/src/main/java/io/quarkus/oidc/token/propagation/AccessTokenRequestFilter.java +++ b/extensions/oidc-token-propagation/runtime/src/main/java/io/quarkus/oidc/token/propagation/AccessTokenRequestFilter.java @@ -54,7 +54,8 @@ public AccessTokenRequestFilter() { public void initExchangeTokenClient() { if (exchangeToken) { OidcClients clients = Arc.container().instance(OidcClients.class).get(); - exchangeTokenClient = oidcClientName.isPresent() ? clients.getClient(oidcClientName.get()) : clients.getClient(); + String clientName = getClientName(); + exchangeTokenClient = clientName != null ? clients.getClient(clientName) : clients.getClient(); Grant.Type exchangeTokenGrantType = ConfigProvider.getConfig() .getValue( "quarkus.oidc-client." + (oidcClientName.isPresent() ? oidcClientName.get() + "." : "") @@ -92,6 +93,10 @@ private String exchangeTokenIfNeeded(String token) { } } + protected String getClientName() { + return oidcClientName.orElse(null); + } + private boolean acquireTokenCredentialFromCtx(ClientRequestContext requestContext) { if (enabledDuringAuthentication) { TokenCredential tokenCredential = getTokenCredentialFromContext();