gnodet commented on code in PR #25187:
URL: https://github.com/apache/camel/pull/25187#discussion_r3665182582
##########
core/camel-main/src/main/java/org/apache/camel/main/HttpManagementServerConfigurationProperties.java:
##########
@@ -77,6 +77,8 @@ public class HttpManagementServerConfigurationProperties
implements BootstrapClo
private String jwtIssuer;
@Metadata(label = "security")
private String jwtAudience;
+ @Metadata(label = "security", defaultValue = "false")
+ private boolean jwtAllowMissingIssuerAndAudience;
Review Comment:
Same here — this file already uses `security = "insecure:dev"` on
`devConsoleEnabled`, `uploadEnabled`, `downloadEnabled`, and `sendEnabled`, so
the pattern is well established.
```suggestion
@Metadata(label = "security", defaultValue = "false", security =
"insecure:dev")
private boolean jwtAllowMissingIssuerAndAudience;
```
##########
core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java:
##########
@@ -68,6 +68,8 @@ public class HttpServerConfigurationProperties implements
BootstrapCloseable {
private String jwtIssuer;
@Metadata(label = "security")
private String jwtAudience;
+ @Metadata(label = "security", defaultValue = "false")
+ private boolean jwtAllowMissingIssuerAndAudience;
Review Comment:
The `jwtAllowMissingIssuerAndAudience` flag weakens security (it opts out of
issuer/audience validation), so per the project convention it should carry
`security = "insecure:dev"` on its `@Metadata` annotation — the same pattern
used for `trustAllCertificates`, `allowJavaSerializedObject`, etc. Without it,
the security policy framework (`camel.main.profile = prod`) cannot warn about
or block this flag in production.
```suggestion
@Metadata(label = "security", defaultValue = "false", security =
"insecure:dev")
private boolean jwtAllowMissingIssuerAndAudience;
```
##########
components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/authentication/JWTIssuerAudienceRequiredMainHttpServerTest.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.platform.http.main.authentication;
+
+import io.vertx.core.Vertx;
+import io.vertx.core.json.JsonObject;
+import io.vertx.ext.auth.JWTOptions;
+import io.vertx.ext.auth.jwt.JWTAuth;
+import io.vertx.ext.auth.jwt.JWTAuthOptions;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.main.HttpManagementServerConfigurationProperties;
+import org.apache.camel.main.HttpServerConfigurationProperties;
+import org.apache.camel.main.Main;
+import org.apache.camel.test.AvailablePortFinder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static io.restassured.RestAssured.given;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * A JWT authenticator built without an issuer or an audience only verifies
the token signature and the exp/nbf claims,
+ * so the embedded server refuses to start in that configuration unless the
opt-out is set.
+ */
+class JWTIssuerAudienceRequiredMainHttpServerTest {
+
+ @RegisterExtension
+ static AvailablePortFinder.Port port = AvailablePortFinder.find();
+
+ @Test
+ void serverFailsToStartWithoutIssuerOrAudience() {
+ Main main = MainHttpServerAuthenticationTestSupport.createMain(
+ "jwt-auth-no-issuer-audience.properties", port, new
PlatformHttpRouteBuilder());
+ try {
+ assertThatThrownBy(main::start)
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("camel.server.jwtIssuer")
+ .hasMessageContaining("camel.server.jwtAudience")
+
.hasMessageContaining("camel.server.jwtAllowMissingIssuerAndAudience");
+ } finally {
+ MainHttpServerAuthenticationTestSupport.stopMain(main);
+ }
+ }
+
+ @Test
+ void optOutStartsAndValidatesSignatureAndExpiryOnly() {
+ // jwt-auth.properties sets jwtAllowMissingIssuerAndAudience=true
+ Main main = MainHttpServerAuthenticationTestSupport.createMain(
+ "jwt-auth.properties", port, new PlatformHttpRouteBuilder());
+ try {
+ main.start();
+
Review Comment:
Minor: the `Vertx.vertx()` instances created here and in
`configuredIssuerAndAudienceRejectAForeignToken()` are never closed, leaking
native event-loop threads. This follows the pre-existing pattern in
`JWTAuthenticationMainHttpServerTest`, but consider extracting a shared `Vertx`
instance with proper cleanup.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]