oscerd commented on code in PR #25187:
URL: https://github.com/apache/camel/pull/25187#discussion_r3665738690


##########
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:
   Done — jwtAllowMissingIssuerAndAudience in HttpServerConfigurationProperties 
now carries @Metadata(label = "security", defaultValue = "false", security = 
"insecure:dev"), so the prod profile can flag it.\n\n_Claude Code on behalf of 
Andrea Cosentino (@oscerd)._



##########
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:
   Done — same annotation applied to the flag in 
HttpManagementServerConfigurationProperties, matching 
devConsoleEnabled/uploadEnabled/etc.\n\n_Claude Code on behalf of Andrea 
Cosentino (@oscerd)._



##########
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:
   Done — the test now uses a single shared private static final Vertx VERTX = 
Vertx.vertx() closed in @AfterAll, so it no longer leaks event-loop 
threads.\n\n_Claude Code on behalf of Andrea Cosentino (@oscerd)._



-- 
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]

Reply via email to