Skip to content

Commit

Permalink
Fail gracefully on invalid token strings (elastic#51014)
Browse files Browse the repository at this point in the history
When we receive a request with an Authorization header that contains
a Bearer token that is not generated by us or that is malformed in
some way, attempting to decode it as one of our own might cause a
number of exceptions that are not IOExceptions. This commit ensures
that we catch and log these too and call onResponse with `null, so
that we can return 401 instead of 500.

Resolves: elastic#50497
  • Loading branch information
jkakavas committed Jan 16, 2020
1 parent 67d8fdb commit 295ca50
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ void decodeToken(String token, ActionListener<UserToken> listener) {
listener.onResponse(null);
}
}
} catch (IOException e) {
} catch (Exception e) {
// could happen with a token that is not ours
if (logger.isDebugEnabled()) {
logger.debug("built in token service unable to decode token", e);
Expand Down

0 comments on commit 295ca50

Please sign in to comment.