Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions quarkus/runtime/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ quarkus.naming.enable-jndi=true
# HTTP limits configuration - reverse-engineered from Wildfly
quarkus.http.limits.max-initial-line-length=32779
quarkus.http.limits.max-header-size=65535
# Align the HTTP/2 header-list limit with max-header-size, instead of the much smaller Quarkus default
quarkus.http.limits.max-header-list-size=65535

# Default and non-production grade database vendor
%dev.kc.db=dev-file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,15 @@ public void testOverrideDefaultQuarkusPropertiesViaEnv() {
assertEquals("200k", config.getConfigValue("quarkus.http.limits.max-header-size").getValue());
}

@Test
public void testHttp2HeaderListSizeMatchesHttp1HeaderSizeDefault() {
ConfigArgsConfigSource.setCliArgs("");
SmallRyeConfig config = createConfig();
assertEquals(config.getConfigValue("quarkus.http.limits.max-header-size").getValue(),
config.getConfigValue("quarkus.http.limits.max-header-list-size").getValue());
assertEquals("65535", config.getConfigValue("quarkus.http.limits.max-header-list-size").getValue());
}

@Test
public void testQuarkusPropertyTakesPrecedenceOverDefault() {
putEnvVar("QUARKUS_HTTP_PORT", "9090");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.keycloak.it.junit5.extension.CLIResult;
import org.keycloak.it.junit5.extension.DistributionTest;
Expand All @@ -37,6 +38,15 @@
import io.quarkus.test.junit.main.Launch;
import io.restassured.RestAssured;
import io.restassured.config.RedirectConfig;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpClientRequest;
import io.vertx.core.http.HttpClientResponse;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpVersion;
import io.vertx.core.http.RequestOptions;
import io.vertx.core.net.SocketAddress;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -91,6 +101,54 @@ public void preventNonNormalizedURLs() {
.when().get("/realms/master;xxx").then().statusCode(400);
}

@Test
@Launch({"start-dev"})
public void largeHeadersTest() throws Exception {
String largeValue = "a".repeat(32 * 1024);

Vertx vertx = Vertx.vertx();
try {
HttpClient http2Client = vertx.createHttpClient(new HttpClientOptions()
.setSsl(true)
.setTrustAll(true)
.setVerifyHost(false)
.setProtocolVersion(HttpVersion.HTTP_2)
.setUseAlpn(true));
HttpClient http1Client = vertx.createHttpClient(new HttpClientOptions()
.setSsl(true)
.setTrustAll(true)
.setVerifyHost(false));
try {
assertThat("Large headers under the limit are accepted over HTTP/2",
largeHeaderRequest(http2Client, largeValue), Matchers.is(200));
assertThat("Large headers under the limit are accepted over HTTP/1.1",
largeHeaderRequest(http1Client, largeValue), Matchers.is(200));
} finally {
http2Client.close().toCompletionStage().toCompletableFuture().get(5, TimeUnit.SECONDS);
http1Client.close().toCompletionStage().toCompletableFuture().get(5, TimeUnit.SECONDS);
}
} finally {
vertx.close().toCompletionStage().toCompletableFuture().get(5, TimeUnit.SECONDS);
}
}

private static int largeHeaderRequest(HttpClient client, String headerValue) throws Exception {
RequestOptions options = new RequestOptions()
.setServer(SocketAddress.inetSocketAddress(8443, "localhost"))
.setPort(8443)
.setSsl(true)
.setURI("/realms/master")
.setMethod(HttpMethod.GET)
.putHeader("X-Large-Header", headerValue);

return client.request(options)
.compose(HttpClientRequest::send)
.map(HttpClientResponse::statusCode)
.toCompletionStage()
.toCompletableFuture()
.get(10, TimeUnit.SECONDS);
}

@Test
@Launch({"start-dev", "--http-access-log-enabled=true", "--http-accept-non-normalized-paths=true"})
public void allowNonNormalizedURLs() {
Expand Down
Loading