diff --git a/docbook/auth-server-docs/reference/en/en-US/modules/clients.xml b/docbook/auth-server-docs/reference/en/en-US/modules/clients.xml index 2d15ad062b..7be201971c 100644 --- a/docbook/auth-server-docs/reference/en/en-US/modules/clients.xml +++ b/docbook/auth-server-docs/reference/en/en-US/modules/clients.xml @@ -19,13 +19,13 @@ Clients - Keycloak provides support for managing OAuth clients. + Keycloak provides support for managing Clients.
Client Config - Keycloak supports flexible configuration of OAuth Clients. + Keycloak supports flexible configuration of Clients.
diff --git a/services/src/main/java/org/keycloak/services/resources/RealmsResource.java b/services/src/main/java/org/keycloak/services/resources/RealmsResource.java index a47f2ab922..43916e7530 100755 --- a/services/src/main/java/org/keycloak/services/resources/RealmsResource.java +++ b/services/src/main/java/org/keycloak/services/resources/RealmsResource.java @@ -116,7 +116,7 @@ public class RealmsResource { * @param realmName * @param clientId * @return - * @since 1.9 + * @since 2.0 */ @GET @Path("{realm}/clients/{client_id}/redirect") @@ -134,14 +134,19 @@ public class RealmsResource { return null; } - if (client.getRootUrl() == null) { - - URI targetUri = KeycloakUriBuilder.fromUri(ResolveRelative.resolveRelativeUri(uriInfo.getRequestUri(), client.getRootUrl(), client.getBaseUrl())).build(); - - return Response.temporaryRedirect(targetUri).build(); + if (client.getRootUrl() == null && client.getBaseUrl() == null) { + return null; } - return Response.temporaryRedirect(URI.create(client.getRootUrl() + client.getBaseUrl())).build(); + + URI targetUri; + if (client.getRootUrl() != null && (client.getBaseUrl() == null || client.getBaseUrl().isEmpty())) { + targetUri = KeycloakUriBuilder.fromUri(client.getRootUrl()).build(); + } else { + targetUri = KeycloakUriBuilder.fromUri(ResolveRelative.resolveRelativeUri(uriInfo.getRequestUri(), client.getRootUrl(), client.getBaseUrl())).build(); + } + + return Response.temporaryRedirect(targetUri).build(); } @Path("{realm}/login-actions") diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/RealmResourceTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/ClientRedirectTest.java similarity index 98% rename from testsuite/integration/src/test/java/org/keycloak/testsuite/RealmResourceTest.java rename to testsuite/integration/src/test/java/org/keycloak/testsuite/ClientRedirectTest.java index caa293016c..3c75cf6126 100644 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/RealmResourceTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/ClientRedirectTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertEquals; /** * @author Thomas Darimont */ -public class RealmResourceTest { +public class ClientRedirectTest { @ClassRule public static KeycloakRule keycloakRule = new KeycloakRule(new KeycloakSetup() {