KEYCLOAK-255 Added tmp redirect to admin/index.html as work-around to WildFly issue

This commit is contained in:
Stian Thorgersen 2014-01-13 11:27:02 +00:00
parent 90f125b03a
commit 739866de0c
3 changed files with 38 additions and 0 deletions

View file

@ -21,6 +21,11 @@
<async-supported>true</async-supported>
</servlet>
<servlet>
<servlet-name>TmpAdminRedirectServlet</servlet-name>
<servlet-class>org.keycloak.services.tmp.TmpAdminRedirectServlet</servlet-class>
</servlet>
<listener>
<listener-class>org.keycloak.services.listeners.KeycloakSessionDestroyListener</listener-class>
</listener>
@ -44,6 +49,12 @@
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TmpAdminRedirectServlet</servlet-name>
<url-pattern>/admin</url-pattern>
<url-pattern>/admin/</url-pattern>
</servlet-mapping>
<!--
<security-constraint>

View file

@ -0,0 +1,21 @@
package org.keycloak.services.tmp;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* TODO Remove once fixed in WildFly (https://issues.jboss.org/browse/WFLY-2687)
*
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
*/
public class TmpAdminRedirectServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.sendRedirect(req.getContextPath() + "/admin/index.html");
}
}

View file

@ -33,9 +33,11 @@ import io.undertow.servlet.Servlets;
import io.undertow.servlet.api.DefaultServletConfig;
import io.undertow.servlet.api.DeploymentInfo;
import io.undertow.servlet.api.FilterInfo;
import io.undertow.servlet.api.ServletInfo;
import org.jboss.resteasy.logging.Logger;
import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer;
import org.jboss.resteasy.spi.ResteasyDeployment;
import org.keycloak.services.tmp.TmpAdminRedirectServlet;
import org.keycloak.util.JsonSerialization;
import org.keycloak.models.Constants;
import org.keycloak.models.KeycloakSession;
@ -259,6 +261,10 @@ public class KeycloakServer {
di.addFilter(filter);
di.addFilterUrlMapping("SessionFilter", "/rest/*", DispatcherType.REQUEST);
ServletInfo tmpAdminRedirectServlet = Servlets.servlet("TmpAdminRedirectServlet", TmpAdminRedirectServlet.class);
tmpAdminRedirectServlet.addMappings("/admin", "/admin/");
di.addServlet(tmpAdminRedirectServlet);
server.deploy(di);
factory = KeycloakApplication.createSessionFactory();