keycloak-aplcache

Details

diff --git a/services/src/main/java/org/keycloak/protocol/oidc/utils/RedirectUtils.java b/services/src/main/java/org/keycloak/protocol/oidc/utils/RedirectUtils.java
index 0db1ddb..780f9a3 100644
--- a/services/src/main/java/org/keycloak/protocol/oidc/utils/RedirectUtils.java
+++ b/services/src/main/java/org/keycloak/protocol/oidc/utils/RedirectUtils.java
@@ -108,7 +108,7 @@ public class RedirectUtils {
     }
 
     private static String relativeToAbsoluteURI(UriInfo uriInfo, String rootUrl, String relative) {
-        if (rootUrl == null) {
+        if (rootUrl == null || rootUrl.isEmpty()) {
             URI baseUri = uriInfo.getBaseUri();
             String uri = baseUri.getScheme() + "://" + baseUri.getHost();
             if (baseUri.getPort() != -1) {
diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/oauth/OAuthRedirectUriTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/oauth/OAuthRedirectUriTest.java
index 7c5c253..b1bc5b3 100755
--- a/testsuite/integration/src/test/java/org/keycloak/testsuite/oauth/OAuthRedirectUriTest.java
+++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/oauth/OAuthRedirectUriTest.java
@@ -74,6 +74,18 @@ public class OAuthRedirectUriTest {
             installedApp4.addRedirectUri("http://with-dash.example.com");
             installedApp4.addRedirectUri("http://with-dash.example.com/foo");
             installedApp4.setSecret("password");
+
+            ClientModel installedApp5 = KeycloakModelUtils.createClient(appRealm, "test-root-url");
+            installedApp5.setEnabled(true);
+            installedApp5.setRootUrl("http://with-dash.example.com");
+            installedApp5.addRedirectUri("/foo");
+            installedApp5.setSecret("password");
+
+            ClientModel installedApp6 = KeycloakModelUtils.createClient(appRealm, "test-relative-url");
+            installedApp6.setEnabled(true);
+            installedApp6.setRootUrl("");
+            installedApp6.addRedirectUri("/foo");
+            installedApp6.setSecret("password");
         }
     });
 
@@ -253,6 +265,22 @@ public class OAuthRedirectUriTest {
     }
 
     @Test
+    public void testRelativeWithRoot() throws IOException {
+        oauth.clientId("test-root-url");
+
+        checkRedirectUri("http://with-dash.example.com/foo", true);
+        checkRedirectUri("http://localhost:8081/foo", false);
+    }
+
+    @Test
+    public void testRelative() throws IOException {
+        oauth.clientId("test-relative-url");
+
+        checkRedirectUri("http://with-dash.example.com/foo", false);
+        checkRedirectUri("http://localhost:8081/foo", true);
+    }
+
+    @Test
     public void testLocalhost() throws IOException {
         oauth.clientId("test-installed");