Skip to content

Commit b374c48

Browse files
authored
More debug logging in realms authenticator (elastic#124342)
This PR adds debug logging to the realms authenticator, for exceptions around request processing.
1 parent a15aee6 commit b374c48

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/RealmsAuthenticator.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,14 @@ private void consumeToken(Context context, ActionListener<AuthenticationResult<A
252252
listener.onFailure(context.getRequest().authenticationFailed(authenticationToken));
253253
} else {
254254
assert e instanceof AuthenticationTerminatedSuccessfullyException == false : e;
255+
logger.debug(
256+
() -> format(
257+
"An error occurred while attempting to authenticate [%s] with token of type [%s]",
258+
authenticationToken.principal(),
259+
authenticationToken.getClass().getName()
260+
),
261+
e
262+
);
255263
listener.onFailure(context.getRequest().exceptionProcessingRequest(e, authenticationToken));
256264
}
257265
}), context.getThreadContext()),
@@ -264,7 +272,7 @@ private void consumeToken(Context context, ActionListener<AuthenticationResult<A
264272
} catch (Exception e) {
265273
logger.debug(
266274
() -> format(
267-
"Authentication of [%s] with token [%s] failed",
275+
"Authentication of [%s] with token of type [%s] failed",
268276
authenticationToken.principal(),
269277
authenticationToken.getClass().getName()
270278
),
@@ -347,7 +355,17 @@ public void lookupRunAsUser(Context context, Authentication authentication, Acti
347355
);
348356
listener.onResponse(tuple);
349357
}
350-
}, e -> listener.onFailure(context.getRequest().exceptionProcessingRequest(e, context.getMostRecentAuthenticationToken()))));
358+
}, e -> {
359+
logger.debug(
360+
() -> format(
361+
"An error occurred while looking up run-as user [%s] for authenticated user [%s]",
362+
runAsUsername,
363+
authentication.getAuthenticatingSubject().getUser().principal()
364+
),
365+
e
366+
);
367+
listener.onFailure(context.getRequest().exceptionProcessingRequest(e, context.getMostRecentAuthenticationToken()));
368+
}));
351369
} else if (runAsUsername == null) {
352370
listener.onResponse(null);
353371
} else {

0 commit comments

Comments
 (0)