KEYCLOAK-8542 Remove resteasy workaround - KeycloakStringEntityFilter
This commit is contained in:
parent
a48698caa3
commit
3cc405b1c5
5 changed files with 11 additions and 50 deletions
|
@ -38,6 +38,11 @@
|
||||||
<async-supported>true</async-supported>
|
<async-supported>true</async-supported>
|
||||||
</servlet>
|
</servlet>
|
||||||
|
|
||||||
|
<context-param>
|
||||||
|
<param-name>resteasy.disable.html.sanitizer</param-name>
|
||||||
|
<param-value>true</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
<listener>
|
<listener>
|
||||||
<listener-class>org.keycloak.services.listeners.KeycloakSessionDestroyListener</listener-class>
|
<listener-class>org.keycloak.services.listeners.KeycloakSessionDestroyListener</listener-class>
|
||||||
</listener>
|
</listener>
|
||||||
|
|
|
@ -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 <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
|
||||||
*/
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -43,7 +43,6 @@ import org.keycloak.representations.idm.UserRepresentation;
|
||||||
import org.keycloak.services.DefaultKeycloakSessionFactory;
|
import org.keycloak.services.DefaultKeycloakSessionFactory;
|
||||||
import org.keycloak.services.ServicesLogger;
|
import org.keycloak.services.ServicesLogger;
|
||||||
import org.keycloak.services.error.KeycloakErrorHandler;
|
import org.keycloak.services.error.KeycloakErrorHandler;
|
||||||
import org.keycloak.services.filters.KeycloakStringEntityFilter;
|
|
||||||
import org.keycloak.services.filters.KeycloakTransactionCommitter;
|
import org.keycloak.services.filters.KeycloakTransactionCommitter;
|
||||||
import org.keycloak.services.managers.ApplianceBootstrap;
|
import org.keycloak.services.managers.ApplianceBootstrap;
|
||||||
import org.keycloak.services.managers.RealmManager;
|
import org.keycloak.services.managers.RealmManager;
|
||||||
|
@ -128,10 +127,6 @@ public class KeycloakApplication extends Application {
|
||||||
classes.add(JsResource.class);
|
classes.add(JsResource.class);
|
||||||
|
|
||||||
classes.add(KeycloakTransactionCommitter.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);
|
classes.add(KeycloakErrorHandler.class);
|
||||||
|
|
||||||
singletons.add(new ObjectMapperResolver(Boolean.parseBoolean(System.getProperty("keycloak.jsonPrettyPrint", "false"))));
|
singletons.add(new ObjectMapperResolver(Boolean.parseBoolean(System.getProperty("keycloak.jsonPrettyPrint", "false"))));
|
||||||
|
|
|
@ -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.ProtocolMetaData;
|
||||||
import org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet;
|
import org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet;
|
||||||
import org.jboss.logging.Logger;
|
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.plugins.server.undertow.UndertowJaxrsServer;
|
||||||
import org.jboss.resteasy.spi.ResteasyDeployment;
|
import org.jboss.resteasy.spi.ResteasyDeployment;
|
||||||
import org.jboss.shrinkwrap.api.Archive;
|
import org.jboss.shrinkwrap.api.Archive;
|
||||||
|
@ -78,6 +79,9 @@ public class KeycloakOnUndertow implements DeployableContainer<KeycloakOnUnderto
|
||||||
ResteasyDeployment deployment = new ResteasyDeployment();
|
ResteasyDeployment deployment = new ResteasyDeployment();
|
||||||
deployment.setApplicationClass(KeycloakApplication.class.getName());
|
deployment.setApplicationClass(KeycloakApplication.class.getName());
|
||||||
|
|
||||||
|
// RESTEASY-2034
|
||||||
|
deployment.setProperty(ResteasyContextParameters.RESTEASY_DISABLE_HTML_SANITIZER, true);
|
||||||
|
|
||||||
DeploymentInfo di = undertow.undertowDeployment(deployment);
|
DeploymentInfo di = undertow.undertowDeployment(deployment);
|
||||||
di.setClassLoader(getClass().getClassLoader());
|
di.setClassLoader(getClass().getClassLoader());
|
||||||
di.setContextPath("/auth");
|
di.setContextPath("/auth");
|
||||||
|
|
|
@ -643,6 +643,7 @@
|
||||||
<auth.server.config.property.value>standalone.xml</auth.server.config.property.value>
|
<auth.server.config.property.value>standalone.xml</auth.server.config.property.value>
|
||||||
<auth.server.config.dir>${auth.server.home}/standalone/configuration</auth.server.config.dir>
|
<auth.server.config.dir>${auth.server.home}/standalone/configuration</auth.server.config.dir>
|
||||||
<h2.version>1.3.173</h2.version>
|
<h2.version>1.3.173</h2.version>
|
||||||
|
<surefire.memory.settings>-Xms512m -Xmx1024m -XX:MetaspaceSize=96m -XX:MaxMetaspaceSize=256m</surefire.memory.settings>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -667,6 +668,7 @@
|
||||||
<auth.server.config.property.value>standalone.xml</auth.server.config.property.value>
|
<auth.server.config.property.value>standalone.xml</auth.server.config.property.value>
|
||||||
<auth.server.config.dir>${auth.server.home}/standalone/configuration</auth.server.config.dir>
|
<auth.server.config.dir>${auth.server.home}/standalone/configuration</auth.server.config.dir>
|
||||||
<h2.version>1.3.173</h2.version>
|
<h2.version>1.3.173</h2.version>
|
||||||
|
<surefire.memory.settings>-Xms512m -Xmx1024m -XX:MetaspaceSize=96m -XX:MaxMetaspaceSize=256m</surefire.memory.settings>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
Loading…
Reference in a new issue