Skip to content

Commit

Permalink
Improve the way HTTP authorizer logs exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
sberyozkin committed Sep 18, 2023
1 parent b1a1196 commit 40b4739
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

}
});
}
Expand Down

0 comments on commit 40b4739

Please sign in to comment.