From 3cc405b1c582c1e512cfa76922200d7b7e21254e Mon Sep 17 00:00:00 2001 From: vramik Date: Thu, 7 Mar 2019 09:18:29 +0100 Subject: [PATCH] KEYCLOAK-8542 Remove resteasy workaround - KeycloakStringEntityFilter --- .../main/server-war/WEB-INF/web.xml | 5 +++ .../filters/KeycloakStringEntityFilter.java | 45 ------------------- .../resources/KeycloakApplication.java | 5 --- .../undertow/KeycloakOnUndertow.java | 4 ++ .../integration-arquillian/tests/pom.xml | 2 + 5 files changed, 11 insertions(+), 50 deletions(-) delete mode 100644 services/src/main/java/org/keycloak/services/filters/KeycloakStringEntityFilter.java diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/keycloak/org/keycloak/keycloak-server-subsystem/main/server-war/WEB-INF/web.xml b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/keycloak/org/keycloak/keycloak-server-subsystem/main/server-war/WEB-INF/web.xml index 4a85d38417..fc904903a8 100755 --- a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/keycloak/org/keycloak/keycloak-server-subsystem/main/server-war/WEB-INF/web.xml +++ b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/keycloak/org/keycloak/keycloak-server-subsystem/main/server-war/WEB-INF/web.xml @@ -38,6 +38,11 @@ true + + resteasy.disable.html.sanitizer + true + + org.keycloak.services.listeners.KeycloakSessionDestroyListener diff --git a/services/src/main/java/org/keycloak/services/filters/KeycloakStringEntityFilter.java b/services/src/main/java/org/keycloak/services/filters/KeycloakStringEntityFilter.java deleted file mode 100644 index a39d3ed8aa..0000000000 --- a/services/src/main/java/org/keycloak/services/filters/KeycloakStringEntityFilter.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2017 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.keycloak.services.filters; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; - -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.container.ContainerResponseContext; -import javax.ws.rs.container.ContainerResponseFilter; - -/** - * Workaround for KEYCLOAK-8461 - * - * @author Marek Posolda - */ -public class KeycloakStringEntityFilter implements ContainerResponseFilter { - - @Override - public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { - if (responseContext.getStatus() == 400 && responseContext.hasEntity()) { - Object entity = responseContext.getEntity(); - if (entity instanceof String) { - // Need to convert String to bytes, so that RestEasy won't escape it - responseContext.setEntity(responseContext.getEntity().toString().getBytes(StandardCharsets.UTF_8)); - } - } - } - -} diff --git a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java index 23d42852ae..cd6daf56c3 100644 --- a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java +++ b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java @@ -43,7 +43,6 @@ import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.services.DefaultKeycloakSessionFactory; import org.keycloak.services.ServicesLogger; import org.keycloak.services.error.KeycloakErrorHandler; -import org.keycloak.services.filters.KeycloakStringEntityFilter; import org.keycloak.services.filters.KeycloakTransactionCommitter; import org.keycloak.services.managers.ApplianceBootstrap; import org.keycloak.services.managers.RealmManager; @@ -128,10 +127,6 @@ public class KeycloakApplication extends Application { classes.add(JsResource.class); classes.add(KeycloakTransactionCommitter.class); - - // Workaround for KEYCLOAK-8461. TODO: Remove it once corresponding issue is fixed in Wildfly/Resteasy - classes.add(KeycloakStringEntityFilter.class); - classes.add(KeycloakErrorHandler.class); singletons.add(new ObjectMapperResolver(Boolean.parseBoolean(System.getProperty("keycloak.jsonPrettyPrint", "false")))); diff --git a/testsuite/integration-arquillian/servers/auth-server/undertow/src/main/java/org/keycloak/testsuite/arquillian/undertow/KeycloakOnUndertow.java b/testsuite/integration-arquillian/servers/auth-server/undertow/src/main/java/org/keycloak/testsuite/arquillian/undertow/KeycloakOnUndertow.java index 87286ce5cc..30d7491454 100644 --- a/testsuite/integration-arquillian/servers/auth-server/undertow/src/main/java/org/keycloak/testsuite/arquillian/undertow/KeycloakOnUndertow.java +++ b/testsuite/integration-arquillian/servers/auth-server/undertow/src/main/java/org/keycloak/testsuite/arquillian/undertow/KeycloakOnUndertow.java @@ -36,6 +36,7 @@ import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext; import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; import org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet; import org.jboss.logging.Logger; +import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters; import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer; import org.jboss.resteasy.spi.ResteasyDeployment; import org.jboss.shrinkwrap.api.Archive; @@ -78,6 +79,9 @@ public class KeycloakOnUndertow implements DeployableContainerstandalone.xml ${auth.server.home}/standalone/configuration 1.3.173 + -Xms512m -Xmx1024m -XX:MetaspaceSize=96m -XX:MaxMetaspaceSize=256m @@ -667,6 +668,7 @@ standalone.xml ${auth.server.home}/standalone/configuration 1.3.173 + -Xms512m -Xmx1024m -XX:MetaspaceSize=96m -XX:MaxMetaspaceSize=256m