From 375e01a0741dceb606c2ccb6cb18220867027c5b Mon Sep 17 00:00:00 2001 From: Bruno Oliveira da Silva Date: Wed, 25 Oct 2017 11:27:24 -0200 Subject: [PATCH] KEYCLOAK-5278 (#4606) --- .../org/keycloak/authentication/AuthenticationProcessor.java | 4 ++-- .../org/keycloak/authentication/ClientAuthenticationFlow.java | 2 +- .../org/keycloak/testsuite/oauth/ClientAuthSignedJWTTest.java | 2 +- .../java/org/keycloak/testsuite/oauth/RefreshTokenTest.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/services/src/main/java/org/keycloak/authentication/AuthenticationProcessor.java b/services/src/main/java/org/keycloak/authentication/AuthenticationProcessor.java index c7a8edee44..1c639a6ed7 100755 --- a/services/src/main/java/org/keycloak/authentication/AuthenticationProcessor.java +++ b/services/src/main/java/org/keycloak/authentication/AuthenticationProcessor.java @@ -672,10 +672,10 @@ public class AuthenticationProcessor { ServicesLogger.LOGGER.failedClientAuthentication(e); if (e.getError() == AuthenticationFlowError.CLIENT_NOT_FOUND) { event.error(Errors.CLIENT_NOT_FOUND); - return ClientAuthUtil.errorResponse(Response.Status.BAD_REQUEST.getStatusCode(), "invalid_client", "Could not find client"); + return ClientAuthUtil.errorResponse(Response.Status.BAD_REQUEST.getStatusCode(), "unauthorized_client", "Invalid client credentials"); } else if (e.getError() == AuthenticationFlowError.CLIENT_DISABLED) { event.error(Errors.CLIENT_DISABLED); - return ClientAuthUtil.errorResponse(Response.Status.BAD_REQUEST.getStatusCode(), "invalid_client", "Client is not enabled"); + return ClientAuthUtil.errorResponse(Response.Status.BAD_REQUEST.getStatusCode(), "unauthorized_client", "Invalid client credentials"); } else if (e.getError() == AuthenticationFlowError.CLIENT_CREDENTIALS_SETUP_REQUIRED) { event.error(Errors.INVALID_CLIENT_CREDENTIALS); return ClientAuthUtil.errorResponse(Response.Status.BAD_REQUEST.getStatusCode(), "unauthorized_client", e.getMessage()); diff --git a/services/src/main/java/org/keycloak/authentication/ClientAuthenticationFlow.java b/services/src/main/java/org/keycloak/authentication/ClientAuthenticationFlow.java index 0cac336cd9..044f4a5406 100755 --- a/services/src/main/java/org/keycloak/authentication/ClientAuthenticationFlow.java +++ b/services/src/main/java/org/keycloak/authentication/ClientAuthenticationFlow.java @@ -98,7 +98,7 @@ public class ClientAuthenticationFlow implements AuthenticationFlow { processor.getEvent().error(Errors.INVALID_CLIENT); return alternativeChallenge; } - throw new AuthenticationFlowException("Client was not identified by any client authenticator", AuthenticationFlowError.UNKNOWN_CLIENT); + throw new AuthenticationFlowException("Invalid client credentials", AuthenticationFlowError.INVALID_CREDENTIALS); } protected List findExecutionsToRun() { diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oauth/ClientAuthSignedJWTTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oauth/ClientAuthSignedJWTTest.java index bcfae6f083..4a748296e1 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oauth/ClientAuthSignedJWTTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oauth/ClientAuthSignedJWTTest.java @@ -536,7 +536,7 @@ public class ClientAuthSignedJWTTest extends AbstractKeycloakTest { CloseableHttpResponse resp = sendRequest(oauth.getServiceAccountUrl(), parameters); OAuthClient.AccessTokenResponse response = new OAuthClient.AccessTokenResponse(resp); - assertError(response, "client1", "invalid_client", Errors.CLIENT_DISABLED); + assertError(response, "client1", "unauthorized_client", Errors.CLIENT_DISABLED); ClientManager.realm(adminClient.realm("test")).clientId("client1").enabled(true); } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oauth/RefreshTokenTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oauth/RefreshTokenTest.java index ffb9bc8480..c8b320d18d 100755 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oauth/RefreshTokenTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oauth/RefreshTokenTest.java @@ -482,7 +482,7 @@ public class RefreshTokenTest extends AbstractKeycloakTest { response = oauth.doRefreshTokenRequest(refreshTokenString, "password"); assertEquals(400, response.getStatusCode()); - assertEquals("invalid_client", response.getError()); + assertEquals("unauthorized_client", response.getError()); events.expectRefresh(refreshToken.getId(), sessionId).user((String) null).session((String) null).clearDetails().error(Errors.CLIENT_DISABLED).assertEvent(); } finally {