From 40b4739553fac21361ebe02314c57f316310784f Mon Sep 17 00:00:00 2001 From: Sergey Beryozkin Date: Mon, 18 Sep 2023 11:54:28 +0100 Subject: [PATCH] Improve the way HTTP authorizer logs exceptions --- .../http/runtime/security/AbstractHttpAuthorizer.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/AbstractHttpAuthorizer.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/AbstractHttpAuthorizer.java index fd194a02b9a77..d41f6e5fd9819 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/AbstractHttpAuthorizer.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/AbstractHttpAuthorizer.java @@ -10,6 +10,7 @@ import org.jboss.logging.Logger; import io.quarkus.security.AuthenticationFailedException; +import io.quarkus.security.AuthenticationRedirectException; import io.quarkus.security.ForbiddenException; import io.quarkus.security.identity.IdentityProviderManager; import io.quarkus.security.identity.SecurityIdentity; @@ -120,10 +121,15 @@ public void accept(Throwable throwable) { // the exception twice;at this point, the exception could be failed by the default auth failure handler if (!routingContext.response().ended() && !throwable.equals(routingContext.failure())) { routingContext.fail(throwable); - } else if (!(throwable instanceof AuthenticationFailedException)) { - //don't log auth failure + } else if (throwable instanceof AuthenticationFailedException) { + log.debug("Authentication challenge is required"); + } else if (throwable instanceof AuthenticationRedirectException) { + log.debugf("Completing authentication with a redirect to %s", + ((AuthenticationRedirectException) throwable).getRedirectUri()); + } else { log.error("Exception occurred during authorization", throwable); } + } }); }