Skip to content

Commit

Permalink
Log all cause exception when authc fails (elastic#111534)
Browse files Browse the repository at this point in the history
In RealmsAuthenticator, if a realm fails to authenticate the token, log
the whole chain of exception causes.
  • Loading branch information
tvernum authored Aug 8, 2024
1 parent 76237b1 commit f02be07
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,16 @@ private static void consumeNullUser(
) {
messages.forEach((realm, tuple) -> {
final String message = tuple.v1();
final String cause = tuple.v2() == null ? "" : " (Caused by " + tuple.v2() + ")";
Throwable ex = tuple.v2();
var cause = new StringBuilder();
while (ex != null) {
cause.append(cause.isEmpty() ? " (" : "; ");
cause.append("Caused by ").append(ex);
ex = ex.getCause();
}
if (cause.isEmpty() == false) {
cause.append(')');
}
logger.warn("Authentication to realm {} failed - {}{}", realm.name(), message, cause);
});
if (context.getUnlicensedRealms().isEmpty() == false) {
Expand Down

0 comments on commit f02be07

Please sign in to comment.