From ec9c312fb8d04576de1890d14d01443d34df3d30 Mon Sep 17 00:00:00 2001 From: Sergey Beryozkin Date: Tue, 28 Nov 2023 19:05:16 +0000 Subject: [PATCH] Do not fail the request in OidcClient filters if OidcClient is disabled --- .../filter/runtime/AbstractOidcClientRequestFilter.java | 4 ++-- .../runtime/AbstractOidcClientRequestReactiveFilter.java | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/runtime/AbstractOidcClientRequestFilter.java b/extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/runtime/AbstractOidcClientRequestFilter.java index 5b2a0f25f67ac..458fa15740778 100644 --- a/extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/runtime/AbstractOidcClientRequestFilter.java +++ b/extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/runtime/AbstractOidcClientRequestFilter.java @@ -25,8 +25,8 @@ public void filter(ClientRequestContext requestContext) throws IOException { final String accessToken = getAccessToken(); requestContext.getHeaders().add(HttpHeaders.AUTHORIZATION, BEARER_SCHEME_WITH_SPACE + accessToken); } catch (DisabledOidcClientException ex) { - LOG.debug("Client is disabled, aborting the request"); - throw ex; + LOG.debug("Client is disabled, acquiring and propagating the token is not necessary"); + return; } catch (Exception ex) { LOG.debugf("Access token is not available, cause: %s, aborting the request", ex.getMessage()); throw (ex instanceof RuntimeException) ? (RuntimeException) ex : new RuntimeException(ex); diff --git a/extensions/oidc-client-reactive-filter/runtime/src/main/java/io/quarkus/oidc/client/reactive/filter/runtime/AbstractOidcClientRequestReactiveFilter.java b/extensions/oidc-client-reactive-filter/runtime/src/main/java/io/quarkus/oidc/client/reactive/filter/runtime/AbstractOidcClientRequestReactiveFilter.java index 9c266fb892baf..5bff7d719403d 100644 --- a/extensions/oidc-client-reactive-filter/runtime/src/main/java/io/quarkus/oidc/client/reactive/filter/runtime/AbstractOidcClientRequestReactiveFilter.java +++ b/extensions/oidc-client-reactive-filter/runtime/src/main/java/io/quarkus/oidc/client/reactive/filter/runtime/AbstractOidcClientRequestReactiveFilter.java @@ -39,11 +39,12 @@ public void accept(Tokens tokens) { @Override public void accept(Throwable t) { if (t instanceof DisabledOidcClientException) { - LOG.debug("Client is disabled, aborting the request"); + LOG.debug("Client is disabled, acquiring and propagating the token is not necessary"); + requestContext.resume(); } else { LOG.debugf("Access token is not available, cause: %s, aborting the request", t.getMessage()); + requestContext.resume((t instanceof RuntimeException) ? t : new RuntimeException(t)); } - requestContext.resume((t instanceof RuntimeException) ? t : new RuntimeException(t)); } }); }