Change admin console to load keycloak.js using a relative URL (#11109)

* Change admin console to load keycloak.js using a relative URL

Closes #11108

* fix tests

Co-authored-by: Dominik Guhr <dguhr@redhat.com>
This commit is contained in:
Stian Thorgersen 2022-04-06 09:35:26 +02:00 committed by GitHub
parent 235f0f3963
commit 7c64f28934
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 3 deletions

View file

@ -68,7 +68,7 @@ public class ProxyDistTest {
given().header("X-Forwarded-Host", "test").when().get("http://mykeycloak.127.0.0.1.nip.io:8080").then().body(containsString("http://test:8080/admin"));
given().header("X-Forwarded-Host", "test").when().get("http://localhost:8080").then().body(containsString("http://test:8080/admin"));
given().header("X-Forwarded-Host", "test").when().get("https://localhost:8443").then().body(containsString("https://test:8443/admin"));
given().header("X-Forwarded-Host", "mykeycloak.127.0.0.1.nip.io").when().get("https://localhost:8443/admin/master/console").then().body(containsString("<script src=\"https://mykeycloak.127.0.0.1.nip.io:8443/js/keycloak.js"));
given().header("X-Forwarded-Host", "mykeycloak.127.0.0.1.nip.io").when().get("https://localhost:8443/admin/master/console").then().body(containsString("<script src=\"/js/keycloak.js?version="));
given().header("X-Forwarded-Proto", "https").when().get("http://localhost:8080").then().body(containsString("https://localhost/admin"));
given().header("X-Forwarded-Proto", "https").header("X-Forwarded-Port", "8443").when().get("http://localhost:8080").then().body(containsString("https://localhost:8443/admin"));
}

View file

@ -339,6 +339,7 @@ public class AdminConsole {
map.put("consoleBaseUrl", Urls.adminConsoleRoot(adminBaseUri, realm.getName()).getPath());
map.put("resourceUrl", Urls.themeRoot(adminBaseUri).getPath() + "/admin/" + theme.getName());
map.put("resourceCommonUrl", Urls.themeRoot(adminBaseUri).getPath() + "/common/keycloak");
map.put("keycloakJsUrl", adminBaseUri.getPath() + "js/keycloak.js?version=" + Version.RESOURCES_VERSION);
map.put("masterRealm", Config.getAdminRealm());
map.put("resourceVersion", Version.RESOURCES_VERSION);
map.put("loginRealm", realm.getName());

View file

@ -70,7 +70,7 @@ public class AdminConsoleLandingPageTest extends AbstractKeycloakTest {
while(m.find()) {
String url = m.group(1);
if (url.contains("keycloak.js")) {
Assert.assertTrue(url, url.startsWith(suiteContext.getAuthServerInfo().getContextRoot() + "/auth/js/"));
Assert.assertTrue(url, url.startsWith("/auth/js/"));
} else {
Assert.assertTrue(url, url.startsWith("/auth/resources/"));
}

View file

@ -48,7 +48,7 @@
<script src="${resourceCommonUrl}/lib/ui-ace/min/ace.js"></script>
<script src="${resourceCommonUrl}/lib/ui-ace/ui-ace.min.js"></script>
<script src="${authUrl}/js/keycloak.js?version=${resourceVersion}" type="text/javascript"></script>
<script src="${keycloakJsUrl}" type="text/javascript"></script>
<script src="${resourceUrl}/js/app.js" type="text/javascript"></script>
<script src="${resourceUrl}/js/controllers/realm.js" type="text/javascript"></script>