diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider-social.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider-social.html
index 3e33cc6a8e..d0aadec88a 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider-social.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider-social.html
@@ -1,4 +1,4 @@
-
+
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider-twitter.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider-twitter.html
index d565cfb7eb..a4630ac786 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider-twitter.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider-twitter.html
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider.html
index 175b8cb71f..ab7cfa46a9 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider.html
@@ -1,4 +1,4 @@
-
+
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-keys.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-keys.html
index 52ccfcae6d..ccccbaec68 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-keys.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-keys.html
@@ -1,4 +1,4 @@
-
+
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-login-settings.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-login-settings.html
index ff318b0c88..bd1bab9f84 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-login-settings.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-login-settings.html
@@ -1,4 +1,4 @@
-
+
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-smtp.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-smtp.html
index f19e3c40da..fdbc33e109 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-smtp.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-smtp.html
@@ -1,4 +1,4 @@
-
+
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-theme-settings.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-theme-settings.html
index 2e6f1f7aad..c08d5f9d43 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-theme-settings.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-theme-settings.html
@@ -1,4 +1,4 @@
-
+
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-tokens.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-tokens.html
index b2833c9466..c322bf2c54 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-tokens.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-tokens.html
@@ -1,4 +1,4 @@
-
+
- Realm Sessions
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/role-detail.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/role-detail.html
index 06fa783fbc..299b6989d4 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/role-detail.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/role-detail.html
@@ -1,4 +1,4 @@
-
+
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/role-list.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/role-list.html
index 74a8670874..17879ca7ba 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/role-list.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/role-list.html
@@ -1,4 +1,4 @@
-
+
- Realm Roles
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/role-mappings.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/role-mappings.html
index 6a07ca73af..0ae08be374 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/role-mappings.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/role-mappings.html
@@ -1,4 +1,4 @@
-
+
- Attributes
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/session-realm.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/session-realm.html
index 8730395b7b..1394703e15 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/session-realm.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/session-realm.html
@@ -1,4 +1,4 @@
-
+
- Realm Sessions
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/session-revocation.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/session-revocation.html
index 866c6fbe2a..c87af7f9ae 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/session-revocation.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/session-revocation.html
@@ -1,4 +1,4 @@
-
+
- Realm Sessions
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-credentials.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-credentials.html
index 0efd271938..8ca73a6e40 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-credentials.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-credentials.html
@@ -1,4 +1,4 @@
-
+
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-detail.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-detail.html
index 5e770a882c..8ed77b74a0 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-detail.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-detail.html
@@ -1,4 +1,4 @@
-
+
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federated-identity.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federated-identity.html
index 845be1f428..70a2691f00 100644
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federated-identity.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federated-identity.html
@@ -1,4 +1,4 @@
-
+
- Attributes
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federation.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federation.html
index 0d7e4c6a59..d81ef0cdb5 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federation.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federation.html
@@ -1,4 +1,4 @@
-
+
- User List
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-list.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-list.html
index 3fdd481ced..df5006727f 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-list.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-list.html
@@ -1,4 +1,4 @@
-
+
- User List
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-sessions.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-sessions.html
index a2a8ee09d4..f3de7e404d 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-sessions.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-sessions.html
@@ -1,4 +1,4 @@
-
+
- Attributes
diff --git a/services/src/main/java/org/keycloak/services/resources/ThemeResource.java b/services/src/main/java/org/keycloak/services/resources/ThemeResource.java
index 2021ed8a4d..488774d275 100755
--- a/services/src/main/java/org/keycloak/services/resources/ThemeResource.java
+++ b/services/src/main/java/org/keycloak/services/resources/ThemeResource.java
@@ -20,7 +20,7 @@ import java.io.InputStream;
*
* @author Stian Thorgersen
*/
-@Path("/theme")
+@Path("/resources")
public class ThemeResource {
private static final Logger logger = Logger.getLogger(ThemeResource.class);
@@ -37,7 +37,7 @@ public class ThemeResource {
* @return
*/
@GET
- @Path("/{themeType}/{themeName}/{path:.*}")
+ @Path("/{version}/{themeType}/{themeName}/{path:.*}")
public Response getResource(@PathParam("themeType") String themType, @PathParam("themeName") String themeName, @PathParam("path") String path) {
try {
ThemeProvider themeProvider = session.getProvider(ThemeProvider.class, "extending");
diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java b/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java
index 7b4c1c93a3..ff6e0fcbfa 100755
--- a/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java
+++ b/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java
@@ -9,6 +9,8 @@ import org.jboss.resteasy.spi.NotFoundException;
import org.keycloak.ClientConnection;
import org.keycloak.Config;
import org.keycloak.freemarker.BrowserSecurityHeaderSetup;
+import org.keycloak.freemarker.FreeMarkerException;
+import org.keycloak.freemarker.FreeMarkerUtil;
import org.keycloak.freemarker.Theme;
import org.keycloak.freemarker.ThemeProvider;
import org.keycloak.models.AdminRoles;
@@ -24,6 +26,7 @@ import org.keycloak.services.managers.ApplicationManager;
import org.keycloak.services.managers.AuthenticationManager;
import org.keycloak.services.managers.RealmManager;
import org.keycloak.services.resources.KeycloakApplication;
+import org.keycloak.services.resources.flows.Urls;
import org.keycloak.util.MimeTypeUtil;
import javax.ws.rs.GET;
@@ -33,9 +36,11 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.CacheControl;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.ext.Providers;
+import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
@@ -248,7 +253,7 @@ public class AdminConsole {
@GET
@NoCache
public Response logout() {
- URI redirect = AdminRoot.adminConsoleUrl(uriInfo).path("index.html").build(realm.getName());
+ URI redirect = AdminRoot.adminConsoleUrl(uriInfo).build(realm.getName());
return Response.status(302).location(
OIDCLoginProtocolService.logoutUrl(uriInfo).queryParam("redirect_uri", redirect.toString()).build(realm.getName())
@@ -266,72 +271,41 @@ public class AdminConsole {
* @throws URISyntaxException
*/
@GET
- public Response getMainPage() throws URISyntaxException {
+ @NoCache
+ public Response getMainPage() throws URISyntaxException, IOException, FreeMarkerException {
if (!uriInfo.getRequestUri().getPath().endsWith("/")) {
return Response.status(302).location(uriInfo.getRequestUriBuilder().path("/").build()).build();
} else {
- return getResource("index.html");
- }
- }
+ String adminTheme = realm.getAdminTheme();
+ if (adminTheme == null) {
+ adminTheme = "keycloak";
+ }
- /**
- * Javascript used by admin console
- *
- * @return
- */
- @GET
- @Path("js/keycloak.js")
- @Produces("text/javascript")
- public Response getKeycloakJs() {
- InputStream inputStream = getClass().getClassLoader().getResourceAsStream("keycloak.js");
- if (inputStream != null) {
- CacheControl cacheControl = new CacheControl();
- cacheControl.setNoTransform(false);
- cacheControl.setMaxAge(Config.scope("theme").getInt("staticMaxAge", -1));
+ Map map = new HashMap();
- return Response.ok(inputStream).type("text/javascript").cacheControl(cacheControl).build();
- } else {
- return Response.status(Response.Status.NOT_FOUND).build();
- }
- }
+ URI baseUri = uriInfo.getBaseUri();
- /**
- * Theme resources for this realm's admin console. (images, html files, etc..)
- *
- * @param path
- * @return
- */
- @GET
- @Path("{path:.+}")
- public Response getResource(@PathParam("path") String path) {
- // todo
- // I don't know why I need this. On IE 11, if I don't have this, getKeycloakJs() isn't invoked
- // I just can't figure out what the difference is between IE11 and FF for console/js/keycloak.js calls
- if (path.equals("js/keycloak.js")) {
- return getKeycloakJs();
- }
+ String authUrl = baseUri.toString();
+ authUrl = authUrl.substring(0, authUrl.length() - 1);
+
+ map.put("authUrl", authUrl);
+ map.put("resourceUrl", Urls.themeRoot(baseUri) + "/admin/" + adminTheme);
- try {
ThemeProvider themeProvider = session.getProvider(ThemeProvider.class, "extending");
Theme theme = themeProvider.getTheme(realm.getAdminTheme(), Theme.Type.ADMIN);
- InputStream resource = theme.getResourceAsStream(path);
- if (resource != null) {
- String contentType = MimeTypeUtil.getContentType(path);
- CacheControl cacheControl = new CacheControl();
- cacheControl.setNoTransform(false);
- cacheControl.setMaxAge(Config.scope("theme").getInt("staticMaxAge", -1));
-
- Response.ResponseBuilder builder = Response.ok(resource).type(contentType).cacheControl(cacheControl);
- BrowserSecurityHeaderSetup.headers(builder, realm);
- return builder.build();
- } else {
- return Response.status(Response.Status.NOT_FOUND).build();
- }
- } catch (Exception e) {
- logger.warn("Failed to get theme resource", e);
- return Response.serverError().build();
+ FreeMarkerUtil freeMarkerUtil = new FreeMarkerUtil();
+ String result = freeMarkerUtil.processTemplate(map, "index.ftl", theme);
+ Response.ResponseBuilder builder = Response.status(Response.Status.OK).type(MediaType.TEXT_HTML).entity(result);
+ BrowserSecurityHeaderSetup.headers(builder, realm);
+ return builder.build();
}
}
+ @GET
+ @Path("index.html")
+ public Response getIndexHtmlRedirect() {
+ return Response.status(302).location(uriInfo.getRequestUriBuilder().path("../").build()).build();
+ }
+
}
diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ServerInfoAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ServerInfoAdminResource.java
index 2ac929ded4..6952e88472 100755
--- a/services/src/main/java/org/keycloak/services/resources/admin/ServerInfoAdminResource.java
+++ b/services/src/main/java/org/keycloak/services/resources/admin/ServerInfoAdminResource.java
@@ -1,5 +1,6 @@
package org.keycloak.services.resources.admin;
+import org.jboss.resteasy.annotations.cache.Cache;
import org.keycloak.Version;
import org.keycloak.broker.provider.IdentityProvider;
import org.keycloak.broker.provider.IdentityProviderFactory;
diff --git a/services/src/main/java/org/keycloak/services/resources/flows/Urls.java b/services/src/main/java/org/keycloak/services/resources/flows/Urls.java
index 2eb1ed4315..7889388fc9 100755
--- a/services/src/main/java/org/keycloak/services/resources/flows/Urls.java
+++ b/services/src/main/java/org/keycloak/services/resources/flows/Urls.java
@@ -22,6 +22,7 @@
package org.keycloak.services.resources.flows;
import org.keycloak.OAuth2Constants;
+import org.keycloak.Version;
import org.keycloak.protocol.oidc.OIDCLoginProtocol;
import org.keycloak.protocol.oidc.OIDCLoginProtocolService;
import org.keycloak.services.resources.AccountService;
@@ -190,7 +191,7 @@ public class Urls {
}
public static URI themeRoot(URI baseUri) {
- return themeBase(baseUri).build();
+ return themeBase(baseUri).path(Version.RESOURCES_VERSION).build();
}
private static UriBuilder requiredActionsBase(URI baseUri) {