[KEYCLOAK-13141] - Fixing filter

This commit is contained in:
Pedro Igor 2020-07-15 09:40:10 -03:00
parent dc73397176
commit 582046bbfe
5 changed files with 43 additions and 20 deletions

View file

@ -50,7 +50,30 @@ jobs:
- name: Build testsuite - name: Build testsuite
run: mvn clean install -B -Pquarkus,auth-server-quarkus -DskipTests -f testsuite/pom.xml run: mvn clean install -B -Pquarkus,auth-server-quarkus -DskipTests -f testsuite/pom.xml
- name: Run base tests - name: Run base tests
run: mvn clean install -B -Pquarkus,auth-server-quarkus -f testsuite/integration-arquillian/tests/base/pom.xml | misc/log/trimmer.sh; exit ${PIPESTATUS[0]} run: mvn clean install -B -Pquarkus,auth-server-quarkus -f testsuite/integration-arquillian/tests/base/pom.xml -Dtest='!org.keycloak.testsuite.adapter.**,!**.crossdc.**,!**.cluster.**' | misc/log/trimmer.sh; exit ${PIPESTATUS[0]}
test-adapter:
name: Test Adapter
needs: build
runs-on: ubuntu-latest
env:
MAVEN_OPTS: -Xmx1024m
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Download Maven Repo
uses: actions/download-artifact@v1
with:
name: maven-repo
path: .
- name: Extract Maven Repo
shell: bash
run: tar -xzvf maven-repo.tgz -C ~
- name: Build testsuite
run: mvn clean install -B -Pquarkus,auth-server-quarkus -DskipTests -f testsuite/pom.xml
- name: Run adapter tests
run: mvn clean install -B -Pquarkus,auth-server-quarkus -f testsuite/integration-arquillian/tests/base/pom.xml -Dtest=org.keycloak.testsuite.adapter.** | misc/log/trimmer.sh; exit ${PIPESTATUS[0]}
test-cluster: test-cluster:
name: Test Clustering name: Test Clustering
needs: build needs: build

View file

@ -148,6 +148,7 @@ public abstract class KeycloakPropertiesConfigSource extends PropertiesConfigSou
case "hibernate-orm": case "hibernate-orm":
case "datasource": case "datasource":
case "http": case "http":
case "vertx":
case "log": case "log":
namespace = NS_QUARKUS; namespace = NS_QUARKUS;
break; break;

View file

@ -35,31 +35,30 @@ import io.vertx.ext.web.RoutingContext;
*/ */
public class QuarkusRequestFilter extends AbstractRequestFilter implements Handler<RoutingContext> { public class QuarkusRequestFilter extends AbstractRequestFilter implements Handler<RoutingContext> {
private static final String KEYCLOAK_SESSION_KEY = KeycloakSession.class.getName();
private static final Handler<AsyncResult<Object>> EMPTY_RESULT = result -> { private static final Handler<AsyncResult<Object>> EMPTY_RESULT = result -> {
// we don't really care about the result because any exception thrown should be handled by the parent class // we don't really care about the result because any exception thrown should be handled by the parent class
}; };
@Override @Override
public void handle(RoutingContext context) { public void handle(RoutingContext context) {
ClientConnection clientConnection = createClientConnection(context.request());
// our code should always be run as blocking until we don't provide a better support for running non-blocking code // our code should always be run as blocking until we don't provide a better support for running non-blocking code
// in the event loop // in the event loop
context.vertx().executeBlocking(promise -> filter(clientConnection, (session) -> { context.vertx().executeBlocking(promise -> {
try { filter(createClientConnection(context.request()), (session) -> {
// we need to close the session before response is sent to the client, otherwise subsequent requests could try {
// not get the latest state because the session from the previous request is still being closed // we need to close the session before response is sent to the client, otherwise subsequent requests could
// other methods from Vert.x to add a handler to the response works asynchronously // not get the latest state because the session from the previous request is still being closed
context.response().headersEndHandler(event -> close(session)); // other methods from Vert.x to add a handler to the response works asynchronously
context.next(); context.addHeadersEndHandler(event -> close(session));
promise.complete(); context.next();
} catch (Exception cause) { promise.complete();
promise.fail(cause); } catch (Throwable cause) {
// re-throw so that the any exception is handled from parent promise.fail(cause);
throw new RuntimeException(cause); // re-throw so that the any exception is handled from parent
} throw new RuntimeException(cause);
}), EMPTY_RESULT); }
});
}, false, EMPTY_RESULT);
} }
@Override @Override

View file

@ -133,7 +133,7 @@ public class DefaultHttpClientFactory implements HttpClientFactory {
if (httpClient == null) { if (httpClient == null) {
synchronized(this) { synchronized(this) {
if (httpClient == null) { if (httpClient == null) {
long socketTimeout = config.getLong("socket-timeout-millis", -1L); long socketTimeout = config.getLong("socket-timeout-millis", 5000L);
long establishConnectionTimeout = config.getLong("establish-connection-timeout-millis", -1L); long establishConnectionTimeout = config.getLong("establish-connection-timeout-millis", -1L);
int maxPooledPerRoute = config.getInt("max-pooled-per-route", 64); int maxPooledPerRoute = config.getInt("max-pooled-per-route", 64);
int connectionPoolSize = config.getInt("connection-pool-size", 128); int connectionPoolSize = config.getInt("connection-pool-size", 128);

View file

@ -237,7 +237,7 @@ public class KeycloakQuarkusServerDeployableContainer implements DeployableConta
SSLSocketFactory socketFactory; SSLSocketFactory socketFactory;
try { try {
sslContext = SSLContext.getInstance("SSL"); sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, trustAllCerts, new java.security.SecureRandom()); sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
socketFactory = sslContext.getSocketFactory(); socketFactory = sslContext.getSocketFactory();
} catch (NoSuchAlgorithmException | KeyManagementException e) { } catch (NoSuchAlgorithmException | KeyManagementException e) {