diff --git a/extensions/funqy/funqy-http/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/http/FunqyHttpBuildStep.java b/extensions/funqy/funqy-http/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/http/FunqyHttpBuildStep.java index 34c86767bc33c..0751cbaa7672a 100644 --- a/extensions/funqy/funqy-http/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/http/FunqyHttpBuildStep.java +++ b/extensions/funqy/funqy-http/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/http/FunqyHttpBuildStep.java @@ -50,7 +50,7 @@ public void staticInit(FunqyHttpBindingRecorder binding, return; // The context path + the resources path - String rootPath = httpConfig.rootPath(); + String rootPath = httpConfig.rootPath; binding.init(); } @@ -71,7 +71,7 @@ public void boot(ShutdownContextBuildItem shutdown, return; feature.produce(new FeatureBuildItem(FUNQY_HTTP_FEATURE)); - String rootPath = httpConfig.rootPath(); + String rootPath = httpConfig.rootPath; Handler handler = binding.start(rootPath, vertx.getVertx(), shutdown, diff --git a/extensions/funqy/funqy-knative-events/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/knative/events/FunqyKnativeEventsBuildStep.java b/extensions/funqy/funqy-knative-events/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/knative/events/FunqyKnativeEventsBuildStep.java index ede48353cd7e9..cbaa4ae12a25e 100644 --- a/extensions/funqy/funqy-knative-events/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/knative/events/FunqyKnativeEventsBuildStep.java +++ b/extensions/funqy/funqy-knative-events/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/knative/events/FunqyKnativeEventsBuildStep.java @@ -73,7 +73,7 @@ public void boot(ShutdownContextBuildItem shutdown, feature.produce(new FeatureBuildItem(FUNQY_KNATIVE_FEATURE)); - String rootPath = httpConfig.rootPath(); + String rootPath = httpConfig.rootPath; if (rootPath == null) { rootPath = "/"; } else if (!rootPath.endsWith("/")) { diff --git a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/devui/GrpcJsonRPCService.java b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/devui/GrpcJsonRPCService.java index 47cbd6988b9e2..dc4f09e115730 100644 --- a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/devui/GrpcJsonRPCService.java +++ b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/devui/GrpcJsonRPCService.java @@ -50,9 +50,9 @@ public void init() { this.port = serverConfig.port; this.ssl = serverConfig.ssl.certificate.isPresent() || serverConfig.ssl.keyStore.isPresent(); } else { - this.host = httpConfiguration.host(); - this.port = httpConfiguration.port(); - this.ssl = httpConfiguration.insecureRequests() != HttpConfiguration.InsecureRequests.ENABLED; + this.host = httpConfiguration.host; + this.port = httpConfiguration.port; + this.ssl = httpConfiguration.insecureRequests != HttpConfiguration.InsecureRequests.ENABLED; } } diff --git a/extensions/keycloak-authorization/runtime/src/main/java/io/quarkus/keycloak/pep/runtime/KeycloakPolicyEnforcerRecorder.java b/extensions/keycloak-authorization/runtime/src/main/java/io/quarkus/keycloak/pep/runtime/KeycloakPolicyEnforcerRecorder.java index 15a926be3e1d1..7165eb7e39c79 100644 --- a/extensions/keycloak-authorization/runtime/src/main/java/io/quarkus/keycloak/pep/runtime/KeycloakPolicyEnforcerRecorder.java +++ b/extensions/keycloak-authorization/runtime/src/main/java/io/quarkus/keycloak/pep/runtime/KeycloakPolicyEnforcerRecorder.java @@ -47,7 +47,7 @@ public Supplier setup(OidcConfig oidcConfig, KeycloakPol @Override public PolicyEnforcerResolver get() { return new PolicyEnforcerResolver(defaultPolicyEnforcer, policyEnforcerTenants, - httpConfiguration.readTimeout().toMillis()); + httpConfiguration.readTimeout.toMillis()); } }; } diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/OidcBuildStep.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/OidcBuildStep.java index ae84cfb80aa24..daa6a390ee240 100644 --- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/OidcBuildStep.java +++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/OidcBuildStep.java @@ -162,7 +162,7 @@ public void produceTenantResolverInterceptors(CombinedIndexBuildItem indexBuildI Capabilities capabilities, OidcRecorder recorder, BuildProducer producer, HttpBuildTimeConfig buildTimeConfig) { - if (!buildTimeConfig.auth().proactive() + if (!buildTimeConfig.auth.proactive && (capabilities.isPresent(Capability.RESTEASY_REACTIVE) || capabilities.isPresent(Capability.RESTEASY))) { // provide method interceptor that will be run before security checks diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevJsonRpcService.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevJsonRpcService.java index 4d7416315cab7..e54c728dbe077 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevJsonRpcService.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevJsonRpcService.java @@ -47,7 +47,7 @@ public OidcDevJsonRpcService(HttpConfiguration httpConfiguration, SmallRyeConfig // 'KeycloakDevServicesProcessor' is created with combined index OidcDevUiRpcSvcPropertiesBean props = Arc.container().instance(OidcDevUiRpcSvcPropertiesBean.class).get(); - this.httpPort = httpConfiguration.port(); + this.httpPort = httpConfiguration.port; this.config = config; this.vertx = vertx; this.authorizationUrl = props.getAuthorizationUrl(); diff --git a/extensions/reactive-routes/deployment/src/main/java/io/quarkus/vertx/web/deployment/ReactiveRoutesProcessor.java b/extensions/reactive-routes/deployment/src/main/java/io/quarkus/vertx/web/deployment/ReactiveRoutesProcessor.java index b9cfc856b0f94..3f6872a54ac88 100644 --- a/extensions/reactive-routes/deployment/src/main/java/io/quarkus/vertx/web/deployment/ReactiveRoutesProcessor.java +++ b/extensions/reactive-routes/deployment/src/main/java/io/quarkus/vertx/web/deployment/ReactiveRoutesProcessor.java @@ -227,7 +227,7 @@ void validateBeanDeployment( // access the SecurityIdentity in a synchronous manner final boolean blocking = annotationStore.hasAnnotation(method, DotNames.BLOCKING); final boolean alwaysAuthenticateRoute; - if (!httpBuildTimeConfig.auth().proactive() && !blocking) { + if (!httpBuildTimeConfig.auth.proactive && !blocking) { final DotName returnTypeName = method.returnType().name(); // method either returns 'something' in a synchronous manner or void (in which case we can't tell) final boolean possiblySynchronousResponse = !returnTypeName.equals(DotNames.UNI) diff --git a/extensions/reactive-routes/runtime/src/main/java/io/quarkus/vertx/web/runtime/VertxWebRecorder.java b/extensions/reactive-routes/runtime/src/main/java/io/quarkus/vertx/web/runtime/VertxWebRecorder.java index 3a492db431ae0..6fd9f8519fc71 100644 --- a/extensions/reactive-routes/runtime/src/main/java/io/quarkus/vertx/web/runtime/VertxWebRecorder.java +++ b/extensions/reactive-routes/runtime/src/main/java/io/quarkus/vertx/web/runtime/VertxWebRecorder.java @@ -52,10 +52,10 @@ public Handler createHandler(String handlerClassName) { } public Handler compressRouteHandler(Handler routeHandler, HttpCompression compression) { - if (httpBuildTimeConfig.enableCompression()) { + if (httpBuildTimeConfig.enableCompression) { return new HttpCompressionHandler(routeHandler, compression, compression == HttpCompression.UNDEFINED - ? Set.copyOf(httpBuildTimeConfig.compressMediaTypes().orElse(List.of())) + ? Set.copyOf(httpBuildTimeConfig.compressMediaTypes.orElse(List.of())) : Set.of()); } else { return routeHandler; diff --git a/extensions/resteasy-classic/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyStandaloneBuildStep.java b/extensions/resteasy-classic/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyStandaloneBuildStep.java index 44b2e019c80ec..73b99d8406866 100644 --- a/extensions/resteasy-classic/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyStandaloneBuildStep.java +++ b/extensions/resteasy-classic/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyStandaloneBuildStep.java @@ -111,7 +111,7 @@ public void boot(ShutdownContextBuildItem shutdown, final boolean noCustomAuthCompletionExMapper; final boolean noCustomAuthFailureExMapper; final boolean noCustomAuthRedirectExMapper; - if (vertxConfig.auth().proactive()) { + if (vertxConfig.auth.proactive) { noCustomAuthCompletionExMapper = notFoundCustomExMapper(AuthenticationCompletionException.class.getName(), AuthenticationCompletionExceptionMapper.class.getName(), combinedIndexBuildItem.getIndex()); noCustomAuthFailureExMapper = notFoundCustomExMapper(AuthenticationFailedException.class.getName(), @@ -129,7 +129,7 @@ public void boot(ShutdownContextBuildItem shutdown, // so that user can define failure handlers that precede exception mappers final Handler failureHandler = recorder.vertxFailureHandler(vertx.getVertx(), executorBuildItem.getExecutorProxy(), resteasyVertxConfig, noCustomAuthCompletionExMapper, - noCustomAuthFailureExMapper, noCustomAuthRedirectExMapper, vertxConfig.auth().proactive()); + noCustomAuthFailureExMapper, noCustomAuthRedirectExMapper, vertxConfig.auth.proactive); filterBuildItemBuildProducer.produce(FilterBuildItem.ofAuthenticationFailureHandler(failureHandler)); // Exact match for resources matched to the root path diff --git a/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/ResteasyStandaloneRecorder.java b/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/ResteasyStandaloneRecorder.java index 6a06404fc4c3b..074519e4a4298 100644 --- a/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/ResteasyStandaloneRecorder.java +++ b/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/ResteasyStandaloneRecorder.java @@ -77,10 +77,10 @@ public Handler vertxRequestHandler(Supplier vertx, Execut if (deployment != null) { Handler handler = new VertxRequestHandler(vertx.get(), deployment, contextPath, new ResteasyVertxAllocator(config.responseBufferSize), executor, - readTimeout.getValue().readTimeout().toMillis()); + readTimeout.getValue().readTimeout.toMillis()); - Set compressMediaTypes = httpBuildTimeConfig.compressMediaTypes().map(Set::copyOf).orElse(Set.of()); - if (httpBuildTimeConfig.enableCompression() && !compressMediaTypes.isEmpty()) { + Set compressMediaTypes = httpBuildTimeConfig.compressMediaTypes.map(Set::copyOf).orElse(Set.of()); + if (httpBuildTimeConfig.enableCompression && !compressMediaTypes.isEmpty()) { // If compression is enabled and the set of compressed media types is not empty then wrap the standalone handler handler = new HttpCompressionHandler(handler, compressMediaTypes); } @@ -99,7 +99,7 @@ public Handler vertxFailureHandler(Supplier vertx, Execut // used when auth failed before RESTEasy Classic began processing the request return new VertxRequestHandler(vertx.get(), deployment, contextPath, new ResteasyVertxAllocator(config.responseBufferSize), executor, - readTimeout.getValue().readTimeout().toMillis()) { + readTimeout.getValue().readTimeout.toMillis()) { @Override public void handle(RoutingContext request) { diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/CompressionScanner.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/CompressionScanner.java index 68517881770ad..2d23b70a6250d 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/CompressionScanner.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/CompressionScanner.java @@ -34,7 +34,7 @@ public CompressionScanner(HttpBuildTimeConfig httpBuildTimeConfig) { @Override public List scan(MethodInfo method, ClassInfo actualEndpointClass, Map methodContext) { - if (!httpBuildTimeConfig.enableCompression()) { + if (!httpBuildTimeConfig.enableCompression) { return Collections.emptyList(); } @@ -58,7 +58,7 @@ public List scan(MethodInfo method, ClassInfo actualEndp return Collections.emptyList(); } ResteasyReactiveCompressionHandler handler = new ResteasyReactiveCompressionHandler( - Set.copyOf(httpBuildTimeConfig.compressMediaTypes().orElse(Collections.emptyList()))); + Set.copyOf(httpBuildTimeConfig.compressMediaTypes.orElse(Collections.emptyList()))); handler.setCompression(compression); String[] produces = (String[]) methodContext.get(EndpointIndexer.METHOD_PRODUCES); if ((produces != null) && (produces.length > 0)) { diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java index 97a5c631905b6..63a1959712a48 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java @@ -1272,7 +1272,7 @@ public void setupDeployment(BeanContainerBuildItem beanContainerBuildItem, final boolean noCustomAuthCompletionExMapper; final boolean noCustomAuthFailureExMapper; final boolean noCustomAuthRedirectExMapper; - if (vertxConfig.auth().proactive()) { + if (vertxConfig.auth.proactive) { noCustomAuthCompletionExMapper = notFoundCustomExMapper(AuthenticationCompletionException.class.getName(), AuthenticationCompletionExceptionMapper.class.getName(), exceptionMapping); noCustomAuthFailureExMapper = notFoundCustomExMapper(AuthenticationFailedException.class.getName(), @@ -1287,7 +1287,7 @@ public void setupDeployment(BeanContainerBuildItem beanContainerBuildItem, } Handler failureHandler = recorder.failureHandler(restInitialHandler, noCustomAuthCompletionExMapper, - noCustomAuthFailureExMapper, noCustomAuthRedirectExMapper, vertxConfig.auth().proactive()); + noCustomAuthFailureExMapper, noCustomAuthRedirectExMapper, vertxConfig.auth.proactive); // we add failure handler right before QuarkusErrorHandler // so that user can define failure handlers that precede exception mappers @@ -1506,10 +1506,10 @@ public List scan(MethodInfo method, ClassInfo actualEndp List securityHandlerList = consumeStandardSecurityAnnotations(method, actualEndpointClass, index, (c) -> Collections.singletonList( - EagerSecurityHandler.Customizer.newInstance(httpBuildTimeConfig.auth().proactive()))); + EagerSecurityHandler.Customizer.newInstance(httpBuildTimeConfig.auth.proactive))); if (securityHandlerList == null && (denyJaxRs || hasDefaultJaxRsRolesAllowed)) { securityHandlerList = Collections - .singletonList(EagerSecurityHandler.Customizer.newInstance(httpBuildTimeConfig.auth().proactive())); + .singletonList(EagerSecurityHandler.Customizer.newInstance(httpBuildTimeConfig.auth.proactive)); } if (applySecurityInterceptors && eagerSecurityInterceptors.get().applyInterceptorOn(method)) { List nextSecurityHandlerList = new ArrayList<>(); diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/ResteasyReactiveRecorder.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/ResteasyReactiveRecorder.java index f2c1cfca2f9fa..3a74e78586a49 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/ResteasyReactiveRecorder.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/ResteasyReactiveRecorder.java @@ -131,7 +131,7 @@ public ResteasyReactiveRequestContext createContext(Deployment deployment, RuntimeDeploymentManager runtimeDeploymentManager = new RuntimeDeploymentManager(info, EXECUTOR_SUPPLIER, VirtualThreadsRecorder::getCurrent, closeTaskHandler, contextFactory, new ArcThreadSetupAction(beanContainer.requestContext()), - vertxConfig.rootPath()); + vertxConfig.rootPath); Deployment deployment = runtimeDeploymentManager.deploy(); DisabledRestEndpoints.set(deployment.getDisabledEndpoints()); initClassFactory.createInstance().getInstance().init(deployment); diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/ResteasyReactiveRuntimeRecorder.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/ResteasyReactiveRuntimeRecorder.java index 30772c618e8fe..fc7feb6161b7e 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/ResteasyReactiveRuntimeRecorder.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/ResteasyReactiveRuntimeRecorder.java @@ -27,17 +27,17 @@ public Supplier runtimeConfiguration(RuntimeValue maxBodySize; - if (httpConf.limits().maxBodySize().isPresent()) { - maxBodySize = Optional.of(httpConf.limits().maxBodySize().get().asLongValue()); + if (httpConf.limits.maxBodySize.isPresent()) { + maxBodySize = Optional.of(httpConf.limits.maxBodySize.get().asLongValue()); } else { maxBodySize = Optional.empty(); } - RuntimeConfiguration runtimeConfiguration = new DefaultRuntimeConfiguration(httpConf.readTimeout(), - httpConf.body().deleteUploadedFilesOnEnd(), httpConf.body().uploadsDirectory(), - httpConf.body().multipart().fileContentTypes().orElse(null), + RuntimeConfiguration runtimeConfiguration = new DefaultRuntimeConfiguration(httpConf.readTimeout, + httpConf.body.deleteUploadedFilesOnEnd, httpConf.body.uploadsDirectory, + httpConf.body.multipart.fileContentTypes.orElse(null), runtimeConf.multipart().inputPart().defaultCharset(), maxBodySize, - httpConf.limits().maxFormAttributeSize().asLongValue()); + httpConf.limits.maxFormAttributeSize.asLongValue()); deployment.getValue().setRuntimeConfiguration(runtimeConfiguration); diff --git a/extensions/security-webauthn/runtime/src/main/java/io/quarkus/security/webauthn/WebAuthnRecorder.java b/extensions/security-webauthn/runtime/src/main/java/io/quarkus/security/webauthn/WebAuthnRecorder.java index 72fd4f3c6155a..d61bf70b3522c 100644 --- a/extensions/security-webauthn/runtime/src/main/java/io/quarkus/security/webauthn/WebAuthnRecorder.java +++ b/extensions/security-webauthn/runtime/src/main/java/io/quarkus/security/webauthn/WebAuthnRecorder.java @@ -53,7 +53,7 @@ public Supplier setupWebAuthnAuthenticationMech @Override public WebAuthnAuthenticationMechanism get() { String key; - if (!httpConfiguration.getValue().encryptionKey().isPresent()) { + if (!httpConfiguration.getValue().encryptionKey.isPresent()) { if (encryptionKey != null) { //persist across dev mode restarts key = encryptionKey; @@ -64,7 +64,7 @@ public WebAuthnAuthenticationMechanism get() { log.warn("Encryption key was not specified for persistent WebAuthn auth, using temporary key " + key); } } else { - key = httpConfiguration.getValue().encryptionKey().get(); + key = httpConfiguration.getValue().encryptionKey.get(); } WebAuthnRunTimeConfig config = WebAuthnRecorder.this.config.getValue(); PersistentLoginManager loginManager = new PersistentLoginManager(key, config.cookieName, diff --git a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java index 616a4a3cfadc9..3899c03b69169 100644 --- a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java +++ b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java @@ -314,7 +314,7 @@ public void includeInOpenAPIEndpoint(BuildProducer startupPathItemProducer, BuildProducer port) { - if (managementInterfaceBuildTimeConfig.enabled()) { + if (managementInterfaceBuildTimeConfig.enabled) { // Switch to the "management" port port.produce(new KubernetesProbePortNameBuildItem("management", selectSchemeForManagement())); } diff --git a/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/SmallRyeOpenApiProcessor.java b/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/SmallRyeOpenApiProcessor.java index d034b9d894d29..59504bc294d33 100644 --- a/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/SmallRyeOpenApiProcessor.java +++ b/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/SmallRyeOpenApiProcessor.java @@ -338,7 +338,7 @@ private String getManagementRoot(LaunchModeBuildItem launch, String managementRoot = nonApplicationRootPathBuildItem.resolveManagementPath("/", managementInterfaceBuildTimeConfig, launch, openApiConfig.managementEnabled); - return managementRoot.split(managementInterfaceBuildTimeConfig.rootPath())[0]; + return managementRoot.split(managementInterfaceBuildTimeConfig.rootPath)[0]; } @@ -435,7 +435,7 @@ void addAutoFilters(BuildProducer addToOpenAPID private boolean isManagement(ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig, SmallRyeOpenApiConfig smallRyeOpenApiConfig, LaunchModeBuildItem launchModeBuildItem) { - return managementInterfaceBuildTimeConfig.enabled() && smallRyeOpenApiConfig.managementEnabled + return managementInterfaceBuildTimeConfig.enabled && smallRyeOpenApiConfig.managementEnabled && launchModeBuildItem.getLaunchMode().equals(LaunchMode.DEVELOPMENT); } diff --git a/extensions/smallrye-openapi/runtime/src/main/java/io/quarkus/smallrye/openapi/runtime/OpenApiRecorder.java b/extensions/smallrye-openapi/runtime/src/main/java/io/quarkus/smallrye/openapi/runtime/OpenApiRecorder.java index 212d2e8b72e58..41d10839c2aec 100644 --- a/extensions/smallrye-openapi/runtime/src/main/java/io/quarkus/smallrye/openapi/runtime/OpenApiRecorder.java +++ b/extensions/smallrye-openapi/runtime/src/main/java/io/quarkus/smallrye/openapi/runtime/OpenApiRecorder.java @@ -30,7 +30,7 @@ public OpenApiRecorder(RuntimeValue configuration) { } public Consumer corsFilter(Filter filter) { - if (configuration.getValue().corsEnabled() && filter.getHandler() != null) { + if (configuration.getValue().corsEnabled && filter.getHandler() != null) { return new Consumer() { @Override public void accept(Route route) { diff --git a/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java b/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java index 341bfc95cebb5..06fd8dd5d7169 100644 --- a/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java +++ b/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java @@ -412,7 +412,7 @@ public ServletDeploymentManagerBuildItem build(List servlets, knownPaths.knownDirectories, launchMode.getLaunchMode(), shutdownContext, httpRootPath.relativePath(contextPath), servletConfig.defaultCharset, webMetaData.getRequestCharacterEncoding(), - webMetaData.getResponseCharacterEncoding(), httpBuildTimeConfig.auth().proactive(), + webMetaData.getResponseCharacterEncoding(), httpBuildTimeConfig.auth.proactive, webMetaData.getWelcomeFileList() != null ? webMetaData.getWelcomeFileList().getWelcomeFiles() : null, hasSecurityCapability(capabilities)); diff --git a/extensions/undertow/runtime/src/main/java/io/quarkus/undertow/runtime/UndertowDeploymentRecorder.java b/extensions/undertow/runtime/src/main/java/io/quarkus/undertow/runtime/UndertowDeploymentRecorder.java index 3a4a46341cf6f..b2c0692265d0d 100644 --- a/extensions/undertow/runtime/src/main/java/io/quarkus/undertow/runtime/UndertowDeploymentRecorder.java +++ b/extensions/undertow/runtime/src/main/java/io/quarkus/undertow/runtime/UndertowDeploymentRecorder.java @@ -386,8 +386,8 @@ public void run() { undertowOptions.set(UndertowOptions.MAX_PARAMETERS, servletRuntimeConfig.maxParameters); UndertowOptionMap undertowOptionMap = undertowOptions.getMap(); - Set compressMediaTypes = httpBuildTimeConfig.enableCompression() - ? Set.copyOf(httpBuildTimeConfig.compressMediaTypes().get()) + Set compressMediaTypes = httpBuildTimeConfig.enableCompression + ? Set.copyOf(httpBuildTimeConfig.compressMediaTypes.get()) : Collections.emptySet(); return new Handler() { @@ -418,11 +418,11 @@ public void handle(AsyncResult result) { }); } - Optional maxBodySize = httpConfiguration.getValue().limits().maxBodySize(); + Optional maxBodySize = httpConfiguration.getValue().limits.maxBodySize; if (maxBodySize.isPresent()) { exchange.setMaxEntitySize(maxBodySize.get().asLongValue()); } - Duration readTimeout = httpConfiguration.getValue().readTimeout(); + Duration readTimeout = httpConfiguration.getValue().readTimeout; exchange.setReadTimeout(readTimeout.toMillis()); exchange.setUndertowOptions(undertowOptionMap); diff --git a/extensions/vertx-http/deployment/pom.xml b/extensions/vertx-http/deployment/pom.xml index 2342dd51e5e34..ed3dd67a09031 100644 --- a/extensions/vertx-http/deployment/pom.xml +++ b/extensions/vertx-http/deployment/pom.xml @@ -87,11 +87,6 @@ quarkus-junit5 test - - org.mockito - mockito-core - test - io.rest-assured rest-assured diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/HttpSecurityProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/HttpSecurityProcessor.java index aa29d6ea1d849..124bd5dc59e57 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/HttpSecurityProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/HttpSecurityProcessor.java @@ -1,6 +1,7 @@ package io.quarkus.vertx.http.deployment; import static io.quarkus.arc.processor.DotNames.APPLICATION_SCOPED; +import static org.jboss.jandex.AnnotationTarget.Kind.CLASS; import java.security.Permission; import java.util.HashMap; @@ -71,19 +72,19 @@ public void builtins(BuildProducer producer, producer.produce(new HttpSecurityPolicyBuildItem("permit", new SupplierImpl<>(new PermitSecurityPolicy()))); producer.produce( new HttpSecurityPolicyBuildItem("authenticated", new SupplierImpl<>(new AuthenticatedHttpSecurityPolicy()))); - if (!buildTimeConfig.auth().permissions().isEmpty()) { + if (!buildTimeConfig.auth.permissions.isEmpty()) { beanProducer.produce(AdditionalBeanBuildItem.unremovableOf(PathMatchingHttpSecurityPolicy.class)); } Map> permClassToCreator = new HashMap<>(); - for (Map.Entry e : buildTimeConfig.auth().rolePolicy().entrySet()) { + for (Map.Entry e : buildTimeConfig.auth.rolePolicy.entrySet()) { PolicyConfig policyConfig = e.getValue(); - if (policyConfig.permissions().isEmpty()) { + if (policyConfig.permissions.isEmpty()) { producer.produce(new HttpSecurityPolicyBuildItem(e.getKey(), - new SupplierImpl<>(new RolesAllowedHttpSecurityPolicy(e.getValue().rolesAllowed())))); + new SupplierImpl<>(new RolesAllowedHttpSecurityPolicy(e.getValue().rolesAllowed)))); } else { // create HTTP Security policy that checks allowed roles and grants SecurityIdentity permissions to // requests that this policy allows to proceed - var permissionCreator = permClassToCreator.computeIfAbsent(policyConfig.permissionClass(), + var permissionCreator = permClassToCreator.computeIfAbsent(policyConfig.permissionClass, new Function>() { @Override public BiFunction apply(String s) { @@ -91,11 +92,11 @@ public BiFunction apply(String s) { return recorder.stringPermissionCreator(); } boolean constructorAcceptsActions = validateConstructor(combinedIndexBuildItem.getIndex(), - policyConfig.permissionClass()); + policyConfig.permissionClass); return recorder.customPermissionCreator(s, constructorAcceptsActions); } }); - var policy = recorder.createRolesAllowedPolicy(policyConfig.rolesAllowed(), policyConfig.permissions(), + var policy = recorder.createRolesAllowedPolicy(policyConfig.rolesAllowed, policyConfig.permissions, permissionCreator); producer.produce(new HttpSecurityPolicyBuildItem(e.getKey(), policy)); } @@ -165,11 +166,11 @@ SyntheticBeanBuildItem initFormAuth( HttpSecurityRecorder recorder, HttpBuildTimeConfig buildTimeConfig, BuildProducer filterBuildItemBuildProducer) { - if (!buildTimeConfig.auth().proactive()) { - filterBuildItemBuildProducer.produce(RouteBuildItem.builder().route(buildTimeConfig.auth().form().postLocation()) + if (!buildTimeConfig.auth.proactive) { + filterBuildItemBuildProducer.produce(RouteBuildItem.builder().route(buildTimeConfig.auth.form.postLocation) .handler(recorder.formAuthPostHandler()).build()); } - if (buildTimeConfig.auth().form().enabled()) { + if (buildTimeConfig.auth.form.enabled) { return SyntheticBeanBuildItem.configure(FormAuthenticationMechanism.class) .types(HttpAuthenticationMechanism.class) .setRuntimeInit() @@ -211,8 +212,8 @@ SyntheticBeanBuildItem initBasicAuth( .setRuntimeInit() .scope(Singleton.class) .supplier(recorder.setupBasicAuth(buildTimeConfig)); - if (!buildTimeConfig.auth().form().enabled() && !isMtlsClientAuthenticationEnabled(buildTimeConfig) - && !buildTimeConfig.auth().basic().orElse(false)) { + if (!buildTimeConfig.auth.form.enabled && !isMtlsClientAuthenticationEnabled(buildTimeConfig) + && !buildTimeConfig.auth.basic.orElse(false)) { //if not explicitly enabled we make this a default bean, so it is the fallback if nothing else is defined configurator.defaultBean(); securityInformationProducer.produce(SecurityInformationBuildItem.BASIC()); @@ -224,12 +225,12 @@ SyntheticBeanBuildItem initBasicAuth( public static boolean applicationBasicAuthRequired(HttpBuildTimeConfig buildTimeConfig, ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig) { //basic auth explicitly disabled - if (buildTimeConfig.auth().basic().isPresent() && !buildTimeConfig.auth().basic().get()) { + if (buildTimeConfig.auth.basic.isPresent() && !buildTimeConfig.auth.basic.get()) { return false; } - if (!buildTimeConfig.auth().basic().orElse(false)) { - if ((buildTimeConfig.auth().form().enabled() || isMtlsClientAuthenticationEnabled(buildTimeConfig)) - || managementInterfaceBuildTimeConfig.auth().basic().orElse(false)) { + if (!buildTimeConfig.auth.basic.orElse(false)) { + if ((buildTimeConfig.auth.form.enabled || isMtlsClientAuthenticationEnabled(buildTimeConfig)) + || managementInterfaceBuildTimeConfig.auth.basic.orElse(false)) { //if form auth is enabled and we are not then we don't install return false; } @@ -257,7 +258,7 @@ void setupAuthenticationMechanisms( policyMap.put(e.getName(), e.policySupplier); } - if (!buildTimeConfig.auth().form().enabled() && buildTimeConfig.auth().basic().orElse(false)) { + if (!buildTimeConfig.auth.form.enabled && buildTimeConfig.auth.basic.orElse(false)) { securityInformationProducer.produce(SecurityInformationBuildItem.BASIC()); } @@ -270,17 +271,17 @@ void setupAuthenticationMechanisms( .addBeanClass(HttpAuthorizer.class).build()); filterBuildItemBuildProducer .produce(new FilterBuildItem( - recorder.authenticationMechanismHandler(buildTimeConfig.auth().proactive()), + recorder.authenticationMechanismHandler(buildTimeConfig.auth.proactive), FilterBuildItem.AUTHENTICATION)); filterBuildItemBuildProducer .produce(new FilterBuildItem(recorder.permissionCheckHandler(), FilterBuildItem.AUTHORIZATION)); - if (!buildTimeConfig.auth().permissions().isEmpty()) { + if (!buildTimeConfig.auth.permissions.isEmpty()) { beanContainerListenerBuildItemBuildProducer .produce(new BeanContainerListenerBuildItem(recorder.initPermissions(buildTimeConfig, policyMap))); } } else { - if (!buildTimeConfig.auth().permissions().isEmpty()) { + if (!buildTimeConfig.auth.permissions.isEmpty()) { throw new IllegalStateException("HTTP permissions have been set however security is not enabled"); } } @@ -290,7 +291,7 @@ void setupAuthenticationMechanisms( void collectEagerSecurityInterceptors(List interceptorCandidates, HttpBuildTimeConfig buildTimeConfig, Capabilities capabilities, BuildProducer interceptorsProducer) { - if (!buildTimeConfig.auth().proactive() && capabilities.isPresent(Capability.SECURITY) + if (!buildTimeConfig.auth.proactive && capabilities.isPresent(Capability.SECURITY) && !interceptorCandidates.isEmpty()) { List allInterceptedMethodInfos = interceptorCandidates .stream() @@ -321,6 +322,6 @@ void produceEagerSecurityInterceptorStorage(HttpSecurityRecorder recorder, } private static boolean isMtlsClientAuthenticationEnabled(HttpBuildTimeConfig buildTimeConfig) { - return !ClientAuth.NONE.equals(buildTimeConfig.tlsClientAuth()); + return !ClientAuth.NONE.equals(buildTimeConfig.tlsClientAuth); } } diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/ManagementInterfaceSecurityProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/ManagementInterfaceSecurityProcessor.java index d296a55be2bd1..07d36632f97ae 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/ManagementInterfaceSecurityProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/ManagementInterfaceSecurityProcessor.java @@ -36,7 +36,7 @@ public class ManagementInterfaceSecurityProcessor { @BuildStep public void builtins(ManagementInterfaceBuildTimeConfig buildTimeConfig, BuildProducer beanProducer) { - if (!buildTimeConfig.auth().permissions().isEmpty()) { + if (!buildTimeConfig.auth.permissions.isEmpty()) { beanProducer.produce(AdditionalBeanBuildItem.unremovableOf(ManagementPathMatchingHttpSecurityPolicy.class)); } } @@ -51,7 +51,7 @@ SyntheticBeanBuildItem initBasicAuth( return null; } - if (managementInterfaceBuildTimeConfig.auth().basic().orElse(false)) { + if (managementInterfaceBuildTimeConfig.auth.basic.orElse(false)) { SyntheticBeanBuildItem.ExtendedBeanConfigurator configurator = SyntheticBeanBuildItem .configure(BasicAuthenticationMechanism.class) .types(HttpAuthenticationMechanism.class) @@ -75,15 +75,15 @@ void setupAuthenticationMechanisms( ManagementInterfaceBuildTimeConfig buildTimeConfig) { Map> policyMap = new HashMap<>(); - for (Map.Entry e : buildTimeConfig.auth().rolePolicy().entrySet()) { + for (Map.Entry e : buildTimeConfig.auth.rolePolicy.entrySet()) { policyMap.put(e.getKey(), - new SupplierImpl<>(new RolesAllowedHttpSecurityPolicy(e.getValue().rolesAllowed()))); + new SupplierImpl<>(new RolesAllowedHttpSecurityPolicy(e.getValue().rolesAllowed))); } policyMap.put("deny", new SupplierImpl<>(new DenySecurityPolicy())); policyMap.put("permit", new SupplierImpl<>(new PermitSecurityPolicy())); policyMap.put("authenticated", new SupplierImpl<>(new AuthenticatedHttpSecurityPolicy())); - if (buildTimeConfig.auth().basic().orElse(false) + if (buildTimeConfig.auth.basic.orElse(false) && capabilities.isPresent(Capability.SECURITY)) { beanProducer .produce(AdditionalBeanBuildItem.builder().setUnremovable() @@ -91,17 +91,17 @@ void setupAuthenticationMechanisms( .addBeanClass(ManagementInterfaceHttpAuthorizer.class).build()); filterBuildItemBuildProducer .produce(new ManagementInterfaceFilterBuildItem( - recorder.authenticationMechanismHandler(buildTimeConfig.auth().proactive()), + recorder.authenticationMechanismHandler(buildTimeConfig.auth.proactive), ManagementInterfaceFilterBuildItem.AUTHENTICATION)); filterBuildItemBuildProducer .produce(new ManagementInterfaceFilterBuildItem(recorder.permissionCheckHandler(buildTimeConfig, policyMap), ManagementInterfaceFilterBuildItem.AUTHORIZATION)); - if (!buildTimeConfig.auth().permissions().isEmpty()) { + if (!buildTimeConfig.auth.permissions.isEmpty()) { beanContainerListenerBuildItemBuildProducer .produce(new BeanContainerListenerBuildItem(recorder.initPermissions(buildTimeConfig, policyMap))); } } else { - if (!buildTimeConfig.auth().permissions().isEmpty()) { + if (!buildTimeConfig.auth.permissions.isEmpty()) { throw new IllegalStateException("HTTP permissions have been set however security is not enabled"); } } diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItem.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItem.java index 13643dbe5d563..d978518a6295e 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItem.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItem.java @@ -177,7 +177,7 @@ public String resolveManagementPath(String path, ManagementInterfaceBuildTimeCon if (path == null || path.trim().isEmpty()) { throw new IllegalArgumentException("Specified path can not be empty"); } - if (managementInterfaceBuildTimeConfig.enabled() && extensionOverride) { + if (managementInterfaceBuildTimeConfig.enabled && extensionOverride) { // Best effort String prefix = getManagementUrlPrefix(mode); if (managementRootPath != null) { diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java index 43e490696f8e6..fd8ec2b3ce36e 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java @@ -92,17 +92,17 @@ LogCategoryBuildItem logging() { @BuildStep HttpRootPathBuildItem httpRoot(HttpBuildTimeConfig httpBuildTimeConfig) { - return new HttpRootPathBuildItem(httpBuildTimeConfig.rootPath()); + return new HttpRootPathBuildItem(httpBuildTimeConfig.rootPath); } @BuildStep NonApplicationRootPathBuildItem frameworkRoot(HttpBuildTimeConfig httpBuildTimeConfig, ManagementInterfaceBuildTimeConfig managementBuildTimeConfig) { String mrp = null; - if (managementBuildTimeConfig.enabled()) { - mrp = managementBuildTimeConfig.rootPath(); + if (managementBuildTimeConfig.enabled) { + mrp = managementBuildTimeConfig.rootPath; } - return new NonApplicationRootPathBuildItem(httpBuildTimeConfig.rootPath(), httpBuildTimeConfig.nonApplicationRootPath(), + return new NonApplicationRootPathBuildItem(httpBuildTimeConfig.rootPath, httpBuildTimeConfig.nonApplicationRootPath, mrp); } @@ -153,7 +153,7 @@ UnremovableBeanBuildItem shouldNotRemoveHttpServerOptionsCustomizers() { @BuildStep UseManagementInterfaceBuildItem useManagementInterfaceBuildItem(ManagementInterfaceBuildTimeConfig config) { - if (config.enabled()) { + if (config.enabled) { return new UseManagementInterfaceBuildItem(); } return null; @@ -183,7 +183,7 @@ public void kubernetes(BuildProducer kubernetesPorts) { public KubernetesPortBuildItem kubernetesForManagement( ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig) { return KubernetesPortBuildItem.fromRuntimeConfiguration("management", "quarkus.management.port", 9000, - managementInterfaceBuildTimeConfig.enabled()); + managementInterfaceBuildTimeConfig.enabled); } @BuildStep @@ -239,7 +239,7 @@ VertxWebRouterBuildItem initializeRouter(VertxHttpRecorder recorder, boolean mainRouterCreated = false; boolean managementRouterCreated = false; - boolean isManagementInterfaceEnabled = managementBuildTimeConfig.enabled(); + boolean isManagementInterfaceEnabled = managementBuildTimeConfig.enabled; for (RouteBuildItem route : routes) { if (route.isManagement() && isManagementInterfaceEnabled) { @@ -272,7 +272,7 @@ VertxWebRouterBuildItem initializeRouter(VertxHttpRecorder recorder, * To create mainrouter when `${quarkus.http.root-path}` is not {@literal /} * Refer https://github.com/quarkusio/quarkus/issues/34261 */ - if (!httpBuildTimeConfig.rootPath().equals("/") && !mainRouterCreated) { + if (!httpBuildTimeConfig.rootPath.equals("/") && !mainRouterCreated) { mainRouter = recorder.initializeRouter(vertx.getVertx()); } @@ -399,7 +399,7 @@ void openSocket(ApplicationStartBuildItem start, List websocketSubProtocols, Capabilities capabilities, VertxHttpRecorder recorder) throws IOException { - boolean startVirtual = requireVirtual.isPresent() || httpBuildTimeConfig.virtual(); + boolean startVirtual = requireVirtual.isPresent() || httpBuildTimeConfig.virtual; if (startVirtual) { reflectiveClass .produce(ReflectiveClassBuildItem.builder(VirtualServerChannel.class) diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/ConfiguredPathInfo.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/ConfiguredPathInfo.java index 99c62a76dbda7..a2cceab2f5cee 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/ConfiguredPathInfo.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/ConfiguredPathInfo.java @@ -33,7 +33,7 @@ public String getEndpointPath(HttpRootPathBuildItem httpRoot) { public String getEndpointPath(NonApplicationRootPathBuildItem nonAppRoot, ManagementInterfaceBuildTimeConfig mibt, LaunchModeBuildItem mode) { - if (management && mibt.enabled()) { + if (management && mibt.enabled) { var prefix = NonApplicationRootPathBuildItem.getManagementUrlPrefix(mode); return prefix + endpointPath; } diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/cors/CORSWildcardSecurityTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/cors/CORSWildcardSecurityTestCase.java index 852dce392609a..e364866570885 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/cors/CORSWildcardSecurityTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/cors/CORSWildcardSecurityTestCase.java @@ -21,7 +21,7 @@ public class CORSWildcardSecurityTestCase { private static final String APP_PROPS = "" + - "quarkus.http.cors.enabled=true\n" + + "quarkus.http.cors=true\n" + "quarkus.http.cors.origins=*\n" + "quarkus.http.auth.basic=true\n" + "quarkus.http.auth.policy.r1.roles-allowed=test\n" + diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItemTest.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItemTest.java index db5e778c2eadf..90796a00e584c 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItemTest.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItemTest.java @@ -1,8 +1,5 @@ package io.quarkus.vertx.http.deployment; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - import java.util.Optional; import org.junit.jupiter.api.Assertions; @@ -111,15 +108,15 @@ void testResolvePathWithSlashWithSlashQWithWildcards() { @Test void testResolveManagementPathWithRelativeRootPath() { - ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig = mock(ManagementInterfaceBuildTimeConfig.class); - when(managementInterfaceBuildTimeConfig.enabled()).thenReturn(true); - when(managementInterfaceBuildTimeConfig.rootPath()).thenReturn("management"); + ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig = new ManagementInterfaceBuildTimeConfig(); + managementInterfaceBuildTimeConfig.enabled = true; + managementInterfaceBuildTimeConfig.rootPath = "management"; LaunchModeBuildItem launchModeBuildItem = new LaunchModeBuildItem(LaunchMode.NORMAL, Optional.empty(), false, Optional.empty(), false); NonApplicationRootPathBuildItem buildItem = new NonApplicationRootPathBuildItem("/", "q", - managementInterfaceBuildTimeConfig.rootPath()); + managementInterfaceBuildTimeConfig.rootPath); Assertions.assertEquals("/management/", buildItem.getManagementRootPath()); Assertions.assertEquals("http://0.0.0.0:9000/management/foo", buildItem.resolveManagementPath("foo", managementInterfaceBuildTimeConfig, launchModeBuildItem)); @@ -137,15 +134,15 @@ void testResolveManagementPathWithRelativeRootPath() { @Test void testResolveManagementPathWithRelativeRootPathInTestMode() { - ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig = mock(ManagementInterfaceBuildTimeConfig.class); - when(managementInterfaceBuildTimeConfig.enabled()).thenReturn(true); - when(managementInterfaceBuildTimeConfig.rootPath()).thenReturn("management"); + ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig = new ManagementInterfaceBuildTimeConfig(); + managementInterfaceBuildTimeConfig.enabled = true; + managementInterfaceBuildTimeConfig.rootPath = "management"; LaunchModeBuildItem launchModeBuildItem = new LaunchModeBuildItem(LaunchMode.NORMAL, Optional.empty(), false, Optional.empty(), true); NonApplicationRootPathBuildItem buildItem = new NonApplicationRootPathBuildItem("/", "q", - managementInterfaceBuildTimeConfig.rootPath()); + managementInterfaceBuildTimeConfig.rootPath); Assertions.assertEquals("/management/", buildItem.getManagementRootPath()); Assertions.assertEquals("http://0.0.0.0:9001/management/foo", buildItem.resolveManagementPath("foo", managementInterfaceBuildTimeConfig, launchModeBuildItem)); @@ -163,9 +160,9 @@ void testResolveManagementPathWithRelativeRootPathInTestMode() { @Test void testResolveManagementPathWithRelativeRootPathAndWithManagementDisabled() { - ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig = mock(ManagementInterfaceBuildTimeConfig.class); - when(managementInterfaceBuildTimeConfig.enabled()).thenReturn(false); - when(managementInterfaceBuildTimeConfig.rootPath()).thenReturn("management"); + ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig = new ManagementInterfaceBuildTimeConfig(); + managementInterfaceBuildTimeConfig.enabled = false; + managementInterfaceBuildTimeConfig.rootPath = "management"; LaunchModeBuildItem launchModeBuildItem = new LaunchModeBuildItem(LaunchMode.NORMAL, Optional.empty(), false, Optional.empty(), false); @@ -189,15 +186,15 @@ void testResolveManagementPathWithRelativeRootPathAndWithManagementDisabled() { @Test void testResolveManagementPathWithAbsoluteRootPath() { - ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig = mock(ManagementInterfaceBuildTimeConfig.class); - when(managementInterfaceBuildTimeConfig.enabled()).thenReturn(true); - when(managementInterfaceBuildTimeConfig.rootPath()).thenReturn("/management"); + ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig = new ManagementInterfaceBuildTimeConfig(); + managementInterfaceBuildTimeConfig.enabled = true; + managementInterfaceBuildTimeConfig.rootPath = "/management"; LaunchModeBuildItem launchModeBuildItem = new LaunchModeBuildItem(LaunchMode.NORMAL, Optional.empty(), false, Optional.empty(), false); NonApplicationRootPathBuildItem buildItem = new NonApplicationRootPathBuildItem("/", "/q", - managementInterfaceBuildTimeConfig.rootPath()); + managementInterfaceBuildTimeConfig.rootPath); Assertions.assertEquals("/management/", buildItem.getManagementRootPath()); Assertions.assertEquals("http://0.0.0.0:9000/management/foo", buildItem.resolveManagementPath("foo", managementInterfaceBuildTimeConfig, launchModeBuildItem)); @@ -215,15 +212,15 @@ void testResolveManagementPathWithAbsoluteRootPath() { @Test void testResolveManagementPathWithEmptyRootPath() { - ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig = mock(ManagementInterfaceBuildTimeConfig.class); - when(managementInterfaceBuildTimeConfig.enabled()).thenReturn(true); - when(managementInterfaceBuildTimeConfig.rootPath()).thenReturn(""); + ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig = new ManagementInterfaceBuildTimeConfig(); + managementInterfaceBuildTimeConfig.enabled = true; + managementInterfaceBuildTimeConfig.rootPath = ""; LaunchModeBuildItem launchModeBuildItem = new LaunchModeBuildItem(LaunchMode.NORMAL, Optional.empty(), false, Optional.empty(), false); NonApplicationRootPathBuildItem buildItem = new NonApplicationRootPathBuildItem("/", "/q", - managementInterfaceBuildTimeConfig.rootPath()); + managementInterfaceBuildTimeConfig.rootPath); Assertions.assertEquals("/", buildItem.getManagementRootPath()); Assertions.assertEquals("http://0.0.0.0:9000/foo", buildItem.resolveManagementPath("foo", managementInterfaceBuildTimeConfig, launchModeBuildItem)); @@ -241,15 +238,15 @@ void testResolveManagementPathWithEmptyRootPath() { @Test void testResolveManagementPathWithWithWildcards() { - ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig = mock(ManagementInterfaceBuildTimeConfig.class); - when(managementInterfaceBuildTimeConfig.enabled()).thenReturn(true); - when(managementInterfaceBuildTimeConfig.rootPath()).thenReturn("/management"); + ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig = new ManagementInterfaceBuildTimeConfig(); + managementInterfaceBuildTimeConfig.enabled = true; + managementInterfaceBuildTimeConfig.rootPath = "/management"; LaunchModeBuildItem launchModeBuildItem = new LaunchModeBuildItem(LaunchMode.NORMAL, Optional.empty(), false, Optional.empty(), false); NonApplicationRootPathBuildItem buildItem = new NonApplicationRootPathBuildItem("/", "/q", - managementInterfaceBuildTimeConfig.rootPath()); + managementInterfaceBuildTimeConfig.rootPath); Assertions.assertEquals("http://0.0.0.0:9000/management/foo/*", buildItem.resolveManagementPath("foo/*", managementInterfaceBuildTimeConfig, launchModeBuildItem)); Assertions.assertEquals("http://0.0.0.0:9000/foo/*", diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/devmode/ArcEndpointTest.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/devmode/ArcEndpointTest.java index 2b950c476d2d6..a2644f677996e 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/devmode/ArcEndpointTest.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/devmode/ArcEndpointTest.java @@ -60,6 +60,7 @@ public void testBeans() { @Named @ApplicationScoped public static class Foo { + @Inject HttpBuildTimeConfig httpConfig; @@ -67,7 +68,8 @@ void onStart(@Observes StartupEvent event) { } void addConfigRoute(@Observes Router router) { - router.route("/console-path").handler(rc -> rc.response().end(httpConfig.nonApplicationRootPath())); + router.route("/console-path").handler(rc -> rc.response().end(httpConfig.nonApplicationRootPath)); } + } } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/DevUICORSFilter.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/DevUICORSFilter.java index 1e41984606bfd..ff8fd0c167f1e 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/DevUICORSFilter.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/DevUICORSFilter.java @@ -1,6 +1,5 @@ package io.quarkus.devui.runtime; -import java.time.Duration; import java.util.List; import java.util.Optional; @@ -33,38 +32,12 @@ public DevUICORSFilter() { private static CORSFilter corsFilter() { int httpPort = ConfigProvider.getConfig().getValue(HTTP_PORT_CONFIG_PROP, int.class); int httpsPort = ConfigProvider.getConfig().getValue(HTTPS_PORT_CONFIG_PROP, int.class); - CORSConfig config = new CORSConfig() { - @Override - public Optional> origins() { - return Optional.of(List.of(HTTP_LOCAL_HOST + ":" + httpPort, HTTP_LOCAL_HOST_IP + ":" + httpPort, - HTTPS_LOCAL_HOST + ":" + httpsPort, HTTPS_LOCAL_HOST_IP + ":" + httpsPort)); - } - - @Override - public Optional> methods() { - return Optional.empty(); - } - - @Override - public Optional> headers() { - return Optional.empty(); - } - - @Override - public Optional> exposedHeaders() { - return Optional.empty(); - } - - @Override - public Optional accessControlMaxAge() { - return Optional.empty(); - } - - @Override - public Optional accessControlAllowCredentials() { - return Optional.empty(); - } - }; + CORSConfig config = new CORSConfig(); + config.origins = Optional.of(List.of( + HTTP_LOCAL_HOST + ":" + httpPort, + HTTP_LOCAL_HOST_IP + ":" + httpPort, + HTTPS_LOCAL_HOST + ":" + httpsPort, + HTTPS_LOCAL_HOST_IP + ":" + httpsPort)); return new CORSFilter(config); } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/AccessLogConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/AccessLogConfig.java index 762dcd9fe4605..7c21a31bccfe1 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/AccessLogConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/AccessLogConfig.java @@ -2,19 +2,23 @@ import java.util.Optional; -import io.smallrye.config.WithDefault; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; + +@ConfigGroup +public class AccessLogConfig { -public interface AccessLogConfig { /** * If access logging is enabled. By default this will log via the standard logging facility */ - @WithDefault("false") - boolean enabled(); + @ConfigItem(defaultValue = "false") + public boolean enabled; /** * A regular expression that can be used to exclude some paths from logging. */ - Optional excludePattern(); + @ConfigItem + Optional excludePattern; /** * The access log pattern. @@ -29,46 +33,48 @@ public interface AccessLogConfig { * * @asciidoclet */ - @WithDefault("common") - String pattern(); + @ConfigItem(defaultValue = "common") + public String pattern; /** * If logging should be done to a separate file. */ - @WithDefault("false") - boolean logToFile(); + @ConfigItem(defaultValue = "false") + public boolean logToFile; /** * The access log file base name, defaults to 'quarkus' which will give a log file * name of 'quarkus.log'. * */ - @WithDefault("quarkus") - String baseFileName(); + @ConfigItem(defaultValue = "quarkus") + public String baseFileName; /** * The log directory to use when logging access to a file * * If this is not set then the current working directory is used. */ - Optional logDirectory(); + @ConfigItem + public Optional logDirectory; /** * The log file suffix */ - @WithDefault(".log") - String logSuffix(); + @ConfigItem(defaultValue = ".log") + public String logSuffix; /** * The log category to use if logging is being done via the standard log mechanism (i.e. if base-file-name is empty). * */ - @WithDefault("io.quarkus.http.access-log") - String category(); + @ConfigItem(defaultValue = "io.quarkus.http.access-log") + public String category; /** * If the log should be rotated daily */ - @WithDefault("true") - boolean rotate(); + @ConfigItem(defaultValue = "true") + public boolean rotate; + } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/AuthConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/AuthConfig.java index 7bba5d0245741..3e609d66f9825 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/AuthConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/AuthConfig.java @@ -3,42 +3,46 @@ import java.util.Map; import java.util.Optional; -import io.smallrye.config.WithDefault; -import io.smallrye.config.WithName; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; /** * Authentication mechanism and SecurityRealm name information used for configuring HTTP auth * instance for the deployment. */ -public interface AuthConfig { +@ConfigGroup +public class AuthConfig { /** * If basic auth should be enabled. If both basic and form auth is enabled then basic auth will be enabled in silent mode. * * If no authentication mechanisms are configured basic auth is the default. */ - Optional basic(); + @ConfigItem + public Optional basic; /** * Form Auth config */ - FormAuthConfig form(); + @ConfigItem + public FormAuthConfig form; /** * The authentication realm */ - Optional realm(); + @ConfigItem + public Optional realm; /** * The HTTP permissions */ - @WithName("permission") - Map permissions(); + @ConfigItem(name = "permission") + public Map permissions; /** * The HTTP role based policies */ - @WithName("policy") - Map rolePolicy(); + @ConfigItem(name = "policy") + public Map rolePolicy; /** * If this is true and credentials are present then a user will always be authenticated @@ -47,6 +51,6 @@ public interface AuthConfig { * If this is false then an attempt will only be made to authenticate the user if a permission * check is performed or the current user is required for some other reason. */ - @WithDefault("true") - boolean proactive(); + @ConfigItem(defaultValue = "true") + public boolean proactive; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/BodyConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/BodyConfig.java index b404a052b0111..1c8723f7f33e4 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/BodyConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/BodyConfig.java @@ -1,11 +1,14 @@ package io.quarkus.vertx.http.runtime; -import io.smallrye.config.WithDefault; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; /** * Request body related settings */ -public interface BodyConfig { +@ConfigGroup +public class BodyConfig { + /** * Whether the files sent using {@code multipart/form-data} will be stored locally. *

@@ -15,16 +18,16 @@ public interface BodyConfig { * will always return an empty collection. Note that even with this option being set to {@code false}, the * {@code multipart/form-data} requests will be accepted. */ - @WithDefault("true") - boolean handleFileUploads(); + @ConfigItem(defaultValue = "true") + public boolean handleFileUploads; /** * The directory where the files sent using {@code multipart/form-data} should be stored. *

* Either an absolute path or a path relative to the current directory of the application process. */ - @WithDefault("${java.io.tmpdir}/uploads") - String uploadsDirectory(); + @ConfigItem(defaultValue = "${java.io.tmpdir}/uploads") + public String uploadsDirectory; /** * Whether the form attributes should be added to the request parameters. @@ -32,8 +35,8 @@ public interface BodyConfig { * If {@code true}, the form attributes will be added to the request parameters; otherwise the form parameters will * not be added to the request parameters */ - @WithDefault("true") - boolean mergeFormAttributes(); + @ConfigItem(defaultValue = "true") + public boolean mergeFormAttributes; /** * Whether the uploaded files should be removed after serving the request. @@ -41,8 +44,8 @@ public interface BodyConfig { * If {@code true} the uploaded files stored in {@code quarkus.http.body-handler.uploads-directory} will be removed * after handling the request. Otherwise, the files will be left there forever. */ - @WithDefault("true") - boolean deleteUploadedFilesOnEnd(); + @ConfigItem(defaultValue = "true") + public boolean deleteUploadedFilesOnEnd; /** * Whether the body buffer should pre-allocated based on the {@code Content-Length} header value. @@ -50,11 +53,12 @@ public interface BodyConfig { * If {@code true} the body buffer is pre-allocated according to the size read from the {@code Content-Length} * header. Otherwise, the body buffer is pre-allocated to 1KB, and is resized dynamically */ - @WithDefault("false") - boolean preallocateBodyBuffer(); + @ConfigItem + public boolean preallocateBodyBuffer; /** * HTTP multipart request related settings */ - MultiPartConfig multipart(); + @ConfigItem + public MultiPartConfig multipart; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/CertificateConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/CertificateConfig.java index f28028bbfbd87..1d8fa0a4f5936 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/CertificateConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/CertificateConfig.java @@ -4,13 +4,18 @@ import java.util.List; import java.util.Optional; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConvertWith; import io.quarkus.runtime.configuration.TrimmedStringConverter; -import io.smallrye.config.WithConverter; /** * A certificate configuration. Either the certificate and key files must be given, or a key store must be given. */ -public interface CertificateConfig { +@ConfigGroup +@SuppressWarnings("OptionalUsedAsFieldOrParameterType") +public class CertificateConfig { + /** * The {@linkplain CredentialsProvider}. * If this property is configured then a matching 'CredentialsProvider' will be used @@ -19,8 +24,9 @@ public interface CertificateConfig { * Please note that using MicroProfile {@linkplain ConfigSource} which is directly supported by Quarkus Configuration * should be preferred unless using `CredentialsProvider` provides for some additional security and dynamism. */ - @WithConverter(TrimmedStringConverter.class) - Optional credentialsProvider(); + @ConfigItem + @ConvertWith(TrimmedStringConverter.class) + public Optional credentialsProvider = Optional.empty(); /** * The credentials provider bean name. @@ -30,14 +36,16 @@ public interface CertificateConfig { * It is recommended to set this property even if there is only one credentials provider currently available * to ensure the same provider is always found in deployments where more than one provider may be available. */ - @WithConverter(TrimmedStringConverter.class) - Optional credentialsProviderName(); + @ConfigItem + @ConvertWith(TrimmedStringConverter.class) + public Optional credentialsProviderName = Optional.empty(); /** * The list of path to server certificates using the PEM format. * Specifying multiple files require SNI to be enabled. */ - Optional> files(); + @ConfigItem + public Optional> files; /** * The list of path to server certificates private key file using the PEM format. @@ -45,24 +53,28 @@ public interface CertificateConfig { * * The order of the key files must match the order of the certificates. */ - Optional> keyFiles(); + @ConfigItem + public Optional> keyFiles; /** * An optional key store which holds the certificate information instead of specifying separate files. */ - Optional keyStoreFile(); + @ConfigItem + public Optional keyStoreFile; /** * An optional parameter to specify type of the key store file. If not given, the type is automatically detected * based on the file name. */ - Optional keyStoreFileType(); + @ConfigItem + public Optional keyStoreFileType; /** * An optional parameter to specify a provider of the key store file. If not given, the provider is automatically detected * based on the key store file type. */ - Optional keyStoreProvider(); + @ConfigItem + public Optional keyStoreProvider; /** * A parameter to specify the password of the key store file. If not given, and if it can not be retrieved from @@ -70,7 +82,8 @@ public interface CertificateConfig { * * @see {@link #credentialsProvider} */ - Optional keyStorePassword(); + @ConfigItem(defaultValueDocumentation = "password") + public Optional keyStorePassword; /** * A parameter to specify a {@linkplain CredentialsProvider} property key which can be used to get the password of the key @@ -79,13 +92,15 @@ public interface CertificateConfig { * * @see {@link #credentialsProvider} */ - Optional keyStorePasswordKey(); + @ConfigItem + public Optional keyStorePasswordKey; /** * An optional parameter to select a specific key in the key store. When SNI is disabled, if the key store contains multiple * keys and no alias is specified, the behavior is undefined. */ - Optional keyStoreKeyAlias(); + @ConfigItem + public Optional keyStoreKeyAlias; /** * An optional parameter to define the password for the key, in case it's different from {@link #keyStorePassword} @@ -93,7 +108,8 @@ public interface CertificateConfig { * * @see {@link #credentialsProvider}. */ - Optional keyStoreKeyPassword(); + @ConfigItem + public Optional keyStoreKeyPassword; /** * A parameter to specify a {@linkplain CredentialsProvider} property key which can be used to get the password for the key @@ -101,24 +117,28 @@ public interface CertificateConfig { * * @see {@link #credentialsProvider} */ - Optional keyStoreKeyPasswordKey(); + @ConfigItem + public Optional keyStoreKeyPasswordKey; /** * An optional trust store which holds the certificate information of the certificates to trust. */ - Optional trustStoreFile(); + @ConfigItem + public Optional trustStoreFile; /** * An optional parameter to specify type of the trust store file. If not given, the type is automatically detected * based on the file name. */ - Optional trustStoreFileType(); + @ConfigItem + public Optional trustStoreFileType; /** * An optional parameter to specify a provider of the trust store file. If not given, the provider is automatically detected * based on the trust store file type. */ - Optional trustStoreProvider(); + @ConfigItem + public Optional trustStoreProvider; /** * A parameter to specify the password of the trust store file. @@ -126,7 +146,8 @@ public interface CertificateConfig { * * @see {@link #credentialsProvider}. */ - Optional trustStorePassword(); + @ConfigItem + public Optional trustStorePassword; /** * A parameter to specify a {@linkplain CredentialsProvider} property key which can be used to get the password of the trust @@ -135,11 +156,13 @@ public interface CertificateConfig { * * @see {@link #credentialsProvider} */ - Optional trustStorePasswordKey(); + @ConfigItem + public Optional trustStorePasswordKey; /** * An optional parameter to trust only one specific certificate in the trust store (instead of trusting all certificates in * the store). */ - Optional trustStoreCertAlias(); + @ConfigItem + public Optional trustStoreCertAlias; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/FilterConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/FilterConfig.java index 33a0fe44ea739..285a581d7759f 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/FilterConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/FilterConfig.java @@ -5,25 +5,32 @@ import java.util.Optional; import java.util.OptionalInt; -public interface FilterConfig { +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; + +@ConfigGroup +public class FilterConfig { /** * A regular expression for the paths matching this configuration */ - String matches(); + @ConfigItem + public String matches; /** * Additional HTTP Headers always sent in the response */ - Map header(); + @ConfigItem + public Map header; /** * The HTTP methods for this path configuration */ - Optional> methods(); + @ConfigItem + public Optional> methods; /** * Order in which this path config is applied. Higher priority takes precedence */ - OptionalInt order(); + public OptionalInt order; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/FormAuthConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/FormAuthConfig.java index bd47b3d99ef94..e08e6595129ba 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/FormAuthConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/FormAuthConfig.java @@ -3,16 +3,18 @@ import java.time.Duration; import java.util.Optional; -import io.smallrye.config.WithDefault; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; /** * config for the form authentication mechanism */ -public interface FormAuthConfig { +@ConfigGroup +public class FormAuthConfig { /** * SameSite attribute values for the session and location cookies. */ - enum CookieSameSite { + public enum CookieSameSite { STRICT, LAX, NONE @@ -21,45 +23,45 @@ enum CookieSameSite { /** * If form authentication is enabled. */ - @WithDefault("false") - boolean enabled(); + @ConfigItem + public boolean enabled; /** * The login page. Redirect to login page can be disabled by setting `quarkus.http.auth.form.login-page=`. */ - @WithDefault("/login.html") - Optional loginPage(); + @ConfigItem(defaultValue = "/login.html") + public Optional loginPage; /** * The post location. */ - @WithDefault("/j_security_check") - String postLocation(); + @ConfigItem(defaultValue = "/j_security_check") + public String postLocation; /** * The username field name. */ - @WithDefault("j_username") - String usernameParameter(); + @ConfigItem(defaultValue = "j_username") + public String usernameParameter; /** * The password field name. */ - @WithDefault("j_password") - String passwordParameter(); + @ConfigItem(defaultValue = "j_password") + public String passwordParameter; /** * The error page. Redirect to error page can be disabled by setting `quarkus.http.auth.form.error-page=`. */ - @WithDefault("/error.html") - Optional errorPage(); + @ConfigItem(defaultValue = "/error.html") + public Optional errorPage; /** * The landing page to redirect to if there is no saved page to redirect back to. * Redirect to landing page can be disabled by setting `quarkus.http.auth.form.landing-page=`. */ - @WithDefault("/index.html") - Optional landingPage(); + @ConfigItem(defaultValue = "/index.html") + public Optional landingPage; /** * Option to disable redirect to landingPage if there is no saved page to redirect back to. Form Auth POST is followed @@ -69,24 +71,24 @@ enum CookieSameSite { * (via `quarkus.http.auth.form.landing-page=`). Quarkus will ignore this configuration property * if there is no landing page. */ - @WithDefault("true") + @ConfigItem(defaultValue = "true") @Deprecated - boolean redirectAfterLogin(); + public boolean redirectAfterLogin; /** * Option to control the name of the cookie used to redirect the user back * to where he wants to get access to. */ - @WithDefault("quarkus-redirect-location") - String locationCookie(); + @ConfigItem(defaultValue = "quarkus-redirect-location") + public String locationCookie; /** * The inactivity (idle) timeout * * When inactivity timeout is reached, cookie is not renewed and a new login is enforced. */ - @WithDefault("PT30M") - Duration timeout(); + @ConfigItem(defaultValue = "PT30M") + public Duration timeout; /** * How old a cookie can get before it will be replaced with a new cookie with an updated timeout, also @@ -103,30 +105,30 @@ enum CookieSameSite { * In other words no timeout is tracked on the server side; the timestamp is encoded and encrypted in the cookie itself, * and it is decrypted and parsed with each request. */ - @WithDefault("PT1M") - Duration newCookieInterval(); + @ConfigItem(defaultValue = "PT1M") + public Duration newCookieInterval; /** * The cookie that is used to store the persistent session */ - @WithDefault("quarkus-credential") - String cookieName(); + @ConfigItem(defaultValue = "quarkus-credential") + public String cookieName; /** * The cookie path for the session and location cookies. */ - @WithDefault("/") - Optional cookiePath(); + @ConfigItem(defaultValue = "/") + public Optional cookiePath = Optional.of("/"); /** * Set the HttpOnly attribute to prevent access to the cookie via JavaScript. */ - @WithDefault("false") - boolean httpOnlyCookie(); + @ConfigItem(defaultValue = "false") + public boolean httpOnlyCookie; /** * SameSite attribute for the session and location cookies. */ - @WithDefault("strict") - CookieSameSite cookieSameSite(); + @ConfigItem(defaultValue = "strict") + public CookieSameSite cookieSameSite = CookieSameSite.STRICT; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardingProxyOptions.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardingProxyOptions.java index 38de21a30e306..e7c0cf032a6fb 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardingProxyOptions.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardingProxyOptions.java @@ -35,17 +35,17 @@ public ForwardingProxyOptions(final boolean proxyAddressForwarding, } public static ForwardingProxyOptions from(ProxyConfig proxy) { - final boolean proxyAddressForwarding = proxy.proxyAddressForwarding(); - final boolean allowForwarded = proxy.allowForwarded(); - final boolean allowXForwarded = proxy.allowXForwarded().orElse(!allowForwarded); + final boolean proxyAddressForwarding = proxy.proxyAddressForwarding; + final boolean allowForwarded = proxy.allowForwarded; + final boolean allowXForwarded = proxy.allowXForwarded.orElse(!allowForwarded); - final boolean enableForwardedHost = proxy.enableForwardedHost(); - final boolean enableForwardedPrefix = proxy.enableForwardedPrefix(); - final AsciiString forwardedPrefixHeader = AsciiString.cached(proxy.forwardedPrefixHeader()); - final AsciiString forwardedHostHeader = AsciiString.cached(proxy.forwardedHostHeader()); + final boolean enableForwardedHost = proxy.enableForwardedHost; + final boolean enableForwardedPrefix = proxy.enableForwardedPrefix; + final AsciiString forwardedPrefixHeader = AsciiString.cached(proxy.forwardedPrefixHeader); + final AsciiString forwardedHostHeader = AsciiString.cached(proxy.forwardedHostHeader); - final List parts = proxy.trustedProxies() - .isPresent() ? List.copyOf(proxy.trustedProxies().get()) : List.of(); + final List parts = proxy.trustedProxies + .isPresent() ? List.copyOf(proxy.trustedProxies.get()) : List.of(); final var proxyCheckBuilder = (!allowXForwarded && !allowForwarded) || parts.isEmpty() ? null : TrustedProxyCheckBuilder.builder(parts); diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/HeaderConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/HeaderConfig.java index 3996865b37a8f..98a247bf2f0cd 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/HeaderConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/HeaderConfig.java @@ -3,26 +3,30 @@ import java.util.List; import java.util.Optional; -import io.smallrye.config.WithDefault; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; /** * Configuration that allows for setting an HTTP header */ -public interface HeaderConfig { +@ConfigGroup +public class HeaderConfig { /** * The path this header should be applied */ - @WithDefault("/*") - String path(); + @ConfigItem(defaultValue = "/*") + public String path; /** * The value for this header configuration */ - String value(); + @ConfigItem + public String value; /** * The HTTP methods for this header configuration */ - Optional> methods(); + @ConfigItem + public Optional> methods; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/HttpBuildTimeConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/HttpBuildTimeConfig.java index a269e2f216600..e672c5e7e0769 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/HttpBuildTimeConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/HttpBuildTimeConfig.java @@ -5,46 +5,40 @@ import java.util.Optional; import java.util.OptionalInt; +import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.quarkus.runtime.annotations.ConvertWith; import io.quarkus.runtime.configuration.NormalizeRootHttpPathConverter; import io.quarkus.vertx.http.Compressed; import io.quarkus.vertx.http.Uncompressed; -import io.smallrye.config.ConfigMapping; -import io.smallrye.config.WithConverter; -import io.smallrye.config.WithDefault; -import io.smallrye.config.WithName; import io.vertx.core.http.ClientAuth; -@ConfigMapping(prefix = "quarkus.http") -@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface HttpBuildTimeConfig { +@ConfigRoot(name = "http", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +public class HttpBuildTimeConfig { + /** * The HTTP root path. All web content will be served relative to this root path. */ - @WithDefault("/") - @WithConverter(NormalizeRootHttpPathConverter.class) - String rootPath(); + @ConfigItem(defaultValue = "/") + @ConvertWith(NormalizeRootHttpPathConverter.class) + public String rootPath; - /** - * Authentication configuration. - */ - AuthConfig auth(); + public AuthConfig auth; /** * Configures the engine to require/request client authentication. * NONE, REQUEST, REQUIRED */ - @WithName("ssl.client-auth") - @WithDefault("NONE") - ClientAuth tlsClientAuth(); + @ConfigItem(name = "ssl.client-auth", defaultValue = "NONE") + public ClientAuth tlsClientAuth; /** * If this is true then only a virtual channel will be set up for vertx web. * We have this switch for testing purposes. */ - @WithDefault("false") - boolean virtual(); + @ConfigItem + public boolean virtual; /** * A common root path for non-application endpoints. Various extension-provided endpoints such as metrics, health, @@ -63,14 +57,14 @@ public interface HttpBuildTimeConfig { * * @asciidoclet */ - @WithDefault("q") - String nonApplicationRootPath(); + @ConfigItem(defaultValue = "q") + public String nonApplicationRootPath; /** * The REST Assured client timeout for testing. */ - @WithDefault("30s") - Duration testTimeout(); + @ConfigItem(defaultValue = "30s") + public Duration testTimeout; /** * If enabled then the response body is compressed if the {@code Content-Type} header is set and the value is a compressed @@ -80,8 +74,8 @@ public interface HttpBuildTimeConfig { * declaratively using the annotations {@link io.quarkus.vertx.http.Compressed} and * {@link io.quarkus.vertx.http.Uncompressed}. */ - @WithDefault("false") - boolean enableCompression(); + @ConfigItem + public boolean enableCompression; /** * When enabled, vert.x will decompress the request's body if it's compressed. @@ -89,18 +83,19 @@ public interface HttpBuildTimeConfig { * Note that the compression format (e.g., gzip) must be specified in the Content-Encoding header * in the request. */ - @WithDefault("false") - boolean enableDecompression(); + @ConfigItem + public boolean enableDecompression; /** * List of media types for which the compression should be enabled automatically, unless declared explicitly via * {@link Compressed} or {@link Uncompressed}. */ - @WithDefault("text/html,text/plain,text/xml,text/css,text/javascript,application/javascript") - Optional> compressMediaTypes(); + @ConfigItem(defaultValue = "text/html,text/plain,text/xml,text/css,text/javascript,application/javascript") + public Optional> compressMediaTypes; /** * The compression level used when compression support is enabled. */ - OptionalInt compressionLevel(); + @ConfigItem + public OptionalInt compressionLevel; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/HttpConfiguration.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/HttpConfiguration.java index 91b5c60669dfd..c301b99754848 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/HttpConfiguration.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/HttpConfiguration.java @@ -6,45 +6,31 @@ import java.util.OptionalInt; import io.quarkus.runtime.LaunchMode; +import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.quarkus.vertx.http.runtime.cors.CORSConfig; -import io.smallrye.config.ConfigMapping; -import io.smallrye.config.WithDefault; -import io.smallrye.config.WithName; -@ConfigMapping(prefix = "quarkus.http") @ConfigRoot(phase = ConfigPhase.RUN_TIME) -public interface HttpConfiguration { - /** - * Enable the CORS filter. - * - * @deprecated Use {@link HttpConfiguration#corsEnabled()}. Deprecated because it requires additional syntax to - * configure with the group {@link HttpConfiguration#cors()} in YAML config. - */ - @WithName("cors") - @WithDefault("false") - @Deprecated - boolean oldCorsEnabled(); +public class HttpConfiguration { /** * Enable the CORS filter. */ - @WithName("cors.enabled") - @WithDefault("${quarkus.http.cors:false}") - boolean corsEnabled(); + @ConfigItem(name = "cors") + public boolean corsEnabled; /** * The HTTP port */ - @WithDefault("8080") - int port(); + @ConfigItem(defaultValue = "8080") + public int port; /** * The HTTP port used to run tests */ - @WithDefault("8081") - int testPort(); + @ConfigItem(defaultValue = "8081") + public int testPort; /** * The HTTP host @@ -55,37 +41,40 @@ public interface HttpConfiguration { * is not suitable for dev/test mode as other people on the network can connect to your * development machine. */ - String host(); + @ConfigItem + public String host; /** * Used when {@code QuarkusIntegrationTest} is meant to execute against an application that is already running and * listening on the host specified by this property. */ - Optional testHost(); + @ConfigItem + public Optional testHost; /** * Enable listening to host:port */ - @WithDefault("true") - boolean hostEnabled(); + @ConfigItem(defaultValue = "true") + public boolean hostEnabled; /** * The HTTPS port */ - @WithDefault("8443") - int sslPort(); + @ConfigItem(defaultValue = "8443") + public int sslPort; /** * The HTTPS port used to run tests */ - @WithDefault("8444") - int testSslPort(); + @ConfigItem(defaultValue = "8444") + public int testSslPort; /** * Used when {@code QuarkusIntegrationTest} is meant to execute against an application that is already running * to configure the test to use SSL. */ - Optional testSslEnabled(); + @ConfigItem + public Optional testSslEnabled; /** * If insecure (i.e. http rather than https) requests are allowed. If this is {@code enabled} @@ -93,8 +82,8 @@ public interface HttpConfiguration { * all requests will be redirected to the HTTPS port. {@code disabled} will prevent the HTTP * port from opening at all. */ - @WithDefault("enabled") - InsecureRequests insecureRequests(); + @ConfigItem(defaultValue = "enabled") + public InsecureRequests insecureRequests; /** * If this is true (the default) then HTTP/2 will be enabled. @@ -103,39 +92,38 @@ public interface HttpConfiguration { * and you must be running on JDK11 or above, as JDK8 does not support * ALPN. */ - @WithDefault("true") - boolean http2(); + @ConfigItem(defaultValue = "true") + public boolean http2; /** * Enables or Disable the HTTP/2 Push feature. * This setting can be used to disable server push. The server will not send a {@code PUSH_PROMISE} frame if it * receives this parameter set to @{code false}. */ - @WithDefault("true") - boolean http2PushEnabled(); + @ConfigItem(defaultValue = "true") + public boolean http2PushEnabled; /** * The CORS config */ - CORSConfig cors(); + public CORSConfig cors; /** * The SSL config */ - ServerSslConfig ssl(); + public ServerSslConfig ssl; /** * The Static Resources config */ - StaticResourcesConfig staticResources(); + public StaticResourcesConfig staticResources; /** * When set to {@code true}, the HTTP server automatically sends `100 CONTINUE` * response when the request expects it (with the `Expect: 100-Continue` header). */ - @WithName("handle-100-continue-automatically") - @WithDefault("false") - boolean handle100ContinueAutomatically(); + @ConfigItem(defaultValue = "false", name = "handle-100-continue-automatically") + public boolean handle100ContinueAutomatically; /** * The number if IO threads used to perform IO. This will be automatically set to a reasonable value based on @@ -145,19 +133,19 @@ public interface HttpConfiguration { * In general this should be controlled by setting quarkus.vertx.event-loops-pool-size, this setting should only * be used if you want to limit the number of HTTP io threads to a smaller number than the total number of IO threads. */ - OptionalInt ioThreads(); + @ConfigItem + public OptionalInt ioThreads; /** * Server limits configuration */ - ServerLimitsConfig limits(); + public ServerLimitsConfig limits; /** * Http connection idle timeout */ - @WithName("idle-timeout") - @WithDefault("30M") - Duration idleTimeout(); + @ConfigItem(defaultValue = "30M", name = "idle-timeout") + public Duration idleTimeout; /** * Http connection read timeout for blocking IO. This is the maximum amount of time @@ -165,14 +153,13 @@ public interface HttpConfiguration { * closed. * */ - @WithName("read-timeout") - @WithDefault("60s") - Duration readTimeout(); + @ConfigItem(defaultValue = "60s", name = "read-timeout") + public Duration readTimeout; /** * Request body related settings */ - BodyConfig body(); + public BodyConfig body; /** * The encryption key that is used to store persistent logins (e.g. for form auth). Logins are stored in a persistent @@ -181,75 +168,74 @@ public interface HttpConfiguration { * If no key is provided then an in-memory one will be generated, this will change on every restart though so it * is not suitable for production environments. This must be more than 16 characters long for security reasons */ - @WithName("auth.session.encryption-key") - Optional encryptionKey(); + @ConfigItem(name = "auth.session.encryption-key") + public Optional encryptionKey; /** * Enable socket reuse port (linux/macOs native transport only) */ - @WithDefault("false") - boolean soReusePort(); + @ConfigItem + public boolean soReusePort; /** * Enable tcp quick ack (linux native transport only) */ - @WithDefault("false") - boolean tcpQuickAck(); + @ConfigItem + public boolean tcpQuickAck; /** * Enable tcp cork (linux native transport only) */ - @WithDefault("false") - boolean tcpCork(); + @ConfigItem + public boolean tcpCork; /** * Enable tcp fast open (linux native transport only) */ - @WithDefault("false") - boolean tcpFastOpen(); + @ConfigItem + public boolean tcpFastOpen; /** * The accept backlog, this is how many connections can be waiting to be accepted before connections start being rejected */ - @WithDefault("-1") - int acceptBacklog(); + @ConfigItem(defaultValue = "-1") + public int acceptBacklog; /** * Set the SETTINGS_INITIAL_WINDOW_SIZE HTTP/2 setting. * Indicates the sender's initial window size (in octets) for stream-level flow control. * The initial value is {@code 2^16-1} (65,535) octets. */ - OptionalInt initialWindowSize(); + @ConfigItem + public OptionalInt initialWindowSize; /** * Path to a unix domain socket */ - @WithDefault("/var/run/io.quarkus.app.socket") - String domainSocket(); + @ConfigItem(defaultValue = "/var/run/io.quarkus.app.socket") + public String domainSocket; /** * Enable listening to host:port */ - @WithDefault("false") - boolean domainSocketEnabled(); + @ConfigItem + public boolean domainSocketEnabled; /** * If this is true then the request start time will be recorded to enable logging of total request time. * * This has a small performance penalty, so is disabled by default. */ - @WithDefault("false") - boolean recordRequestStartTime(); + @ConfigItem + public boolean recordRequestStartTime; - /** - * Access log configuration. - */ - AccessLogConfig accessLog(); + AccessLogConfig accessLog; /** * Configuration that allows setting the same site attributes for cookies. */ - Map sameSiteCookie(); + @ConfigItem + public Map sameSiteCookie; /** * Provides a hint (optional) for the default content type of responses generated for @@ -262,38 +248,38 @@ public interface HttpConfiguration { * Otherwise, it will default to the content type configured here. *

*/ - Optional unhandledErrorContentTypeDefault(); + @ConfigItem + public Optional unhandledErrorContentTypeDefault; /** * Additional HTTP Headers always sent in the response */ - Map header(); + @ConfigItem + public Map header; /** * Additional HTTP configuration per path */ - Map filter(); + @ConfigItem + public Map filter; - /** - * Proxy configuration. - */ - ProxyConfig proxy(); + public ProxyConfig proxy; - default int determinePort(LaunchMode launchMode) { - return launchMode == LaunchMode.TEST ? testPort() : port(); + public int determinePort(LaunchMode launchMode) { + return launchMode == LaunchMode.TEST ? testPort : port; } - default int determineSslPort(LaunchMode launchMode) { - return launchMode == LaunchMode.TEST ? testSslPort() : sslPort(); + public int determineSslPort(LaunchMode launchMode) { + return launchMode == LaunchMode.TEST ? testSslPort : sslPort; } - enum InsecureRequests { + public enum InsecureRequests { ENABLED, REDIRECT, DISABLED; } - enum PayloadHint { + public enum PayloadHint { JSON, HTML, } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/MultiPartConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/MultiPartConfig.java index dc6981d8d7adc..43cfe26f7ed3a 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/MultiPartConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/MultiPartConfig.java @@ -4,13 +4,16 @@ import java.util.Optional; import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConvertWith; import io.quarkus.runtime.configuration.TrimmedStringConverter; -import io.smallrye.config.WithConverter; /** * A {@link ConfigGroup} for the settings related to HTTP multipart request handling. */ -public interface MultiPartConfig { +@ConfigGroup +public class MultiPartConfig { + /** * A comma-separated list of {@code ContentType} to indicate whether a given multipart field should be handled as a file * part. @@ -19,5 +22,7 @@ public interface MultiPartConfig { * * For now, this setting only works when using RESTEasy Reactive. */ - Optional> fileContentTypes(); + @ConfigItem + @ConvertWith(TrimmedStringConverter.class) + public Optional> fileContentTypes; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/PolicyConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/PolicyConfig.java index 9ebad5f0baf66..7d16bc2f4e392 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/PolicyConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/PolicyConfig.java @@ -4,18 +4,22 @@ import java.util.Map; import io.quarkus.runtime.annotations.ConfigDocMapKey; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConvertWith; import io.quarkus.runtime.configuration.TrimmedStringConverter; -import io.smallrye.config.WithConverter; -import io.smallrye.config.WithDefault; +import io.quarkus.security.StringPermission; + +@ConfigGroup +public class PolicyConfig { -public interface PolicyConfig { /** * The roles that are allowed to access resources protected by this policy. * By default, access is allowed to any authenticated user. */ - @WithDefault("**") - @WithConverter(TrimmedStringConverter.class) - List rolesAllowed(); + @ConfigItem(defaultValue = "**") + @ConvertWith(TrimmedStringConverter.class) + public List rolesAllowed; /** * Permissions granted to the `SecurityIdentity` if this policy is applied successfully @@ -25,13 +29,15 @@ public interface PolicyConfig { * Granted permissions are used for authorization with the `@PermissionsAllowed` annotation. */ @ConfigDocMapKey("role1") - Map> permissions(); + @ConfigItem + public Map> permissions; /** * Permissions granted by this policy will be created with a `java.security.Permission` implementation * specified by this configuration property. The permission class must declare exactly one constructor * that accepts permission name (`String`) or permission name and actions (`String`, `String[]`). */ - @WithDefault("io.quarkus.security.StringPermission") - String permissionClass(); + @ConfigItem(defaultValue = "io.quarkus.security.StringPermission") + public String permissionClass = StringPermission.class.getName(); + } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/PolicyMappingConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/PolicyMappingConfig.java index 5bad6b162d114..d78640f6913f6 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/PolicyMappingConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/PolicyMappingConfig.java @@ -3,13 +3,19 @@ import java.util.List; import java.util.Optional; -public interface PolicyMappingConfig { +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; + +@ConfigGroup +public class PolicyMappingConfig { + /** * Determines whether the entire permission set is enabled, or not. * * By default, if the permission set is defined, it is enabled. */ - Optional enabled(); + @ConfigItem + public Optional enabled; /** * The HTTP policy that this permission set is linked to. @@ -17,7 +23,8 @@ public interface PolicyMappingConfig { * There are 3 built in policies: permit, deny and authenticated. Role based * policies can be defined, and extensions can add their own policies. */ - String policy(); + @ConfigItem + public String policy; /** * The methods that this permission set applies to. If this is not set then they apply to all methods. @@ -31,7 +38,8 @@ public interface PolicyMappingConfig { * and no other permissions are configured PUT requests to /admin will be denied. * */ - Optional> methods(); + @ConfigItem + public Optional> methods; /** * The paths that this permission check applies to. If the path ends in /* then this is treated @@ -43,11 +51,13 @@ public interface PolicyMappingConfig { * over matches without methods set, otherwise the most restrictive permissions are applied. * */ - Optional> paths(); + @ConfigItem + public Optional> paths; /** * Path specific authentication mechanism which must be used to authenticate a user. * It needs to match {@link HttpCredentialTransport} authentication scheme such as 'basic', 'bearer', 'form', etc. */ - Optional authMechanism(); + @ConfigItem + public Optional authMechanism; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ProxyConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ProxyConfig.java index 7aaf42dfe5703..f4a2f557c796b 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ProxyConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ProxyConfig.java @@ -3,30 +3,31 @@ import java.util.List; import java.util.Optional; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConvertWith; import io.quarkus.vertx.http.runtime.TrustedProxyCheck.TrustedProxyCheckPart; -import io.smallrye.config.WithConverter; -import io.smallrye.config.WithDefault; /** * Holds configuration related with proxy addressing forward. */ -public interface ProxyConfig { - +@ConfigGroup +public class ProxyConfig { /** * Set whether the server should use the HA {@code PROXY} protocol when serving requests from behind a proxy. * (see the PROXY Protocol). * When set to {@code true}, the remote address returned will be the one from the actual connecting client. * If it is set to {@code false} (default), the remote address returned will be the one from the proxy. */ - @WithDefault("false") - boolean useProxyProtocol(); + @ConfigItem(defaultValue = "false") + public boolean useProxyProtocol; /** * If this is true then the address, scheme etc. will be set from headers forwarded by the proxy server, such as * {@code X-Forwarded-For}. This should only be set if you are behind a proxy that sets these headers. */ - @WithDefault("false") - boolean proxyAddressForwarding(); + @ConfigItem + public boolean proxyAddressForwarding; /** * If this is true and proxy address forwarding is enabled then the standard {@code Forwarded} header will be used. @@ -36,8 +37,8 @@ public interface ProxyConfig { * requests with a forwarded header that is not overwritten by the proxy. Therefore, proxies should strip unexpected * `X-Forwarded` or `X-Forwarded-*` headers from the client. */ - @WithDefault("false") - boolean allowForwarded(); + @ConfigItem + public boolean allowForwarded; /** * If either this or {@code allow-forwarded} are true and proxy address forwarding is enabled then the not standard @@ -48,31 +49,32 @@ public interface ProxyConfig { * requests with a forwarded header that is not overwritten by the proxy. Therefore, proxies should strip unexpected * `X-Forwarded` or `X-Forwarded-*` headers from the client. */ - Optional allowXForwarded(); + @ConfigItem + public Optional allowXForwarded; /** * Enable override the received request's host through a forwarded host header. */ - @WithDefault("false") - boolean enableForwardedHost(); + @ConfigItem(defaultValue = "false") + public boolean enableForwardedHost; /** * Configure the forwarded host header to be used if override enabled. */ - @WithDefault("X-Forwarded-Host") - String forwardedHostHeader(); + @ConfigItem(defaultValue = "X-Forwarded-Host") + public String forwardedHostHeader; /** * Enable prefix the received request's path with a forwarded prefix header. */ - @WithDefault("false") - boolean enableForwardedPrefix(); + @ConfigItem(defaultValue = "false") + public boolean enableForwardedPrefix; /** * Configure the forwarded prefix header to be used if prefixing enabled. */ - @WithDefault("X-Forwarded-Prefix") - String forwardedPrefixHeader(); + @ConfigItem(defaultValue = "X-Forwarded-Prefix") + public String forwardedPrefixHeader; /** * Configure the list of trusted proxy addresses. @@ -102,5 +104,8 @@ public interface ProxyConfig { *

* Please bear in mind that IPv4 CIDR won't match request sent from the IPv6 address and the other way around. */ - Optional> trustedProxies(); + @ConfigItem(defaultValueDocumentation = "All proxy addresses are trusted") + @ConvertWith(TrustedProxyCheckPartConverter.class) + public Optional> trustedProxies; + } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/SameSiteCookieConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/SameSiteCookieConfig.java index 37fa0eba96aea..cad1b8b44edb4 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/SameSiteCookieConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/SameSiteCookieConfig.java @@ -1,6 +1,7 @@ package io.quarkus.vertx.http.runtime; -import io.smallrye.config.WithDefault; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; import io.vertx.core.http.CookieSameSite; /** @@ -9,28 +10,31 @@ * As some API's (Servlet, JAX-RS) don't current support this attribute this config allows * it to be set based on the cookie name pattern. */ -public interface SameSiteCookieConfig { +@ConfigGroup +public class SameSiteCookieConfig { + /** * If the cookie pattern is case-sensitive */ - @WithDefault("false") - boolean caseSensitive(); + @ConfigItem + public boolean caseSensitive; /** * The value to set in the samesite attribute */ - CookieSameSite value(); + @ConfigItem + public CookieSameSite value; /** * Some User Agents break when sent SameSite=None, this will detect them and avoid sending the value */ - @WithDefault("true") - boolean enableClientChecker(); + @ConfigItem(defaultValue = "true") + public boolean enableClientChecker; /** * If this is true then the 'secure' attribute will automatically be sent on * cookies with a SameSite attribute of None. */ - @WithDefault("true") - boolean addSecureForNone(); + @ConfigItem(defaultValue = "true") + public boolean addSecureForNone; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ServerLimitsConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ServerLimitsConfig.java index d015cac8979b6..1d8e91e323eed 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ServerLimitsConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ServerLimitsConfig.java @@ -4,45 +4,48 @@ import java.util.OptionalInt; import java.util.OptionalLong; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.configuration.MemorySize; -import io.smallrye.config.WithDefault; -public interface ServerLimitsConfig { +@ConfigGroup +public class ServerLimitsConfig { /** * The maximum length of all headers. */ - @WithDefault("20K") - MemorySize maxHeaderSize(); + @ConfigItem(defaultValue = "20K") + public MemorySize maxHeaderSize; /** * The maximum size of a request body. */ - @WithDefault("10240K") - Optional maxBodySize(); + @ConfigItem(defaultValue = "10240K") + public Optional maxBodySize; /** * The max HTTP chunk size */ - @WithDefault("8192") - MemorySize maxChunkSize(); + @ConfigItem(defaultValue = "8192") + public MemorySize maxChunkSize; /** * The maximum length of the initial line (e.g. {@code "GET / HTTP/1.0"}). */ - @WithDefault("4096") - int maxInitialLineLength(); + @ConfigItem(defaultValue = "4096") + public int maxInitialLineLength; /** * The maximum length of a form attribute. */ - @WithDefault("2048") - MemorySize maxFormAttributeSize(); + @ConfigItem(defaultValue = "2048") + public MemorySize maxFormAttributeSize; /** * The maximum number of connections that are allowed at any one time. If this is set * it is recommended to set a short idle timeout. */ - OptionalInt maxConnections(); + @ConfigItem + public OptionalInt maxConnections; /** * Set the SETTINGS_HEADER_TABLE_SIZE HTTP/2 setting. @@ -52,7 +55,8 @@ public interface ServerLimitsConfig { * specific to the header compression format inside a header block. * The initial value is {@code 4,096} octets. */ - OptionalLong headerTableSize(); + @ConfigItem + public OptionalLong headerTableSize; /** * Set SETTINGS_MAX_CONCURRENT_STREAMS HTTP/2 setting. @@ -61,14 +65,16 @@ public interface ServerLimitsConfig { * applies to the number of streams that the sender permits the receiver to create. Initially, there is no limit to * this value. It is recommended that this value be no smaller than 100, to not unnecessarily limit parallelism. */ - OptionalLong maxConcurrentStreams(); + @ConfigItem + public OptionalLong maxConcurrentStreams; /** * Set the SETTINGS_MAX_FRAME_SIZE HTTP/2 setting. * Indicates the size of the largest frame payload that the sender is willing to receive, in octets. * The initial value is {@code 2^14} (16,384) octets. */ - OptionalInt maxFrameSize(); + @ConfigItem + public OptionalInt maxFrameSize; /** * Set the SETTINGS_MAX_HEADER_LIST_SIZE HTTP/2 setting. @@ -77,5 +83,7 @@ public interface ServerLimitsConfig { * value in octets plus an overhead of 32 octets for each header field. * The default value is {@code 8192} */ - OptionalLong maxHeaderListSize(); + @ConfigItem + public OptionalLong maxHeaderListSize; + } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ServerSslConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ServerSslConfig.java index a298f4acadc3e..bcab41197df6f 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ServerSslConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ServerSslConfig.java @@ -4,21 +4,25 @@ import java.util.Optional; import java.util.Set; -import io.smallrye.config.WithDefault; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.DefaultConverter; /** * Shared configuration for setting up server-side SSL. */ -public interface ServerSslConfig { +@ConfigGroup +public class ServerSslConfig { /** * The server certificate configuration. */ - CertificateConfig certificate(); + public CertificateConfig certificate; /** * The cipher suites to use. If none is given, a reasonable default is selected. */ - Optional> cipherSuites(); + @ConfigItem + public Optional> cipherSuites; /** * Sets the ordered list of enabled SSL/TLS protocols. @@ -30,13 +34,15 @@ public interface ServerSslConfig { * Note that setting an empty list, and enabling SSL/TLS is invalid. * You must at least have one protocol. */ - @WithDefault("TLSv1.3,TLSv1.2") - Set protocols(); + @DefaultConverter + @ConfigItem(defaultValue = "TLSv1.3,TLSv1.2") + public Set protocols; /** * Enables Server Name Indication (SNI), an TLS extension allowing the server to use multiple certificates. * The client indicate the server name during the TLS handshake, allowing the server to select the right certificate. */ - @WithDefault("false") - boolean sni(); + @ConfigItem(defaultValue = "false") + public boolean sni; + } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesConfig.java index f460d5ab7ffdb..94ff031402d81 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesConfig.java @@ -2,48 +2,52 @@ import java.time.Duration; -import io.smallrye.config.WithDefault; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; + +@ConfigGroup +public class StaticResourcesConfig { -public interface StaticResourcesConfig { /** * Set the index page when serving static resources. */ - @WithDefault("index.html") - String indexPage(); + @ConfigItem(defaultValue = "index.html") + public String indexPage; /** * Set whether hidden files should be served. */ - @WithDefault("true") - boolean includeHidden(); + @ConfigItem(defaultValue = "true") + public boolean includeHidden; /** * Set whether range requests (resumable downloads; media streaming) should be enabled. */ - @WithDefault("true") - boolean enableRangeSupport(); + @ConfigItem(defaultValue = "true") + public boolean enableRangeSupport; /** * Set whether cache handling is enabled. */ - @WithDefault("true") - boolean cachingEnabled(); + @ConfigItem(defaultValue = "true") + public boolean cachingEnabled; /** * Set the cache entry timeout. The default is {@code 30} seconds. */ - @WithDefault("30S") - Duration cacheEntryTimeout(); + @ConfigItem(defaultValue = "30S") + public Duration cacheEntryTimeout; /** * Set value for max age in caching headers. The default is {@code 24} hours. */ - @WithDefault("24H") - Duration maxAge(); + @ConfigItem(defaultValue = "24H") + public Duration maxAge; /** * Set the max cache size. */ - @WithDefault("10000") - int maxCacheSize(); + @ConfigItem(defaultValue = "10000") + public int maxCacheSize; + } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesRecorder.java index e900e09166b9a..7738d9bfe34cd 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesRecorder.java @@ -39,11 +39,11 @@ public static void setHotDeploymentResources(List resources) { } public Consumer start(Set knownPaths) { - if (httpBuildTimeConfig.enableCompression() && httpBuildTimeConfig.compressMediaTypes().isPresent()) { - this.compressMediaTypes = Set.copyOf(httpBuildTimeConfig.compressMediaTypes().get()); + if (httpBuildTimeConfig.enableCompression && httpBuildTimeConfig.compressMediaTypes.isPresent()) { + this.compressMediaTypes = Set.copyOf(httpBuildTimeConfig.compressMediaTypes.get()); } List> handlers = new ArrayList<>(); - StaticResourcesConfig config = httpConfiguration.getValue().staticResources(); + StaticResourcesConfig config = httpConfiguration.getValue().staticResources; if (hotDeploymentResourcePaths != null && !hotDeploymentResourcePaths.isEmpty()) { for (Path resourcePath : hotDeploymentResourcePaths) { @@ -51,9 +51,9 @@ public Consumer start(Set knownPaths) { StaticHandler staticHandler = StaticHandler.create(FileSystemAccess.ROOT, root) .setDefaultContentEncoding("UTF-8") .setCachingEnabled(false) - .setIndexPage(config.indexPage()) - .setIncludeHidden(config.includeHidden()) - .setEnableRangeSupport(config.enableRangeSupport()); + .setIndexPage(config.indexPage) + .setIncludeHidden(config.includeHidden) + .setEnableRangeSupport(config.enableRangeSupport); handlers.add(new Handler<>() { @Override public void handle(RoutingContext ctx) { @@ -73,18 +73,18 @@ public void handle(RoutingContext ctx) { ClassLoader currentCl = Thread.currentThread().getContextClassLoader(); StaticHandler staticHandler = StaticHandler.create(META_INF_RESOURCES) .setDefaultContentEncoding("UTF-8") - .setCachingEnabled(config.cachingEnabled()) - .setIndexPage(config.indexPage()) - .setIncludeHidden(config.includeHidden()) - .setEnableRangeSupport(config.enableRangeSupport()) - .setMaxCacheSize(config.maxCacheSize()) - .setCacheEntryTimeout(config.cacheEntryTimeout().toMillis()) - .setMaxAgeSeconds(config.maxAge().toSeconds()); + .setCachingEnabled(config.cachingEnabled) + .setIndexPage(config.indexPage) + .setIncludeHidden(config.includeHidden) + .setEnableRangeSupport(config.enableRangeSupport) + .setMaxCacheSize(config.maxCacheSize) + .setCacheEntryTimeout(config.cacheEntryTimeout.toMillis()) + .setMaxAgeSeconds(config.maxAge.toSeconds()); // normalize index page like StaticHandler because its not expose // TODO: create a converter to normalize filename in config.indexPage? - final String indexPage = (config.indexPage().charAt(0) == '/') - ? config.indexPage().substring(1) - : config.indexPage(); + final String indexPage = (config.indexPage.charAt(0) == '/') + ? config.indexPage.substring(1) + : config.indexPage; handlers.add(new Handler<>() { @Override public void handle(RoutingContext ctx) { @@ -122,7 +122,7 @@ public void accept(Route route) { } private void compressIfNeeded(RoutingContext ctx, String path) { - if (httpBuildTimeConfig.enableCompression() && isCompressed(path)) { + if (httpBuildTimeConfig.enableCompression && isCompressed(path)) { // VertxHttpRecorder is adding "Content-Encoding: identity" to all requests if compression is enabled. // Handlers can remove the "Content-Encoding: identity" header to enable compression. ctx.response().headers().remove(HttpHeaders.CONTENT_ENCODING); diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java index b6ab04b678024..1f90288598153 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java @@ -75,7 +75,6 @@ import io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers; import io.quarkus.vertx.http.runtime.options.HttpServerOptionsUtils; import io.smallrye.common.vertx.VertxContext; -import io.smallrye.config.SmallRyeConfig; import io.vertx.core.AbstractVerticle; import io.vertx.core.AsyncResult; import io.vertx.core.Context; @@ -207,8 +206,7 @@ private boolean uriValid(HttpServerRequest httpServerRequest) { final RuntimeValue managementConfiguration; private static volatile Handler managementRouter; - public VertxHttpRecorder( - HttpBuildTimeConfig httpBuildTimeConfig, + public VertxHttpRecorder(HttpBuildTimeConfig httpBuildTimeConfig, ManagementInterfaceBuildTimeConfig managementBuildTimeConfig, RuntimeValue httpConfiguration, RuntimeValue managementConfiguration) { @@ -261,21 +259,18 @@ public static void startServerAfterFailedStart() { } try { - SmallRyeConfig config = ConfigUtils.emptyConfigBuilder() - .addDiscoveredSources() - .withMapping(HttpBuildTimeConfig.class) - .withMapping(HttpConfiguration.class) - .withMapping(ManagementInterfaceBuildTimeConfig.class) - .withMapping(ManagementInterfaceConfiguration.class) - .withDefaultValue("quarkus.http.host", "localhost") - .build(); - - HttpBuildTimeConfig httpBuildConfig = config.getConfigMapping(HttpBuildTimeConfig.class); - ManagementInterfaceBuildTimeConfig managementBuildTimeConfig = config - .getConfigMapping(ManagementInterfaceBuildTimeConfig.class); - HttpConfiguration httpConfig = config.getConfigMapping(HttpConfiguration.class); - ManagementInterfaceConfiguration managementConfig = config.getConfigMapping(ManagementInterfaceConfiguration.class); - + HttpBuildTimeConfig buildConfig = new HttpBuildTimeConfig(); + ConfigInstantiator.handleObject(buildConfig); + ManagementInterfaceBuildTimeConfig managementBuildTimeConfig = new ManagementInterfaceBuildTimeConfig(); + ConfigInstantiator.handleObject(managementBuildTimeConfig); + HttpConfiguration config = new HttpConfiguration(); + ConfigInstantiator.handleObject(config); + ManagementInterfaceConfiguration managementConfig = new ManagementInterfaceConfiguration(); + ConfigInstantiator.handleObject(managementConfig); + if (config.host == null) { + //HttpHostConfigSource does not come into play here + config.host = "localhost"; + } Router router = Router.router(vertx); if (hotReplacementHandler != null) { router.route().order(Integer.MIN_VALUE).blockingHandler(hotReplacementHandler); @@ -291,8 +286,7 @@ public static void startServerAfterFailedStart() { rootHandler = root; //we can't really do - doServerStart(vertx, httpBuildConfig, managementBuildTimeConfig, null, httpConfig, managementConfig, - LaunchMode.DEVELOPMENT, + doServerStart(vertx, buildConfig, managementBuildTimeConfig, null, config, managementConfig, LaunchMode.DEVELOPMENT, new Supplier() { @Override public Integer get() { @@ -341,8 +335,8 @@ public void startServer(Supplier vertx, ShutdownContext shutdown, HttpConfiguration httpConfiguration = this.httpConfiguration.getValue(); ManagementInterfaceConfiguration managementConfig = this.managementConfiguration == null ? null : this.managementConfiguration.getValue(); - if (startSocket && (httpConfiguration.hostEnabled() || httpConfiguration.domainSocketEnabled() - || managementConfig.hostEnabled() || managementConfig.domainSocketEnabled())) { + if (startSocket && (httpConfiguration.hostEnabled || httpConfiguration.domainSocketEnabled + || managementConfig.hostEnabled || managementConfig.domainSocketEnabled)) { // Start the server if (closeTask == null) { doServerStart(vertx.get(), httpBuildTimeConfig, managementBuildTimeConfig, managementRouter, @@ -411,9 +405,9 @@ public void finalizeRouter(BeanContainer container, Consumer defaultRoute defaultRouteHandler.accept(httpRouteRouter.route().order(DEFAULT_ROUTE_ORDER)); } - applyCompression(httpBuildTimeConfig.enableCompression(), httpRouteRouter); + applyCompression(httpBuildTimeConfig.enableCompression, httpRouteRouter); httpRouteRouter.route().last().failureHandler( - new QuarkusErrorHandler(launchMode.isDevOrTest(), httpConfiguration.unhandledErrorContentTypeDefault())); + new QuarkusErrorHandler(launchMode.isDevOrTest(), httpConfiguration.unhandledErrorContentTypeDefault)); if (requireBodyHandler) { //if this is set then everything needs the body handler installed @@ -427,12 +421,12 @@ public void handle(RoutingContext routingContext) { }); } - HttpServerCommonHandlers.enforceMaxBodySize(httpConfiguration.limits(), httpRouteRouter); + HttpServerCommonHandlers.enforceMaxBodySize(httpConfiguration.limits, httpRouteRouter); // Filter Configuration per path - var filtersInConfig = httpConfiguration.filter(); + var filtersInConfig = httpConfiguration.filter; HttpServerCommonHandlers.applyFilters(filtersInConfig, httpRouteRouter); // Headers sent on any request, regardless of the response - HttpServerCommonHandlers.applyHeaders(httpConfiguration.header(), httpRouteRouter); + HttpServerCommonHandlers.applyHeaders(httpConfiguration.header, httpRouteRouter); Handler root; if (rootPath.equals("/")) { @@ -466,8 +460,8 @@ public void handle(RoutingContext event) { root = mainRouter; } - warnIfProxyAddressForwardingAllowedWithMultipleHeaders(httpConfiguration.proxy()); - root = HttpServerCommonHandlers.applyProxy(httpConfiguration.proxy(), root, vertx); + warnIfProxyAddressForwardingAllowedWithMultipleHeaders(httpConfiguration.proxy); + root = HttpServerCommonHandlers.applyProxy(httpConfiguration.proxy, root, vertx); boolean quarkusWrapperNeeded = false; @@ -477,18 +471,18 @@ public void handle(RoutingContext event) { quarkusWrapperNeeded = true; } - AccessLogConfig accessLog = httpConfiguration.accessLog(); - if (accessLog.enabled()) { + AccessLogConfig accessLog = httpConfiguration.accessLog; + if (accessLog.enabled) { AccessLogReceiver receiver; - if (accessLog.logToFile()) { - File outputDir = accessLog.logDirectory().isPresent() ? new File(accessLog.logDirectory().get()) : new File(""); - receiver = new DefaultAccessLogReceiver(executor, outputDir, accessLog.baseFileName(), accessLog.logSuffix(), - accessLog.rotate()); + if (accessLog.logToFile) { + File outputDir = accessLog.logDirectory.isPresent() ? new File(accessLog.logDirectory.get()) : new File(""); + receiver = new DefaultAccessLogReceiver(executor, outputDir, accessLog.baseFileName, accessLog.logSuffix, + accessLog.rotate); } else { - receiver = new JBossLoggingAccessLogReceiver(accessLog.category()); + receiver = new JBossLoggingAccessLogReceiver(accessLog.category); } - AccessLogHandler handler = new AccessLogHandler(receiver, accessLog.pattern(), getClass().getClassLoader(), - accessLog.excludePattern()); + AccessLogHandler handler = new AccessLogHandler(receiver, accessLog.pattern, getClass().getClassLoader(), + accessLog.excludePattern); if (rootPath.equals("/") || nonRootPath.equals("/")) { mainRouterRuntimeValue.orElse(httpRouterRuntimeValue).getValue().route().order(Integer.MIN_VALUE) .handler(handler); @@ -505,8 +499,8 @@ public void handle(RoutingContext event) { } BiConsumer cookieFunction = null; - if (!httpConfiguration.sameSiteCookie().isEmpty()) { - cookieFunction = processSameSiteConfig(httpConfiguration.sameSiteCookie()); + if (!httpConfiguration.sameSiteCookie.isEmpty()) { + cookieFunction = processSameSiteConfig(httpConfiguration.sameSiteCookie); quarkusWrapperNeeded = true; } BiConsumer cookieConsumer = cookieFunction; @@ -523,7 +517,7 @@ public void handle(HttpServerRequest event) { Handler delegate = root; root = HttpServerCommonHandlers.enforceDuplicatedContext(delegate); - if (httpConfiguration.recordRequestStartTime()) { + if (httpConfiguration.recordRequestStartTime) { httpRouteRouter.route().order(Integer.MIN_VALUE).handler(new Handler() { @Override public void handle(RoutingContext event) { @@ -543,22 +537,22 @@ public void handle(RoutingContext event) { var mr = managementRouter.getValue(); mr.route().last().failureHandler( - new QuarkusErrorHandler(launchMode.isDevOrTest(), httpConfiguration.unhandledErrorContentTypeDefault())); + new QuarkusErrorHandler(launchMode.isDevOrTest(), httpConfiguration.unhandledErrorContentTypeDefault)); mr.route().order(Integer.MIN_VALUE).handler(createBodyHandlerForManagementInterface()); // We can use "*" here as the management interface is not expected to be used publicly. mr.route().order(Integer.MIN_VALUE).handler(CorsHandler.create().addOrigin("*")); - HttpServerCommonHandlers.applyFilters(managementConfiguration.getValue().filter(), mr); + HttpServerCommonHandlers.applyFilters(managementConfiguration.getValue().filter, mr); for (Filter filter : managementInterfaceFilterList) { mr.route().order(filter.getPriority()).handler(filter.getHandler()); } - HttpServerCommonHandlers.applyHeaders(managementConfiguration.getValue().header(), mr); - applyCompression(managementBuildTimeConfig.enableCompression(), mr); + HttpServerCommonHandlers.applyHeaders(managementConfiguration.getValue().header, mr); + applyCompression(managementBuildTimeConfig.enableCompression, mr); Handler handler = HttpServerCommonHandlers.enforceDuplicatedContext(mr); - handler = HttpServerCommonHandlers.applyProxy(managementConfiguration.getValue().proxy(), handler, vertx); + handler = HttpServerCommonHandlers.applyProxy(managementConfiguration.getValue().proxy, handler, vertx); event.select(ManagementInterface.class).fire(new ManagementInterfaceImpl(managementRouter.getValue())); @@ -581,9 +575,9 @@ public void handle(RoutingContext ctx) { } private void warnIfProxyAddressForwardingAllowedWithMultipleHeaders(ProxyConfig proxyConfig) { - boolean proxyAddressForwardingActivated = proxyConfig.proxyAddressForwarding(); - boolean forwardedActivated = proxyConfig.allowForwarded(); - boolean xForwardedActivated = proxyConfig.allowXForwarded().orElse(!forwardedActivated); + boolean proxyAddressForwardingActivated = proxyConfig.proxyAddressForwarding; + boolean forwardedActivated = proxyConfig.allowForwarded; + boolean xForwardedActivated = proxyConfig.allowXForwarded.orElse(!forwardedActivated); if (proxyAddressForwardingActivated && forwardedActivated && xForwardedActivated) { LOGGER.warn( @@ -599,7 +593,7 @@ private static CompletableFuture initializeManagementInterfaceWithDo ManagementInterfaceConfiguration managementConfig, List websocketSubProtocols) { CompletableFuture managementInterfaceDomainSocketFuture = new CompletableFuture<>(); - if (!managementBuildTimeConfig.enabled() || managementRouter == null || managementConfig == null) { + if (!managementBuildTimeConfig.enabled || managementRouter == null || managementConfig == null) { managementInterfaceDomainSocketFuture.complete(null); return managementInterfaceDomainSocketFuture; } @@ -634,7 +628,7 @@ private static CompletableFuture initializeManagementInterface(Vertx List websocketSubProtocols) throws IOException { httpManagementServerOptions = null; CompletableFuture managementInterfaceFuture = new CompletableFuture<>(); - if (!managementBuildTimeConfig.enabled() || managementRouter == null || managementConfig == null) { + if (!managementBuildTimeConfig.enabled || managementRouter == null || managementConfig == null) { managementInterfaceFuture.complete(null); return managementInterfaceFuture; } @@ -672,7 +666,7 @@ private static CompletableFuture initializeMainHttpServer(Vertx vertx, H LaunchMode launchMode, Supplier eventLoops, List websocketSubProtocols) throws IOException { - if (!httpConfiguration.hostEnabled() && !httpConfiguration.domainSocketEnabled()) { + if (!httpConfiguration.hostEnabled && !httpConfiguration.domainSocketEnabled) { return CompletableFuture.completedFuture(null); } @@ -709,15 +703,15 @@ private static CompletableFuture initializeMainHttpServer(Vertx vertx, H } httpMainSslServerOptions = tmpSslConfig; - if (httpConfiguration.insecureRequests() != HttpConfiguration.InsecureRequests.ENABLED + if (httpConfiguration.insecureRequests != HttpConfiguration.InsecureRequests.ENABLED && httpMainSslServerOptions == null) { throw new IllegalStateException("Cannot set quarkus.http.redirect-insecure-requests without enabling SSL."); } int eventLoopCount = eventLoops.get(); final int ioThreads; - if (httpConfiguration.ioThreads().isPresent()) { - ioThreads = Math.min(httpConfiguration.ioThreads().getAsInt(), eventLoopCount); + if (httpConfiguration.ioThreads.isPresent()) { + ioThreads = Math.min(httpConfiguration.ioThreads.getAsInt(), eventLoopCount); } else if (launchMode.isDevOrTest()) { ioThreads = Math.min(2, eventLoopCount); //Don't start ~100 threads to run a couple unit tests } else { @@ -731,7 +725,7 @@ private static CompletableFuture initializeMainHttpServer(Vertx vertx, H public Verticle get() { return new WebDeploymentVerticle(httpMainServerOptions, httpMainSslServerOptions, httpMainDomainSocketOptions, launchMode, - httpConfiguration.insecureRequests(), httpConfiguration, connectionCount); + httpConfiguration.insecureRequests, httpConfiguration, connectionCount); } }, new DeploymentOptions().setInstances(ioThreads), new Handler>() { @Override @@ -743,11 +737,11 @@ public void handle(AsyncResult event) { if ((httpMainSslServerOptions == null) && (httpMainServerOptions != null)) { portsUsed = List.of(httpMainServerOptions.getPort()); - } else if ((httpConfiguration.insecureRequests() == InsecureRequests.DISABLED) + } else if ((httpConfiguration.insecureRequests == InsecureRequests.DISABLED) && (httpMainSslServerOptions != null)) { portsUsed = List.of(httpMainSslServerOptions.getPort()); } else if ((httpMainSslServerOptions != null) - && (httpConfiguration.insecureRequests() == InsecureRequests.ENABLED) + && (httpConfiguration.insecureRequests == InsecureRequests.ENABLED) && (httpMainServerOptions != null)) { portsUsed = List.of(httpMainServerOptions.getPort(), httpMainSslServerOptions.getPort()); } @@ -860,7 +854,7 @@ public void handle(AsyncResult event) { throw new RuntimeException("Unable to start HTTP server", e); } - setHttpServerTiming(httpConfiguration.insecureRequests(), httpMainServerOptions, httpMainSslServerOptions, + setHttpServerTiming(httpConfiguration.insecureRequests, httpMainServerOptions, httpMainSslServerOptions, httpMainDomainSocketOptions, auxiliaryApplication, httpManagementServerOptions); } @@ -903,7 +897,7 @@ private static void setHttpServerTiming(InsecureRequests insecureRequests, HttpS private static HttpServerOptions createHttpServerOptions( HttpBuildTimeConfig buildTimeConfig, HttpConfiguration httpConfiguration, LaunchMode launchMode, List websocketSubProtocols) { - if (!httpConfiguration.hostEnabled()) { + if (!httpConfiguration.hostEnabled) { return null; } // TODO other config properties @@ -919,7 +913,7 @@ private static HttpServerOptions createHttpServerOptions( private static HttpServerOptions createHttpServerOptionsForManagementInterface( ManagementInterfaceBuildTimeConfig buildTimeConfig, ManagementInterfaceConfiguration httpConfiguration, LaunchMode launchMode, List websocketSubProtocols) { - if (!httpConfiguration.hostEnabled()) { + if (!httpConfiguration.hostEnabled) { return null; } HttpServerOptions options = new HttpServerOptions(); @@ -935,22 +929,22 @@ private static HttpServerOptions createHttpServerOptionsForManagementInterface( private static HttpServerOptions createDomainSocketOptions( HttpBuildTimeConfig buildTimeConfig, HttpConfiguration httpConfiguration, List websocketSubProtocols) { - if (!httpConfiguration.domainSocketEnabled()) { + if (!httpConfiguration.domainSocketEnabled) { return null; } HttpServerOptions options = new HttpServerOptions(); HttpServerOptionsUtils.applyCommonOptions(options, buildTimeConfig, httpConfiguration, websocketSubProtocols); // Override the host (0.0.0.0 by default) with the configured domain socket. - options.setHost(httpConfiguration.domainSocket()); + options.setHost(httpConfiguration.domainSocket); // Check if we can write into the domain socket directory // We can do this check using a blocking API as the execution is done from the main thread (not an I/O thread) - File file = new File(httpConfiguration.domainSocket()); + File file = new File(httpConfiguration.domainSocket); if (!file.getParentFile().canWrite()) { LOGGER.warnf( "Unable to write in the domain socket directory (`%s`). Binding to the socket is likely going to fail.", - httpConfiguration.domainSocket()); + httpConfiguration.domainSocket); } return options; @@ -959,7 +953,7 @@ private static HttpServerOptions createDomainSocketOptions( private static HttpServerOptions createDomainSocketOptionsForManagementInterface( ManagementInterfaceBuildTimeConfig buildTimeConfig, ManagementInterfaceConfiguration httpConfiguration, List websocketSubProtocols) { - if (!httpConfiguration.domainSocketEnabled()) { + if (!httpConfiguration.domainSocketEnabled) { return null; } HttpServerOptions options = new HttpServerOptions(); @@ -967,15 +961,15 @@ private static HttpServerOptions createDomainSocketOptionsForManagementInterface HttpServerOptionsUtils.applyCommonOptionsForManagementInterface(options, buildTimeConfig, httpConfiguration, websocketSubProtocols); // Override the host (0.0.0.0 by default) with the configured domain socket. - options.setHost(httpConfiguration.domainSocket()); + options.setHost(httpConfiguration.domainSocket); // Check if we can write into the domain socket directory // We can do this check using a blocking API as the execution is done from the main thread (not an I/O thread) - File file = new File(httpConfiguration.domainSocket()); + File file = new File(httpConfiguration.domainSocket); if (!file.getParentFile().canWrite()) { LOGGER.warnf( "Unable to write in the domain socket directory (`%s`). Binding to the socket is likely going to fail.", - httpConfiguration.domainSocket()); + httpConfiguration.domainSocket); } return options; @@ -1146,8 +1140,8 @@ private void setupUnixDomainSocketHttpServer(HttpServer httpServer, HttpServerOp private void setupTcpHttpServer(HttpServer httpServer, HttpServerOptions options, boolean https, Promise startFuture, AtomicInteger remainingCount, AtomicInteger currentConnectionCount) { - if (quarkusConfig.limits().maxConnections().isPresent() && quarkusConfig.limits().maxConnections().getAsInt() > 0) { - final int maxConnections = quarkusConfig.limits().maxConnections().getAsInt(); + if (quarkusConfig.limits.maxConnections.isPresent() && quarkusConfig.limits.maxConnections.getAsInt() > 0) { + final int maxConnections = quarkusConfig.limits.maxConnections.getAsInt(); httpServer.connectionHandler(new Handler() { @Override @@ -1360,11 +1354,11 @@ private static Handler configureAndGetBody(Optional if (maxBodySize.isPresent()) { bodyHandler.setBodyLimit(maxBodySize.get().asLongValue()); } - bodyHandler.setHandleFileUploads(bodyConfig.handleFileUploads()); - bodyHandler.setUploadsDirectory(bodyConfig.uploadsDirectory()); - bodyHandler.setDeleteUploadedFilesOnEnd(bodyConfig.deleteUploadedFilesOnEnd()); - bodyHandler.setMergeFormAttributes(bodyConfig.mergeFormAttributes()); - bodyHandler.setPreallocateBodyBuffer(bodyConfig.preallocateBodyBuffer()); + bodyHandler.setHandleFileUploads(bodyConfig.handleFileUploads); + bodyHandler.setUploadsDirectory(bodyConfig.uploadsDirectory); + bodyHandler.setDeleteUploadedFilesOnEnd(bodyConfig.deleteUploadedFilesOnEnd); + bodyHandler.setMergeFormAttributes(bodyConfig.mergeFormAttributes); + bodyHandler.setPreallocateBodyBuffer(bodyConfig.preallocateBodyBuffer); return new Handler() { @Override public void handle(RoutingContext event) { @@ -1404,13 +1398,13 @@ public void run() { } public Handler createBodyHandler() { - Optional maxBodySize = httpConfiguration.getValue().limits().maxBodySize(); - return configureAndGetBody(maxBodySize, httpConfiguration.getValue().body()); + Optional maxBodySize = httpConfiguration.getValue().limits.maxBodySize; + return configureAndGetBody(maxBodySize, httpConfiguration.getValue().body); } public Handler createBodyHandlerForManagementInterface() { - Optional maxBodySize = managementConfiguration.getValue().limits().maxBodySize(); - return configureAndGetBody(maxBodySize, managementConfiguration.getValue().body()); + Optional maxBodySize = managementConfiguration.getValue().limits.maxBodySize; + return configureAndGetBody(maxBodySize, managementConfiguration.getValue().body); } private static final List CAN_HAVE_BODY = Arrays.asList(HttpMethod.POST, HttpMethod.PUT, HttpMethod.PATCH, @@ -1422,24 +1416,24 @@ private BiConsumer processSameSiteConfig(Map last = null; for (Map.Entry entry : new TreeMap<>(httpConfiguration).entrySet()) { - Pattern p = Pattern.compile(entry.getKey(), entry.getValue().caseSensitive() ? 0 : Pattern.CASE_INSENSITIVE); + Pattern p = Pattern.compile(entry.getKey(), entry.getValue().caseSensitive ? 0 : Pattern.CASE_INSENSITIVE); BiFunction biFunction = new BiFunction() { @Override public Boolean apply(Cookie cookie, HttpServerRequest request) { if (p.matcher(cookie.getName()).matches()) { - if (entry.getValue().value() == CookieSameSite.NONE) { - if (entry.getValue().enableClientChecker()) { + if (entry.getValue().value == CookieSameSite.NONE) { + if (entry.getValue().enableClientChecker) { String userAgent = request.getHeader(HttpHeaders.USER_AGENT); if (userAgent != null && SameSiteNoneIncompatibleClientChecker.isSameSiteNoneIncompatible(userAgent)) { return false; } } - if (entry.getValue().addSecureForNone()) { + if (entry.getValue().addSecureForNone) { cookie.setSecure(true); } } - cookie.setSameSite(entry.getValue().value()); + cookie.setSameSite(entry.getValue().value); return true; } return false; diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/cors/CORSConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/cors/CORSConfig.java index 9206e11e204b3..253ad10984b94 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/cors/CORSConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/cors/CORSConfig.java @@ -4,61 +4,87 @@ import java.util.List; import java.util.Optional; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConvertWith; import io.quarkus.runtime.configuration.TrimmedStringConverter; -import io.smallrye.config.WithConverter; -public interface CORSConfig { +@ConfigGroup +public class CORSConfig { + /** * Origins allowed for CORS - *

+ * * Comma separated list of valid URLs, e.g.: http://www.quarkus.io,http://localhost:3000 * In case an entry of the list is surrounded by forward slashes, * it is interpreted as a regular expression. */ - Optional> origins(); + @ConfigItem + @ConvertWith(TrimmedStringConverter.class) + public Optional> origins = Optional.empty(); /** * HTTP methods allowed for CORS - *

+ * * Comma separated list of valid methods. ex: GET,PUT,POST * The filter allows any method if this is not set. - *

+ * * default: returns any requested method as valid */ - Optional> methods(); + @ConfigItem + @ConvertWith(TrimmedStringConverter.class) + public Optional> methods = Optional.empty(); /** * HTTP headers allowed for CORS - *

+ * * Comma separated list of valid headers. ex: X-Custom,Content-Disposition * The filter allows any header if this is not set. - *

+ * * default: returns any requested header as valid */ - Optional> headers(); + @ConfigItem + @ConvertWith(TrimmedStringConverter.class) + public Optional> headers = Optional.empty(); /** * HTTP headers exposed in CORS - *

+ * * Comma separated list of valid headers. ex: X-Custom,Content-Disposition - *

+ * * default: empty */ - Optional> exposedHeaders(); + @ConfigItem + @ConvertWith(TrimmedStringConverter.class) + public Optional> exposedHeaders = Optional.empty(); /** * The `Access-Control-Max-Age` response header value indicating * how long the results of a pre-flight request can be cached. */ - Optional accessControlMaxAge(); + @ConfigItem + public Optional accessControlMaxAge = Optional.empty(); /** * The `Access-Control-Allow-Credentials` header is used to tell the * browsers to expose the response to front-end JavaScript code when * the request’s credentials mode Request.credentials is “include”. - *

+ * * The value of this header will default to `true` if `quarkus.http.cors.origins` property is set and * there is a match with the precise `Origin` header. */ - Optional accessControlAllowCredentials(); + @ConfigItem + public Optional accessControlAllowCredentials = Optional.empty(); + + @Override + public String toString() { + return "CORSConfig{" + + "origins=" + origins + + ", methods=" + methods + + ", headers=" + headers + + ", exposedHeaders=" + exposedHeaders + + ", accessControlMaxAge=" + accessControlMaxAge + + ", accessControlAllowCredentials=" + accessControlAllowCredentials + + '}'; + } } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/cors/CORSFilter.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/cors/CORSFilter.java index 51252dbe9af34..b28d0d7a470cb 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/cors/CORSFilter.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/cors/CORSFilter.java @@ -39,13 +39,13 @@ public class CORSFilter implements Handler { public CORSFilter(CORSConfig corsConfig) { this.corsConfig = corsConfig; - this.wildcardOrigin = isOriginConfiguredWithWildcard(this.corsConfig.origins()); - this.wildcardMethod = isConfiguredWithWildcard(corsConfig.methods()); - this.allowedOriginsRegex = this.wildcardOrigin ? List.of() : parseAllowedOriginsRegex(this.corsConfig.origins()); - this.configuredHttpMethods = createConfiguredHttpMethods(this.corsConfig.methods()); - this.exposedHeaders = createHeaderString(this.corsConfig.exposedHeaders()); - this.allowedHeaders = createHeaderString(this.corsConfig.headers()); - this.allowedMethods = createHeaderString(this.corsConfig.methods()); + this.wildcardOrigin = isOriginConfiguredWithWildcard(this.corsConfig.origins); + this.wildcardMethod = isConfiguredWithWildcard(corsConfig.methods); + this.allowedOriginsRegex = this.wildcardOrigin ? List.of() : parseAllowedOriginsRegex(this.corsConfig.origins); + this.configuredHttpMethods = createConfiguredHttpMethods(this.corsConfig.methods); + this.exposedHeaders = createHeaderString(this.corsConfig.exposedHeaders); + this.allowedHeaders = createHeaderString(this.corsConfig.headers); + this.allowedMethods = createHeaderString(this.corsConfig.methods); } private String createHeaderString(Optional> headers) { @@ -141,8 +141,8 @@ public void handle(RoutingContext event) { //for both normal and preflight requests we need to check the origin boolean allowsOrigin = wildcardOrigin; if (!allowsOrigin) { - if (corsConfig.origins().isPresent()) { - allowsOrigin = corsConfig.origins().get().contains(origin) + if (corsConfig.origins.isPresent()) { + allowsOrigin = corsConfig.origins.get().contains(origin) || isOriginAllowedByRegex(allowedOriginsRegex, origin) || isSameOrigin(request, origin); } else { @@ -153,8 +153,8 @@ public void handle(RoutingContext event) { response.setStatusCode(403); response.setStatusMessage("CORS Rejected - Invalid origin"); } else { - boolean allowCredentials = corsConfig.accessControlAllowCredentials() - .orElse(corsConfig.origins().isPresent() && corsConfig.origins().get().contains(origin)); + boolean allowCredentials = corsConfig.accessControlAllowCredentials + .orElse(corsConfig.origins.isPresent() && corsConfig.origins.get().contains(origin)); response.headers().set(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, String.valueOf(allowCredentials)); response.headers().set(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, origin); } @@ -203,9 +203,9 @@ private void handlePreflightRequest(RoutingContext event, String requestedHeader boolean allowsOrigin) { //see https://fetch.spec.whatwg.org/#http-cors-protocol - if (corsConfig.accessControlMaxAge().isPresent()) { + if (corsConfig.accessControlMaxAge.isPresent()) { event.response().putHeader(HttpHeaders.ACCESS_CONTROL_MAX_AGE, - String.valueOf(corsConfig.accessControlMaxAge().get().getSeconds())); + String.valueOf(corsConfig.accessControlMaxAge.get().getSeconds())); } var response = event.response(); if (requestedMethods != null) { @@ -309,7 +309,7 @@ static boolean substringMatch(String str, int pos, String substring, boolean req } private void processPreFlightRequestedHeaders(HttpServerResponse response, String allowHeadersValue) { - if (isConfiguredWithWildcard(corsConfig.headers())) { + if (isConfiguredWithWildcard(corsConfig.headers)) { response.headers().set(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, allowHeadersValue); } else { response.headers().set(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, allowedHeaders); diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/cors/CORSRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/cors/CORSRecorder.java index edf4161815351..18d2b5a4b4d40 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/cors/CORSRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/cors/CORSRecorder.java @@ -14,8 +14,8 @@ public CORSRecorder(HttpConfiguration configuration) { } public Handler corsHandler() { - if (configuration.corsEnabled()) { - return new CORSFilter(configuration.cors()); + if (configuration.corsEnabled) { + return new CORSFilter(configuration.cors); } return null; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementAuthConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementAuthConfig.java index c0ebcbc868e26..017fcfe953a66 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementAuthConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementAuthConfig.java @@ -3,32 +3,34 @@ import java.util.Map; import java.util.Optional; +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.vertx.http.runtime.PolicyConfig; import io.quarkus.vertx.http.runtime.PolicyMappingConfig; -import io.smallrye.config.WithDefault; -import io.smallrye.config.WithName; /** * Authentication for the management interface. */ -public interface ManagementAuthConfig { +@ConfigGroup +public class ManagementAuthConfig { /** * If basic auth should be enabled. * */ - Optional basic(); + @ConfigItem + public Optional basic; /** * The HTTP permissions */ - @WithName("permission") - Map permissions(); + @ConfigItem(name = "permission") + public Map permissions; /** * The HTTP role based policies */ - @WithName("policy") - Map rolePolicy(); + @ConfigItem(name = "policy") + public Map rolePolicy; /** * If this is true and credentials are present then a user will always be authenticated @@ -37,6 +39,6 @@ public interface ManagementAuthConfig { * If this is false then an attempt will only be made to authenticate the user if a permission * check is performed or the current user is required for some other reason. */ - @WithDefault("true") - boolean proactive(); + @ConfigItem(defaultValue = "true") + public boolean proactive; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementInterfaceBuildTimeConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementInterfaceBuildTimeConfig.java index 0037ad6b8caaa..b2ca8512199e9 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementInterfaceBuildTimeConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementInterfaceBuildTimeConfig.java @@ -2,46 +2,43 @@ import java.util.OptionalInt; +import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; -import io.smallrye.config.ConfigMapping; -import io.smallrye.config.WithDefault; -import io.smallrye.config.WithName; import io.vertx.core.http.ClientAuth; /** * Management interface configuration. */ -@ConfigMapping(prefix = "quarkus.management") -@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface ManagementInterfaceBuildTimeConfig { +@ConfigRoot(name = "management", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +public class ManagementInterfaceBuildTimeConfig { + /** * Enables / Disables the usage of a separate interface/port to expose the management endpoints. * If sets to {@code true}, the management endpoints will be exposed to a different HTTP server. * This avoids exposing the management endpoints on a publicly available server. */ - @WithDefault("false") - boolean enabled(); + @ConfigItem(defaultValue = "false") + public boolean enabled; /** * Authentication configuration */ - ManagementAuthConfig auth(); + public ManagementAuthConfig auth; /** * Configures the engine to require/request client authentication. * NONE, REQUEST, REQUIRED */ - @WithDefault("NONE") - @WithName("ssl.client-auth") - ClientAuth tlsClientAuth(); + @ConfigItem(name = "ssl.client-auth", defaultValue = "NONE") + public ClientAuth tlsClientAuth; /** * A common root path for management endpoints. Various extension-provided management endpoints such as metrics * and health are deployed under this path by default. */ - @WithDefault("/q") - String rootPath(); + @ConfigItem(defaultValue = "/q") + public String rootPath; /** * If responses should be compressed. @@ -53,8 +50,8 @@ public interface ManagementInterfaceBuildTimeConfig { *

* Which will tell vert.x not to compress the response. */ - @WithDefault("false") - boolean enableCompression(); + @ConfigItem + public boolean enableCompression; /** * When enabled, vert.x will decompress the request's body if it's compressed. @@ -62,11 +59,12 @@ public interface ManagementInterfaceBuildTimeConfig { * Note that the compression format (e.g., gzip) must be specified in the Content-Encoding header * in the request. */ - @WithDefault("false") - boolean enableDecompression(); + @ConfigItem + public boolean enableDecompression; /** * The compression level used when compression support is enabled. */ - OptionalInt compressionLevel(); + @ConfigItem + public OptionalInt compressionLevel; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementInterfaceConfiguration.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementInterfaceConfiguration.java index 447bd8c5da6ac..9d77f458d1c90 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementInterfaceConfiguration.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementInterfaceConfiguration.java @@ -5,6 +5,7 @@ import java.util.Optional; import io.quarkus.runtime.LaunchMode; +import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.quarkus.vertx.http.runtime.BodyConfig; @@ -13,29 +14,26 @@ import io.quarkus.vertx.http.runtime.ProxyConfig; import io.quarkus.vertx.http.runtime.ServerLimitsConfig; import io.quarkus.vertx.http.runtime.ServerSslConfig; -import io.smallrye.config.ConfigMapping; -import io.smallrye.config.WithDefault; -import io.smallrye.config.WithName; /** * Configures the management interface. * Note that the management interface must be enabled using the * {@link ManagementInterfaceBuildTimeConfig#enabled} build-time property. */ -@ConfigMapping(prefix = "quarkus.management") -@ConfigRoot(phase = ConfigPhase.RUN_TIME) -public interface ManagementInterfaceConfiguration { +@ConfigRoot(phase = ConfigPhase.RUN_TIME, name = "management") +public class ManagementInterfaceConfiguration { + /** * The HTTP port */ - @WithDefault("9000") - int port(); + @ConfigItem(defaultValue = "9000") + public int port; /** * The HTTP port */ - @WithDefault("9001") - int testPort(); + @ConfigItem(defaultValue = "9001") + public int testPort; /** * The HTTP host @@ -46,78 +44,77 @@ public interface ManagementInterfaceConfiguration { * is not suitable for dev/test mode as other people on the network can connect to your * development machine. */ - Optional host(); + @ConfigItem + public Optional host; /** * Enable listening to host:port */ - @WithDefault("true") - boolean hostEnabled(); + @ConfigItem(defaultValue = "true") + public boolean hostEnabled; /** * The SSL config */ - ServerSslConfig ssl(); + public ServerSslConfig ssl; /** * When set to {@code true}, the HTTP server automatically sends `100 CONTINUE` * response when the request expects it (with the `Expect: 100-Continue` header). */ - @WithName("handle-100-continue-automatically") - @WithDefault("false") - boolean handle100ContinueAutomatically(); + @ConfigItem(defaultValue = "false", name = "handle-100-continue-automatically") + public boolean handle100ContinueAutomatically; /** * Server limits configuration */ - ServerLimitsConfig limits(); + public ServerLimitsConfig limits; /** * Http connection idle timeout */ - @WithName("idle-timeout") - @WithDefault("30M") - Duration idleTimeout(); + @ConfigItem(defaultValue = "30M", name = "idle-timeout") + public Duration idleTimeout; /** * Request body related settings */ - BodyConfig body(); + public BodyConfig body; /** * The accept backlog, this is how many connections can be waiting to be accepted before connections start being rejected */ - @WithDefault("-1") - int acceptBacklog(); + @ConfigItem(defaultValue = "-1") + public int acceptBacklog; /** * Path to a unix domain socket */ - @WithDefault("/var/run/io.quarkus.management.socket") - String domainSocket(); + @ConfigItem(defaultValue = "/var/run/io.quarkus.management.socket") + public String domainSocket; /** * Enable listening to host:port */ - @WithDefault("false") - boolean domainSocketEnabled(); + @ConfigItem + public boolean domainSocketEnabled; /** * Additional HTTP Headers always sent in the response */ - Map header(); + @ConfigItem + public Map header; /** * Additional HTTP configuration per path */ - Map filter(); + @ConfigItem + public Map filter; - /** - * Proxy configuration. - */ - ProxyConfig proxy(); + public ProxyConfig proxy; - default int determinePort(LaunchMode launchMode) { - return launchMode == LaunchMode.TEST ? testPort() : port(); + public int determinePort(LaunchMode launchMode) { + return launchMode == LaunchMode.TEST ? testPort : port; } + } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementInterfaceSecurityRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementInterfaceSecurityRecorder.java index 70390c5958fdf..03e6be2d83742 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementInterfaceSecurityRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/management/ManagementInterfaceSecurityRecorder.java @@ -58,7 +58,7 @@ public BeanContainerListener initPermissions(ManagementInterfaceBuildTimeConfig @Override public void created(BeanContainer container) { container.beanInstance(ManagementPathMatchingHttpSecurityPolicy.class) - .init(buildTimeConfig.auth().permissions(), policies, buildTimeConfig.rootPath()); + .init(buildTimeConfig.auth.permissions, policies, buildTimeConfig.rootPath); } }; } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/options/HttpServerCommonHandlers.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/options/HttpServerCommonHandlers.java index 44c6cac25d36d..562611de71eb4 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/options/HttpServerCommonHandlers.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/options/HttpServerCommonHandlers.java @@ -30,8 +30,8 @@ public class HttpServerCommonHandlers { public static void enforceMaxBodySize(ServerLimitsConfig limits, Router httpRouteRouter) { - if (limits.maxBodySize().isPresent()) { - long limit = limits.maxBodySize().get().asLongValue(); + if (limits.maxBodySize.isPresent()) { + long limit = limits.maxBodySize.get().asLongValue(); Long limitObj = limit; httpRouteRouter.route().order(-2).handler(new Handler() { @Override @@ -87,7 +87,7 @@ public void handle(Void x) { public static Handler applyProxy(ProxyConfig proxyConfig, Handler root, Supplier vertx) { - if (proxyConfig.proxyAddressForwarding()) { + if (proxyConfig.proxyAddressForwarding) { final ForwardingProxyOptions forwardingProxyOptions = ForwardingProxyOptions.from(proxyConfig); final TrustedProxyCheck.TrustedProxyCheckBuilder proxyCheckBuilder = forwardingProxyOptions.trustedProxyCheckBuilder; if (proxyCheckBuilder == null) { @@ -111,10 +111,10 @@ public static void applyFilters(Map filtersInConfig, Route if (!filtersInConfig.isEmpty()) { for (var entry : filtersInConfig.entrySet()) { var filterConfig = entry.getValue(); - var matches = filterConfig.matches(); - var order = filterConfig.order().orElse(Integer.MIN_VALUE); - var methods = filterConfig.methods(); - var headers = filterConfig.header(); + var matches = filterConfig.matches; + var order = filterConfig.order.orElse(Integer.MIN_VALUE); + var methods = filterConfig.methods; + var headers = filterConfig.header; if (methods.isEmpty()) { httpRouteRouter.routeWithRegex(matches) .order(order) @@ -148,24 +148,24 @@ public static void applyHeaders(Map headers, Router httpRo for (Map.Entry entry : headers.entrySet()) { var name = entry.getKey(); var config = entry.getValue(); - if (config.methods().isEmpty()) { - httpRouteRouter.route(config.path()) + if (config.methods.isEmpty()) { + httpRouteRouter.route(config.path) .order(Integer.MIN_VALUE) .handler(new Handler() { @Override public void handle(RoutingContext event) { - event.response().headers().set(name, config.value()); + event.response().headers().set(name, config.value); event.next(); } }); } else { - for (String method : config.methods().get()) { - httpRouteRouter.route(HttpMethod.valueOf(method.toUpperCase(Locale.ROOT)), config.path()) + for (String method : config.methods.get()) { + httpRouteRouter.route(HttpMethod.valueOf(method.toUpperCase(Locale.ROOT)), config.path) .order(Integer.MIN_VALUE) .handler(new Handler() { @Override public void handle(RoutingContext event) { - event.response().headers().add(name, config.value()); + event.response().headers().add(name, config.value); event.next(); } }); diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/options/HttpServerOptionsUtils.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/options/HttpServerOptionsUtils.java index 56409be6f047d..bd20ba9b5c813 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/options/HttpServerOptionsUtils.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/options/HttpServerOptionsUtils.java @@ -38,43 +38,43 @@ public class HttpServerOptionsUtils { public static HttpServerOptions createSslOptions(HttpBuildTimeConfig buildTimeConfig, HttpConfiguration httpConfiguration, LaunchMode launchMode, List websocketSubProtocols) throws IOException { - if (!httpConfiguration.hostEnabled()) { + if (!httpConfiguration.hostEnabled) { return null; } - ServerSslConfig sslConfig = httpConfiguration.ssl(); + ServerSslConfig sslConfig = httpConfiguration.ssl; final List keys = new ArrayList<>(); final List certificates = new ArrayList<>(); - if (sslConfig.certificate().keyFiles().isPresent()) { - keys.addAll(sslConfig.certificate().keyFiles().get()); + if (sslConfig.certificate.keyFiles.isPresent()) { + keys.addAll(sslConfig.certificate.keyFiles.get()); } - if (sslConfig.certificate().files().isPresent()) { - certificates.addAll(sslConfig.certificate().files().get()); + if (sslConfig.certificate.files.isPresent()) { + certificates.addAll(sslConfig.certificate.files.get()); } // credentials provider Map credentials = Map.of(); - if (sslConfig.certificate().credentialsProvider().isPresent()) { - String beanName = sslConfig.certificate().credentialsProviderName().orElse(null); + if (sslConfig.certificate.credentialsProvider.isPresent()) { + String beanName = sslConfig.certificate.credentialsProviderName.orElse(null); CredentialsProvider credentialsProvider = CredentialsProviderFinder.find(beanName); - String name = sslConfig.certificate().credentialsProvider().get(); + String name = sslConfig.certificate.credentialsProvider.get(); credentials = credentialsProvider.getCredentials(name); } - final Optional keyStoreFile = sslConfig.certificate().keyStoreFile(); - final Optional keyStorePassword = getCredential(sslConfig.certificate().keyStorePassword(), credentials, - sslConfig.certificate().keyStorePasswordKey()); - final Optional keyStoreKeyPassword = getCredential(sslConfig.certificate().keyStoreKeyPassword(), credentials, - sslConfig.certificate().keyStoreKeyPasswordKey()); - final Optional trustStoreFile = sslConfig.certificate().trustStoreFile(); - final Optional trustStorePassword = getCredential(sslConfig.certificate().trustStorePassword(), credentials, - sslConfig.certificate().trustStorePasswordKey()); + final Optional keyStoreFile = sslConfig.certificate.keyStoreFile; + final Optional keyStorePassword = getCredential(sslConfig.certificate.keyStorePassword, credentials, + sslConfig.certificate.keyStorePasswordKey); + final Optional keyStoreKeyPassword = getCredential(sslConfig.certificate.keyStoreKeyPassword, credentials, + sslConfig.certificate.keyStoreKeyPasswordKey); + final Optional trustStoreFile = sslConfig.certificate.trustStoreFile; + final Optional trustStorePassword = getCredential(sslConfig.certificate.trustStorePassword, credentials, + sslConfig.certificate.trustStorePasswordKey); final HttpServerOptions serverOptions = new HttpServerOptions(); //ssl if (JdkSSLEngineOptions.isAlpnAvailable()) { - serverOptions.setUseAlpn(httpConfiguration.http2()); - if (httpConfiguration.http2()) { + serverOptions.setUseAlpn(httpConfiguration.http2); + if (httpConfiguration.http2) { serverOptions.setAlpnVersions(Arrays.asList(HttpVersion.HTTP_2, HttpVersion.HTTP_1_1)); } } @@ -86,9 +86,9 @@ public static HttpServerOptions createSslOptions(HttpBuildTimeConfig buildTimeCo KeyStoreOptions options = createKeyStoreOptions( keyStoreFile.get(), keyStorePassword.orElse("password"), - sslConfig.certificate().keyStoreFileType(), - sslConfig.certificate().keyStoreProvider(), - sslConfig.certificate().keyStoreKeyAlias(), + sslConfig.certificate.keyStoreFileType, + sslConfig.certificate.keyStoreProvider, + sslConfig.certificate.keyStoreKeyAlias, keyStoreKeyPassword); serverOptions.setKeyCertOptions(options); } @@ -100,24 +100,24 @@ public static HttpServerOptions createSslOptions(HttpBuildTimeConfig buildTimeCo KeyStoreOptions options = createKeyStoreOptions( trustStoreFile.get(), trustStorePassword.get(), - sslConfig.certificate().trustStoreFileType(), - sslConfig.certificate().trustStoreProvider(), - sslConfig.certificate().trustStoreCertAlias(), + sslConfig.certificate.trustStoreFileType, + sslConfig.certificate.trustStoreProvider, + sslConfig.certificate.trustStoreCertAlias, Optional.empty()); serverOptions.setTrustOptions(options); } - for (String cipher : sslConfig.cipherSuites().orElse(Collections.emptyList())) { + for (String cipher : sslConfig.cipherSuites.orElse(Collections.emptyList())) { serverOptions.addEnabledCipherSuite(cipher); } - serverOptions.setEnabledSecureTransportProtocols(sslConfig.protocols()); + serverOptions.setEnabledSecureTransportProtocols(sslConfig.protocols); serverOptions.setSsl(true); - serverOptions.setSni(sslConfig.sni()); + serverOptions.setSni(sslConfig.sni); int sslPort = httpConfiguration.determineSslPort(launchMode); // -2 instead of -1 (see http) to have vert.x assign two different random ports if both http and https shall be random serverOptions.setPort(sslPort == 0 ? -2 : sslPort); - serverOptions.setClientAuth(buildTimeConfig.tlsClientAuth()); + serverOptions.setClientAuth(buildTimeConfig.tlsClientAuth); applyCommonOptions(serverOptions, buildTimeConfig, httpConfiguration, websocketSubProtocols); @@ -131,37 +131,37 @@ public static HttpServerOptions createSslOptionsForManagementInterface(Managemen ManagementInterfaceConfiguration httpConfiguration, LaunchMode launchMode, List websocketSubProtocols) throws IOException { - if (!httpConfiguration.hostEnabled()) { + if (!httpConfiguration.hostEnabled) { return null; } - ServerSslConfig sslConfig = httpConfiguration.ssl(); + ServerSslConfig sslConfig = httpConfiguration.ssl; final List keys = new ArrayList<>(); final List certificates = new ArrayList<>(); - if (sslConfig.certificate().keyFiles().isPresent()) { - keys.addAll(sslConfig.certificate().keyFiles().get()); + if (sslConfig.certificate.keyFiles.isPresent()) { + keys.addAll(sslConfig.certificate.keyFiles.get()); } - if (sslConfig.certificate().files().isPresent()) { - certificates.addAll(sslConfig.certificate().files().get()); + if (sslConfig.certificate.files.isPresent()) { + certificates.addAll(sslConfig.certificate.files.get()); } // credentials provider Map credentials = Map.of(); - if (sslConfig.certificate().credentialsProvider().isPresent()) { - String beanName = sslConfig.certificate().credentialsProviderName().orElse(null); + if (sslConfig.certificate.credentialsProvider.isPresent()) { + String beanName = sslConfig.certificate.credentialsProviderName.orElse(null); CredentialsProvider credentialsProvider = CredentialsProviderFinder.find(beanName); - String name = sslConfig.certificate().credentialsProvider().get(); + String name = sslConfig.certificate.credentialsProvider.get(); credentials = credentialsProvider.getCredentials(name); } - final Optional keyStoreFile = sslConfig.certificate().keyStoreFile(); - final Optional keyStorePassword = getCredential(sslConfig.certificate().keyStorePassword(), credentials, - sslConfig.certificate().keyStorePasswordKey()); - final Optional keyStoreKeyPassword = getCredential(sslConfig.certificate().keyStoreKeyPassword(), credentials, - sslConfig.certificate().keyStoreKeyPasswordKey()); - final Optional trustStoreFile = sslConfig.certificate().trustStoreFile(); - final Optional trustStorePassword = getCredential(sslConfig.certificate().trustStorePassword(), credentials, - sslConfig.certificate().trustStorePasswordKey()); + final Optional keyStoreFile = sslConfig.certificate.keyStoreFile; + final Optional keyStorePassword = getCredential(sslConfig.certificate.keyStorePassword, credentials, + sslConfig.certificate.keyStorePasswordKey); + final Optional keyStoreKeyPassword = getCredential(sslConfig.certificate.keyStoreKeyPassword, credentials, + sslConfig.certificate.keyStoreKeyPasswordKey); + final Optional trustStoreFile = sslConfig.certificate.trustStoreFile; + final Optional trustStorePassword = getCredential(sslConfig.certificate.trustStorePassword, credentials, + sslConfig.certificate.trustStorePasswordKey); final HttpServerOptions serverOptions = new HttpServerOptions(); //ssl @@ -169,7 +169,7 @@ public static HttpServerOptions createSslOptionsForManagementInterface(Managemen serverOptions.setUseAlpn(true); serverOptions.setAlpnVersions(Arrays.asList(HttpVersion.HTTP_2, HttpVersion.HTTP_1_1)); } - int idleTimeout = (int) httpConfiguration.idleTimeout().toMillis(); + int idleTimeout = (int) httpConfiguration.idleTimeout.toMillis(); serverOptions.setIdleTimeout(idleTimeout); serverOptions.setIdleTimeoutUnit(TimeUnit.MILLISECONDS); @@ -179,9 +179,9 @@ public static HttpServerOptions createSslOptionsForManagementInterface(Managemen KeyStoreOptions options = createKeyStoreOptions( keyStoreFile.get(), keyStorePassword.orElse("password"), - sslConfig.certificate().keyStoreFileType(), - sslConfig.certificate().keyStoreProvider(), - sslConfig.certificate().keyStoreKeyAlias(), + sslConfig.certificate.keyStoreFileType, + sslConfig.certificate.keyStoreProvider, + sslConfig.certificate.keyStoreKeyAlias, keyStoreKeyPassword); serverOptions.setKeyCertOptions(options); } @@ -193,25 +193,25 @@ public static HttpServerOptions createSslOptionsForManagementInterface(Managemen KeyStoreOptions options = createKeyStoreOptions( trustStoreFile.get(), trustStorePassword.get(), - sslConfig.certificate().trustStoreFileType(), - sslConfig.certificate().trustStoreProvider(), - sslConfig.certificate().trustStoreCertAlias(), + sslConfig.certificate.trustStoreFileType, + sslConfig.certificate.trustStoreProvider, + sslConfig.certificate.trustStoreCertAlias, Optional.empty()); serverOptions.setTrustOptions(options); } - for (String cipher : sslConfig.cipherSuites().orElse(Collections.emptyList())) { + for (String cipher : sslConfig.cipherSuites.orElse(Collections.emptyList())) { serverOptions.addEnabledCipherSuite(cipher); } - serverOptions.setEnabledSecureTransportProtocols(sslConfig.protocols()); + serverOptions.setEnabledSecureTransportProtocols(sslConfig.protocols); serverOptions.setSsl(true); - serverOptions.setSni(sslConfig.sni()); + serverOptions.setSni(sslConfig.sni); int sslPort = httpConfiguration.determinePort(launchMode); // -2 instead of -1 (see http) to have vert.x assign two different random ports if both http and https shall be random serverOptions.setPort(sslPort == 0 ? -2 : sslPort); - serverOptions.setClientAuth(buildTimeConfig.tlsClientAuth()); + serverOptions.setClientAuth(buildTimeConfig.tlsClientAuth); applyCommonOptionsForManagementInterface(serverOptions, buildTimeConfig, httpConfiguration, websocketSubProtocols); @@ -235,74 +235,73 @@ public static void applyCommonOptions(HttpServerOptions httpServerOptions, HttpBuildTimeConfig buildTimeConfig, HttpConfiguration httpConfiguration, List websocketSubProtocols) { - httpServerOptions.setHost(httpConfiguration.host()); + httpServerOptions.setHost(httpConfiguration.host); setIdleTimeout(httpConfiguration, httpServerOptions); - httpServerOptions.setMaxHeaderSize(httpConfiguration.limits().maxHeaderSize().asBigInteger().intValueExact()); - httpServerOptions.setMaxChunkSize(httpConfiguration.limits().maxChunkSize().asBigInteger().intValueExact()); - httpServerOptions - .setMaxFormAttributeSize(httpConfiguration.limits().maxFormAttributeSize().asBigInteger().intValueExact()); + httpServerOptions.setMaxHeaderSize(httpConfiguration.limits.maxHeaderSize.asBigInteger().intValueExact()); + httpServerOptions.setMaxChunkSize(httpConfiguration.limits.maxChunkSize.asBigInteger().intValueExact()); + httpServerOptions.setMaxFormAttributeSize(httpConfiguration.limits.maxFormAttributeSize.asBigInteger().intValueExact()); httpServerOptions.setWebSocketSubProtocols(websocketSubProtocols); - httpServerOptions.setReusePort(httpConfiguration.soReusePort()); - httpServerOptions.setTcpQuickAck(httpConfiguration.tcpQuickAck()); - httpServerOptions.setTcpCork(httpConfiguration.tcpCork()); - httpServerOptions.setAcceptBacklog(httpConfiguration.acceptBacklog()); - httpServerOptions.setTcpFastOpen(httpConfiguration.tcpFastOpen()); - httpServerOptions.setCompressionSupported(buildTimeConfig.enableCompression()); - if (buildTimeConfig.compressionLevel().isPresent()) { - httpServerOptions.setCompressionLevel(buildTimeConfig.compressionLevel().getAsInt()); + httpServerOptions.setReusePort(httpConfiguration.soReusePort); + httpServerOptions.setTcpQuickAck(httpConfiguration.tcpQuickAck); + httpServerOptions.setTcpCork(httpConfiguration.tcpCork); + httpServerOptions.setAcceptBacklog(httpConfiguration.acceptBacklog); + httpServerOptions.setTcpFastOpen(httpConfiguration.tcpFastOpen); + httpServerOptions.setCompressionSupported(buildTimeConfig.enableCompression); + if (buildTimeConfig.compressionLevel.isPresent()) { + httpServerOptions.setCompressionLevel(buildTimeConfig.compressionLevel.getAsInt()); } - httpServerOptions.setDecompressionSupported(buildTimeConfig.enableDecompression()); - httpServerOptions.setMaxInitialLineLength(httpConfiguration.limits().maxInitialLineLength()); - httpServerOptions.setHandle100ContinueAutomatically(httpConfiguration.handle100ContinueAutomatically()); + httpServerOptions.setDecompressionSupported(buildTimeConfig.enableDecompression); + httpServerOptions.setMaxInitialLineLength(httpConfiguration.limits.maxInitialLineLength); + httpServerOptions.setHandle100ContinueAutomatically(httpConfiguration.handle100ContinueAutomatically); - if (httpConfiguration.http2()) { + if (httpConfiguration.http2) { var settings = new Http2Settings(); - if (httpConfiguration.limits().headerTableSize().isPresent()) { - settings.setHeaderTableSize(httpConfiguration.limits().headerTableSize().getAsLong()); + if (httpConfiguration.limits.headerTableSize.isPresent()) { + settings.setHeaderTableSize(httpConfiguration.limits.headerTableSize.getAsLong()); } - settings.setPushEnabled(httpConfiguration.http2PushEnabled()); - if (httpConfiguration.limits().maxConcurrentStreams().isPresent()) { - settings.setMaxConcurrentStreams(httpConfiguration.limits().maxConcurrentStreams().getAsLong()); + settings.setPushEnabled(httpConfiguration.http2PushEnabled); + if (httpConfiguration.limits.maxConcurrentStreams.isPresent()) { + settings.setMaxConcurrentStreams(httpConfiguration.limits.maxConcurrentStreams.getAsLong()); } - if (httpConfiguration.initialWindowSize().isPresent()) { - settings.setInitialWindowSize(httpConfiguration.initialWindowSize().getAsInt()); + if (httpConfiguration.initialWindowSize.isPresent()) { + settings.setInitialWindowSize(httpConfiguration.initialWindowSize.getAsInt()); } - if (httpConfiguration.limits().maxFrameSize().isPresent()) { - settings.setMaxFrameSize(httpConfiguration.limits().maxFrameSize().getAsInt()); + if (httpConfiguration.limits.maxFrameSize.isPresent()) { + settings.setMaxFrameSize(httpConfiguration.limits.maxFrameSize.getAsInt()); } - if (httpConfiguration.limits().maxHeaderListSize().isPresent()) { - settings.setMaxHeaderListSize(httpConfiguration.limits().maxHeaderListSize().getAsLong()); + if (httpConfiguration.limits.maxHeaderListSize.isPresent()) { + settings.setMaxHeaderListSize(httpConfiguration.limits.maxHeaderListSize.getAsLong()); } httpServerOptions.setInitialSettings(settings); } - httpServerOptions.setUseProxyProtocol(httpConfiguration.proxy().useProxyProtocol()); + httpServerOptions.setUseProxyProtocol(httpConfiguration.proxy.useProxyProtocol); } public static void applyCommonOptionsForManagementInterface(HttpServerOptions options, ManagementInterfaceBuildTimeConfig buildTimeConfig, ManagementInterfaceConfiguration httpConfiguration, List websocketSubProtocols) { - options.setHost(httpConfiguration.host().orElse("0.0.0.0")); + options.setHost(httpConfiguration.host.orElse("0.0.0.0")); - int idleTimeout = (int) httpConfiguration.idleTimeout().toMillis(); + int idleTimeout = (int) httpConfiguration.idleTimeout.toMillis(); options.setIdleTimeout(idleTimeout); options.setIdleTimeoutUnit(TimeUnit.MILLISECONDS); - options.setMaxHeaderSize(httpConfiguration.limits().maxHeaderSize().asBigInteger().intValueExact()); - options.setMaxChunkSize(httpConfiguration.limits().maxChunkSize().asBigInteger().intValueExact()); - options.setMaxFormAttributeSize(httpConfiguration.limits().maxFormAttributeSize().asBigInteger().intValueExact()); - options.setMaxInitialLineLength(httpConfiguration.limits().maxInitialLineLength()); + options.setMaxHeaderSize(httpConfiguration.limits.maxHeaderSize.asBigInteger().intValueExact()); + options.setMaxChunkSize(httpConfiguration.limits.maxChunkSize.asBigInteger().intValueExact()); + options.setMaxFormAttributeSize(httpConfiguration.limits.maxFormAttributeSize.asBigInteger().intValueExact()); + options.setMaxInitialLineLength(httpConfiguration.limits.maxInitialLineLength); options.setWebSocketSubProtocols(websocketSubProtocols); - options.setAcceptBacklog(httpConfiguration.acceptBacklog()); - options.setCompressionSupported(buildTimeConfig.enableCompression()); - if (buildTimeConfig.compressionLevel().isPresent()) { - options.setCompressionLevel(buildTimeConfig.compressionLevel().getAsInt()); + options.setAcceptBacklog(httpConfiguration.acceptBacklog); + options.setCompressionSupported(buildTimeConfig.enableCompression); + if (buildTimeConfig.compressionLevel.isPresent()) { + options.setCompressionLevel(buildTimeConfig.compressionLevel.getAsInt()); } - options.setDecompressionSupported(buildTimeConfig.enableDecompression()); - options.setHandle100ContinueAutomatically(httpConfiguration.handle100ContinueAutomatically()); + options.setDecompressionSupported(buildTimeConfig.enableDecompression); + options.setHandle100ContinueAutomatically(httpConfiguration.handle100ContinueAutomatically); - options.setUseProxyProtocol(httpConfiguration.proxy().useProxyProtocol()); + options.setUseProxyProtocol(httpConfiguration.proxy.useProxyProtocol); } private static KeyStoreOptions createKeyStoreOptions(Path path, String password, Optional fileType, @@ -383,7 +382,7 @@ private static byte[] doRead(InputStream is) throws IOException { } private static void setIdleTimeout(HttpConfiguration httpConfiguration, HttpServerOptions options) { - int idleTimeout = (int) httpConfiguration.idleTimeout().toMillis(); + int idleTimeout = (int) httpConfiguration.idleTimeout.toMillis(); options.setIdleTimeout(idleTimeout); options.setIdleTimeoutUnit(TimeUnit.MILLISECONDS); } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/AbstractPathMatchingHttpSecurityPolicy.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/AbstractPathMatchingHttpSecurityPolicy.java index d9ef00a58b239..185387e80061a 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/AbstractPathMatchingHttpSecurityPolicy.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/AbstractPathMatchingHttpSecurityPolicy.java @@ -89,25 +89,25 @@ public void init(Map permissions, Map> tempMap = new HashMap<>(); for (Map.Entry entry : permissions.entrySet()) { - HttpSecurityPolicy checker = permissionCheckers.get(entry.getValue().policy()); + HttpSecurityPolicy checker = permissionCheckers.get(entry.getValue().policy); if (checker == null) { - throw new RuntimeException("Unable to find HTTP security policy " + entry.getValue().policy()); + throw new RuntimeException("Unable to find HTTP security policy " + entry.getValue().policy); } - if (entry.getValue().enabled().orElse(Boolean.TRUE)) { - for (String path : entry.getValue().paths().orElse(Collections.emptyList())) { + if (entry.getValue().enabled.orElse(Boolean.TRUE)) { + for (String path : entry.getValue().paths.orElse(Collections.emptyList())) { path = path.trim(); if (!path.startsWith("/")) { path = rootPath + path; } if (tempMap.containsKey(path)) { - HttpMatcher m = new HttpMatcher(entry.getValue().authMechanism().orElse(null), - new HashSet<>(entry.getValue().methods().orElse(Collections.emptyList())), + HttpMatcher m = new HttpMatcher(entry.getValue().authMechanism.orElse(null), + new HashSet<>(entry.getValue().methods.orElse(Collections.emptyList())), checker); tempMap.get(path).add(m); } else { - HttpMatcher m = new HttpMatcher(entry.getValue().authMechanism().orElse(null), - new HashSet<>(entry.getValue().methods().orElse(Collections.emptyList())), + HttpMatcher m = new HttpMatcher(entry.getValue().authMechanism.orElse(null), + new HashSet<>(entry.getValue().methods.orElse(Collections.emptyList())), checker); List perms = new ArrayList<>(); tempMap.put(path, perms); diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpSecurityRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpSecurityRecorder.java index a688891631bf0..84b3ef16064ad 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpSecurityRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpSecurityRecorder.java @@ -94,7 +94,7 @@ public BeanContainerListener initPermissions(HttpBuildTimeConfig buildTimeConfig @Override public void created(BeanContainer container) { container.beanInstance(PathMatchingHttpSecurityPolicy.class) - .init(buildTimeConfig.auth().permissions(), policies, buildTimeConfig.rootPath()); + .init(buildTimeConfig.auth.permissions, policies, buildTimeConfig.rootPath); } }; } @@ -106,7 +106,7 @@ public Supplier setupFormAuth() { @Override public FormAuthenticationMechanism get() { String key; - if (!httpConfiguration.getValue().encryptionKey().isPresent()) { + if (!httpConfiguration.getValue().encryptionKey.isPresent()) { if (encryptionKey != null) { //persist across dev mode restarts key = encryptionKey; @@ -117,24 +117,23 @@ public FormAuthenticationMechanism get() { log.warn("Encryption key was not specified for persistent FORM auth, using temporary key " + key); } } else { - key = httpConfiguration.getValue().encryptionKey().get(); + key = httpConfiguration.getValue().encryptionKey.get(); } - FormAuthConfig form = buildTimeConfig.auth().form(); - PersistentLoginManager loginManager = new PersistentLoginManager(key, form.cookieName(), - form.timeout().toMillis(), - form.newCookieInterval().toMillis(), form.httpOnlyCookie(), form.cookieSameSite().name(), - form.cookiePath().orElse(null)); - String loginPage = startWithSlash(form.loginPage().orElse(null)); - String errorPage = startWithSlash(form.errorPage().orElse(null)); - String landingPage = startWithSlash(form.landingPage().orElse(null)); - String postLocation = startWithSlash(form.postLocation()); - String usernameParameter = form.usernameParameter(); - String passwordParameter = form.passwordParameter(); - String locationCookie = form.locationCookie(); - String cookiePath = form.cookiePath().orElse(null); - boolean redirectAfterLogin = form.redirectAfterLogin(); + FormAuthConfig form = buildTimeConfig.auth.form; + PersistentLoginManager loginManager = new PersistentLoginManager(key, form.cookieName, form.timeout.toMillis(), + form.newCookieInterval.toMillis(), form.httpOnlyCookie, form.cookieSameSite.name(), + form.cookiePath.orElse(null)); + String loginPage = startWithSlash(form.loginPage.orElse(null)); + String errorPage = startWithSlash(form.errorPage.orElse(null)); + String landingPage = startWithSlash(form.landingPage.orElse(null)); + String postLocation = startWithSlash(form.postLocation); + String usernameParameter = form.usernameParameter; + String passwordParameter = form.passwordParameter; + String locationCookie = form.locationCookie; + String cookiePath = form.cookiePath.orElse(null); + boolean redirectAfterLogin = form.redirectAfterLogin; return new FormAuthenticationMechanism(loginPage, postLocation, usernameParameter, passwordParameter, - errorPage, landingPage, redirectAfterLogin, locationCookie, form.cookieSameSite().name(), cookiePath, + errorPage, landingPage, redirectAfterLogin, locationCookie, form.cookieSameSite.name(), cookiePath, loginManager); } }; @@ -151,8 +150,8 @@ public Supplier setupBasicAuth(HttpBuildTimeConfig buildTimeConfig) { return new Supplier() { @Override public BasicAuthenticationMechanism get() { - return new BasicAuthenticationMechanism(buildTimeConfig.auth().realm().orElse(null), - buildTimeConfig.auth().form().enabled()); + return new BasicAuthenticationMechanism(buildTimeConfig.auth.realm.orElse(null), + buildTimeConfig.auth.form.enabled); } }; } diff --git a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/WebJarLocatorStandaloneBuildStep.java b/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/WebJarLocatorStandaloneBuildStep.java index f8aba4274b42e..95dd06ed48fb7 100644 --- a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/WebJarLocatorStandaloneBuildStep.java +++ b/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/WebJarLocatorStandaloneBuildStep.java @@ -87,7 +87,7 @@ public void findWebjarsAndCreateHandler( if (!webjarNameToVersionMap.isEmpty()) { // The context path + the resources path - String rootPath = httpConfig.rootPath(); + String rootPath = httpConfig.rootPath; String webjarRootPath = (rootPath.endsWith("/")) ? rootPath + "webjars/" : rootPath + "/webjars/"; feature.produce(new FeatureBuildItem(Feature.WEBJARS_LOCATOR)); routes.produce( diff --git a/integration-tests/oidc/src/main/resources/application.properties b/integration-tests/oidc/src/main/resources/application.properties index 104e58e33cc5b..c9e1a6d9f3511 100644 --- a/integration-tests/oidc/src/main/resources/application.properties +++ b/integration-tests/oidc/src/main/resources/application.properties @@ -11,7 +11,7 @@ quarkus.oidc.tls.key-store-file=client-keystore.jks quarkus.oidc.tls.key-store-password=password quarkus.native.additional-build-args=-H:IncludeResources=.*\\.jks -quarkus.http.cors.enabled=true +quarkus.http.cors=true quarkus.http.cors.origins=* quarkus.http.auth.basic=true diff --git a/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownConfigTest.java b/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownConfigTest.java index eba70b89bc9ae..97b201903d50f 100644 --- a/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownConfigTest.java +++ b/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownConfigTest.java @@ -45,7 +45,7 @@ public class UnknownConfigTest { @Test void unknown() { assertEquals("1234", config.getConfigValue("quarkus.unknown.prop").getValue()); - assertEquals("/1234", httpBuildTimeConfig.nonApplicationRootPath()); - assertEquals(4443, httpConfiguration.sslPort()); + assertEquals("/1234", httpBuildTimeConfig.nonApplicationRootPath); + assertEquals(4443, httpConfiguration.sslPort); } }