Skip to content

Commit

Permalink
Move http configuration to @ConfigMapping
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Dec 15, 2024
1 parent d8069b0 commit 6f323ad
Show file tree
Hide file tree
Showing 83 changed files with 1,015 additions and 1,121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void staticInit(FunqyHttpBindingRecorder binding,
return;

// The context path + the resources path
String rootPath = httpConfig.rootPath;
String rootPath = httpConfig.rootPath();
binding.init();
}

Expand All @@ -81,7 +81,7 @@ public void boot(ShutdownContextBuildItem shutdown,
return;
feature.produce(new FeatureBuildItem(FUNQY_HTTP_FEATURE));

String rootPath = httpConfig.rootPath;
String rootPath = httpConfig.rootPath();
Handler<RoutingContext> handler = binding.start(rootPath,
vertx.getVertx(),
shutdown,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,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("/")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ 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 = isTLSConfigured(httpConfiguration.ssl.certificate);
this.host = httpConfiguration.host();
this.port = httpConfiguration.port();
this.ssl = isTLSConfigured(httpConfiguration.ssl().certificate());
}
this.grpcServiceClassInfos = getGrpcServiceClassInfos();
this.callsInProgress = new HashMap<>();
}

private boolean isTLSConfigured(CertificateConfig certificate) {
return certificate.files.isPresent()
|| certificate.keyFiles.isPresent()
|| certificate.keyStoreFile.isPresent();
return certificate.files().isPresent()
|| certificate.keyFiles().isPresent()
|| certificate.keyStoreFile().isPresent();
}

public JsonArray getServices() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class DefaultPolicyEnforcerResolver implements PolicyEnforcerResolver {
HttpConfiguration httpConfiguration, BlockingSecurityExecutor blockingSecurityExecutor,
Instance<TenantPolicyConfigResolver> configResolver,
InjectableInstance<TlsConfigurationRegistry> tlsConfigRegistryInstance) {
this.readTimeout = httpConfiguration.readTimeout.toMillis();
this.readTimeout = httpConfiguration.readTimeout().toMillis();

if (tlsConfigRegistryInstance.isResolvable()) {
this.tlsSupport = OidcTlsSupport.of(tlsConfigRegistryInstance.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ public class ManagementRequestPrioritizer implements RequestPrioritizer<HttpServ
@Inject
public ManagementRequestPrioritizer(HttpBuildTimeConfig httpConfig,
ManagementInterfaceBuildTimeConfig managementInterfaceConfig) {
if (managementInterfaceConfig.enabled) {
if (managementInterfaceConfig.enabled()) {
managementPath = null;
return;
}
if (httpConfig.nonApplicationRootPath.startsWith("/")) {
if (httpConfig.nonApplicationRootPath.equals(httpConfig.rootPath)) {
if (httpConfig.nonApplicationRootPath().startsWith("/")) {
if (httpConfig.nonApplicationRootPath().equals(httpConfig.rootPath())) {
managementPath = null;
return;
}
managementPath = httpConfig.nonApplicationRootPath;
managementPath = httpConfig.nonApplicationRootPath();
return;
}
managementPath = httpConfig.rootPath + httpConfig.nonApplicationRootPath;
managementPath = httpConfig.rootPath() + httpConfig.nonApplicationRootPath();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public void registerTenantResolverInterceptor(Capabilities capabilities, OidcRec
CombinedIndexBuildItem combinedIndexBuildItem,
BuildProducer<EagerSecurityInterceptorBindingBuildItem> bindingProducer,
BuildProducer<SystemPropertyBuildItem> systemPropertyProducer) {
if (!buildTimeConfig.auth.proactive
if (!buildTimeConfig.auth().proactive()
&& (capabilities.isPresent(Capability.RESTEASY_REACTIVE) || capabilities.isPresent(Capability.RESTEASY))) {
boolean foundTenantResolver = combinedIndexBuildItem
.getIndex()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void shutdown() {
@NonBlocking
public OidcDevUiRuntimePropertiesDTO getProperties() {
return new OidcDevUiRuntimePropertiesDTO(props.getAuthorizationUrl(), props.getTokenUrl(), props.getLogoutUrl(),
ConfigProvider.getConfig(), httpConfiguration.port,
ConfigProvider.getConfig(), httpConfiguration.port(),
props.getOidcProviderName(), props.getOidcApplicationType(), props.getOidcGrantType(),
props.isIntrospectionIsAvailable(), props.getKeycloakAdminUrl(),
props.getKeycloakRealms(), props.isSwaggerIsAvailable(), props.isGraphqlIsAvailable(), props.getSwaggerUiPath(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public Handler<RoutingContext> runOnVirtualThread(Handler<RoutingContext> routeH
}

public Handler<RoutingContext> compressRouteHandler(Handler<RoutingContext> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,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(),
Expand All @@ -135,7 +135,7 @@ public void boot(ShutdownContextBuildItem shutdown,
// so that user can define failure handlers that precede exception mappers
final Handler<RoutingContext> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void setupUsers() {
}

private boolean isProactiveAuth() {
return httpBuildTimeConfig.auth.proactive;
return httpBuildTimeConfig.auth().proactive();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ public Handler<RoutingContext> vertxRequestHandler(Supplier<Vertx> vertx, Execut
if (deployment != null) {
Handler<RoutingContext> handler = new VertxRequestHandler(vertx.get(), deployment, contextPath,
new ResteasyVertxAllocator(config.responseBufferSize), executor,
readTimeout.getValue().readTimeout.toMillis());
readTimeout.getValue().readTimeout().toMillis());

Set<String> compressMediaTypes = httpBuildTimeConfig.compressMediaTypes.map(Set::copyOf).orElse(Set.of());
if (httpBuildTimeConfig.enableCompression && !compressMediaTypes.isEmpty()) {
Set<String> 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);
}
Expand All @@ -129,7 +129,7 @@ public Handler<RoutingContext> vertxFailureHandler(Supplier<Vertx> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public CompressionScanner(HttpBuildTimeConfig httpBuildTimeConfig) {
@Override
public List<HandlerChainCustomizer> scan(MethodInfo method, ClassInfo actualEndpointClass,
Map<String, Object> methodContext) {
if (!httpBuildTimeConfig.enableCompression) {
if (!httpBuildTimeConfig.enableCompression()) {
return Collections.emptyList();
}

Expand All @@ -58,7 +58,7 @@ public List<HandlerChainCustomizer> 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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,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(),
Expand All @@ -1408,7 +1408,7 @@ public void setupDeployment(BeanContainerBuildItem beanContainerBuildItem,
}

Handler<RoutingContext> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void setupUsers() {
}

private boolean isProactiveAuth() {
return httpBuildTimeConfig.auth.proactive;
return httpBuildTimeConfig.auth().proactive();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public ResteasyReactiveRequestContext createContext(Deployment deployment,
RuntimeDeploymentManager runtimeDeploymentManager = new RuntimeDeploymentManager(info, EXECUTOR_SUPPLIER,
VTHREAD_EXECUTOR_SUPPLIER,
closeTaskHandler, contextFactory, new ArcThreadSetupAction(beanContainer.requestContext()),
vertxConfig.rootPath);
vertxConfig.rootPath());
Deployment deployment = runtimeDeploymentManager.deploy();
DisabledRestEndpoints.set(deployment.getDisabledEndpoints());
initClassFactory.createInstance().getInstance().init(deployment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ public Supplier<RuntimeConfiguration> runtimeConfiguration(RuntimeValue<Deployme
ResteasyReactiveServerRuntimeConfig runtimeConf) {
Optional<Long> 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.maxParameters);
httpConf.limits().maxFormAttributeSize().asLongValue(),
httpConf.limits().maxParameters());

deployment.getValue().setRuntimeConfiguration(runtimeConfiguration);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class EagerSecurityContext {
InjectableInstance<CurrentIdentityAssociation> identityAssociation, AuthorizationController authorizationController,
HttpBuildTimeConfig buildTimeConfig,
JaxRsPathMatchingHttpSecurityPolicy jaxRsPathMatchingPolicy) {
this.isProactiveAuthDisabled = !buildTimeConfig.auth.proactive;
this.isProactiveAuthDisabled = !buildTimeConfig.auth().proactive();
this.identityAssociation = identityAssociation;
this.authorizationController = authorizationController;
this.eventHelper = new SecurityEventHelper<>(authorizationSuccessEvent, authorizationFailureEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Supplier<WebAuthnAuthenticationMechanism> 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;
Expand All @@ -72,7 +72,7 @@ public WebAuthnAuthenticationMechanism get() {
+ 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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ void buildExecutionEndpoint(
// Queries and Mutations
boolean allowGet = getBooleanConfigValue(ConfigKey.ALLOW_GET, false);
boolean allowQueryParametersOnPost = getBooleanConfigValue(ConfigKey.ALLOW_POST_WITH_QUERY_PARAMETERS, false);
boolean allowCompression = httpBuildTimeConfig.enableCompression && httpBuildTimeConfig.compressMediaTypes
boolean allowCompression = httpBuildTimeConfig.enableCompression() && httpBuildTimeConfig.compressMediaTypes()
.map(mediaTypes -> mediaTypes.contains(GRAPHQL_MEDIA_TYPE))
.orElse(false);
Handler<RoutingContext> executionHandler = recorder.executionHandler(graphQLInitializedBuildItem.getInitialized(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public void includeInOpenAPIEndpoint(BuildProducer<AddToOpenAPIDefinitionBuildIt
SmallRyeHealthConfig healthConfig) {

// Add to OpenAPI if OpenAPI is available
if (capabilities.isPresent(Capability.SMALLRYE_OPENAPI) && !managementInterfaceBuildTimeConfig.enabled) {
if (capabilities.isPresent(Capability.SMALLRYE_OPENAPI) && !managementInterfaceBuildTimeConfig.enabled()) {
String healthRootPath = nonApplicationRootPathBuildItem.resolvePath(healthConfig.rootPath);
HealthOpenAPIFilter filter = new HealthOpenAPIFilter(healthRootPath,
nonApplicationRootPathBuildItem.resolveManagementNestedPath(healthRootPath, healthConfig.livenessPath),
Expand Down Expand Up @@ -338,7 +338,7 @@ public void kubernetes(NonApplicationRootPathBuildItem nonApplicationRootPathBui
BuildProducer<KubernetesHealthStartupPathBuildItem> startupPathItemProducer,
BuildProducer<KubernetesProbePortNameBuildItem> port) {

if (managementInterfaceBuildTimeConfig.enabled) {
if (managementInterfaceBuildTimeConfig.enabled()) {
// Switch to the "management" port
port.produce(new KubernetesProbePortNameBuildItem("management", selectSchemeForManagement()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,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];

}

Expand Down Expand Up @@ -454,7 +454,7 @@ private List<String> getUserDefinedFilters(IndexView index, OpenApiFilter.RunSta
private boolean isManagement(ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig,
SmallRyeOpenApiConfig smallRyeOpenApiConfig,
LaunchModeBuildItem launchModeBuildItem) {
return managementInterfaceBuildTimeConfig.enabled && smallRyeOpenApiConfig.managementEnabled
return managementInterfaceBuildTimeConfig.enabled() && smallRyeOpenApiConfig.managementEnabled
&& launchModeBuildItem.getLaunchMode().equals(LaunchMode.DEVELOPMENT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public OpenApiRecorder(RuntimeValue<HttpConfiguration> configuration) {
}

public Consumer<Route> corsFilter(Filter filter) {
if (configuration.getValue().corsEnabled && filter.getHandler() != null) {
if (configuration.getValue().corsEnabled() && filter.getHandler() != null) {
return new Consumer<Route>() {
@Override
public void accept(Route route) {
Expand Down
Loading

0 comments on commit 6f323ad

Please sign in to comment.