Separated the error message for Bearer token and Basic authentication failures.
This commit is contained in:
parent
b3f142d715
commit
3a4897c7d2
1 changed files with 7 additions and 2 deletions
|
@ -188,9 +188,14 @@ public class KeycloakAuthenticationProcessingFilter extends AbstractAuthenticati
|
||||||
protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response,
|
protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response,
|
||||||
AuthenticationException failed) throws IOException, ServletException {
|
AuthenticationException failed) throws IOException, ServletException {
|
||||||
|
|
||||||
if (this.isBearerTokenRequest(request) || this.isBasicAuthRequest(request)) {
|
if (this.isBearerTokenRequest(request)) {
|
||||||
SecurityContextHolder.clearContext();
|
SecurityContextHolder.clearContext();
|
||||||
response.sendError(HttpServletResponse.SC_FORBIDDEN, "Unable to authenticate bearer token/basic authentication");
|
response.sendError(HttpServletResponse.SC_FORBIDDEN, "Unable to authenticate bearer token");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (this.isBasicAuthRequest(request)) {
|
||||||
|
SecurityContextHolder.clearContext();
|
||||||
|
response.sendError(HttpServletResponse.SC_FORBIDDEN, "Unable to authenticate with basic authentication");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue