Skip to content

Commit

Permalink
[#3285] Support mongodb+srv scheme in connection string
Browse files Browse the repository at this point in the history
The mongodb+srv scheme requires JNDI to be available in the JRE.
However, Quarkus by default disables JNDI for security reasons.

The MongoDB based registry now uses the Quarkus Mongo Client extension
which enables JNDI in JVM mode and provides means to use vert.x DNS
resolver instead of JNDI when running as a native executable, where JNDI
is not available by definition.

Fixes #3285

Signed-off-by: Kai Hudalla <[email protected]>
  • Loading branch information
sophokles73 committed Jun 9, 2022
1 parent 88a672b commit b35e090
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
6 changes: 6 additions & 0 deletions legal/src/main/resources/legal/DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ maven/mavencentral/io.quarkus/quarkus-kubernetes-client-internal/2.8.3.Final, Ap
maven/mavencentral/io.quarkus/quarkus-logging-gelf/2.8.3.Final, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.quarkus/quarkus-micrometer/2.8.3.Final, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.quarkus/quarkus-micrometer-registry-prometheus/2.8.3.Final, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.quarkus/quarkus-mongodb-client/2.8.3.Final, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.quarkus/quarkus-mutiny/2.8.3.Final, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.quarkus/quarkus-mutiny-reactive-streams-operators/2.8.3.Final, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.quarkus/quarkus-netty/2.8.3.Final, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.quarkus/quarkus-opentelemetry/2.8.3.Final, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.quarkus/quarkus-opentelemetry-exporter-otlp/2.8.3.Final, Apache-2.0, approved, clearlydefined
Expand All @@ -147,6 +149,7 @@ maven/mavencentral/io.smallrye.config/smallrye-config-common/2.9.2, Apache-2.0,
maven/mavencentral/io.smallrye.config/smallrye-config-core/2.9.2, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.smallrye.config/smallrye-config-source-yaml/2.9.2, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.smallrye.reactive/mutiny/1.4.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.smallrye.reactive/mutiny-reactive-streams-operators/1.4.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.smallrye.reactive/mutiny-smallrye-context-propagation/1.4.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.smallrye.reactive/smallrye-mutiny-vertx-auth-common/2.21.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.smallrye.reactive/smallrye-mutiny-vertx-bridge-common/2.21.0, Apache-2.0, approved, clearlydefined
Expand Down Expand Up @@ -189,6 +192,7 @@ maven/mavencentral/jakarta.interceptor/jakarta.interceptor-api/1.2.5, , approved
maven/mavencentral/jakarta.transaction/jakarta.transaction-api/1.3.3, , approved, eclipse
maven/mavencentral/jakarta.ws.rs/jakarta.ws.rs-api/2.1.6, , approved, ee4j.jaxrs
maven/mavencentral/jakarta.xml.bind/jakarta.xml.bind-api/2.3.3, BSD-3-Clause, approved, ee4j.jaxb
maven/mavencentral/net.java.dev.jna/jna/5.8.0, Apache-2.0 OR LGPL-2.1-or-later, approved, CQ23217
maven/mavencentral/org.apache.commons/commons-collections4/4.2, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.apache.commons/commons-compress/1.21, Apache-2.0 AND BSD-3-Clause AND bzip2-1.0.6 AND LicenseRef-Public-Domain, approved, CQ23710
maven/mavencentral/org.apache.kafka/kafka-clients/2.8.1, Apache-2.0, approved, clearlydefined
Expand Down Expand Up @@ -217,8 +221,10 @@ maven/mavencentral/org.jline/jline/3.19.0, BSD-3-Clause, approved, clearlydefine
maven/mavencentral/org.latencyutils/LatencyUtils/2.0.3, BSD-2-Clause, approved, CQ17408
maven/mavencentral/org.lz4/lz4-java/1.8.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.mongodb/bson/4.3.4, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.mongodb/mongodb-crypt/1.2.1, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.mongodb/mongodb-driver-core/4.3.4, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.mongodb/mongodb-driver-reactivestreams/4.3.4, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.mongodb/mongodb-driver-sync/4.3.4, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.postgresql/postgresql/42.3.3, BSD-2-Clause, approved, #2487
maven/mavencentral/org.reactivestreams/reactive-streams/1.0.3, CC0-1.0, approved, CQ16332
maven/mavencentral/org.slf4j/slf4j-api/1.7.36, MIT, approved, CQ13368
Expand Down
6 changes: 6 additions & 0 deletions legal/src/main/resources/legal/hono-maven.deps
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ io.quarkus:quarkus-kubernetes-client:jar:2.8.3.Final
io.quarkus:quarkus-logging-gelf:jar:2.8.3.Final
io.quarkus:quarkus-micrometer:jar:2.8.3.Final
io.quarkus:quarkus-micrometer-registry-prometheus:jar:2.8.3.Final
io.quarkus:quarkus-mongodb-client:jar:2.8.3.Final
io.quarkus:quarkus-mutiny:jar:2.8.3.Final
io.quarkus:quarkus-mutiny-reactive-streams-operators:jar:2.8.3.Final
io.quarkus:quarkus-netty:jar:2.8.3.Final
io.quarkus:quarkus-opentelemetry-exporter-otlp:jar:2.8.3.Final
io.quarkus:quarkus-opentelemetry:jar:2.8.3.Final
Expand All @@ -147,6 +149,7 @@ io.smallrye.config:smallrye-config-core:jar:2.9.2
io.smallrye.config:smallrye-config:jar:2.9.2
io.smallrye.config:smallrye-config-source-yaml:jar:2.9.2
io.smallrye.reactive:mutiny:jar:1.4.0
io.smallrye.reactive:mutiny-reactive-streams-operators:jar:1.4.0
io.smallrye.reactive:mutiny-smallrye-context-propagation:jar:1.4.0
io.smallrye.reactive:smallrye-mutiny-vertx-auth-common:jar:2.21.0
io.smallrye.reactive:smallrye-mutiny-vertx-bridge-common:jar:2.21.0
Expand Down Expand Up @@ -189,6 +192,7 @@ jakarta.interceptor:jakarta.interceptor-api:jar:1.2.5
jakarta.transaction:jakarta.transaction-api:jar:1.3.3
jakarta.ws.rs:jakarta.ws.rs-api:jar:2.1.6
jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3
net.java.dev.jna:jna:jar:5.8.0
org.apache.commons:commons-collections4:jar:4.2
org.apache.commons:commons-compress:jar:1.21
org.apache.kafka:kafka-clients:jar:2.8.1
Expand Down Expand Up @@ -217,8 +221,10 @@ org.jline:jline:jar:3.19.0
org.latencyutils:LatencyUtils:jar:2.0.3
org.lz4:lz4-java:jar:1.8.0
org.mongodb:bson:jar:4.3.4
org.mongodb:mongodb-crypt:jar:1.2.1
org.mongodb:mongodb-driver-core:jar:4.3.4
org.mongodb:mongodb-driver-reactivestreams:jar:4.3.4
org.mongodb:mongodb-driver-sync:jar:4.3.4
org.postgresql:postgresql:jar:42.3.3
org.reactivestreams:reactive-streams:jar:1.0.3
org.slf4j:slf4j-api:jar:1.7.36
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,17 @@ protected void doStart() {
log.info("successfully deployed authentication service verticle");
deploymentResult.put("authentication service verticle", "successfully deployed");
registerHealthCheckProvider(authenticationService);
});
})
.onFailure(t -> log.error("failed to deploy authentication service verticle", t));

// deploy notification sender (once only)
final Future<String> notificationSenderDeploymentTracker = vertx.deployVerticle(
new WrappedLifecycleComponentVerticle(notificationSender))
.onSuccess(ok -> {
log.info("successfully deployed notification sender verticle(s)");
log.info("successfully deployed notification sender verticle");
deploymentResult.put("notification sender verticle", "successfully deployed");
});
})
.onFailure(t -> log.error("failed to deploy notification sender verticle", t));


// deploy AMQP 1.0 server
Expand All @@ -83,7 +85,8 @@ protected void doStart() {
.onSuccess(ok -> {
log.info("successfully deployed AMQP server verticle(s)");
deploymentResult.put("AMQP server verticle(s)", "successfully deployed");
});
})
.onFailure(t -> log.error("failed to deploy AMQP server verticle(s)", t));

// deploy HTTP server
final Future<String> httpServerDeploymentTracker = vertx.deployVerticle(
Expand All @@ -92,7 +95,8 @@ protected void doStart() {
.onSuccess(ok -> {
log.info("successfully deployed HTTP server verticle(s)");
deploymentResult.put("HTTP server verticle(s)", "successfully deployed");
});
})
.onFailure(t -> log.error("failed to deploy HTTP server verticle(s)", t));

CompositeFuture.all(
authServiceDeploymentTracker,
Expand Down
4 changes: 4 additions & 0 deletions services/device-registry-mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kafka-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mongodb-client</artifactId>
</dependency>

<!-- testing -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public CredentialsDao credentialsDao(

final var encryptionHelper = options.encryptionKeyFile()
.map(this::fieldLevelEncryption)
.orElse( FieldLevelEncryption.NOOP_ENCRYPTION);
.orElse(FieldLevelEncryption.NOOP_ENCRYPTION);

final var dao = new MongoDbBasedCredentialsDao(
mongoClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ ${quarkus.application.properties}
quarkus.jackson.accept-case-insensitive-enums=true
# fail deserialization of JSON objects sent by clients if they contain unexpected content
quarkus.jackson.fail-on-unknown-properties=true

# this is needed in order to support mongodb+srv:// style connection strings in native executable
# see https://quarkus.io/guides/mongodb
quarkus.mongodb.native.dns.use-vertx-dns-resolver=true

0 comments on commit b35e090

Please sign in to comment.