ramu11 commented on code in PR #9509:
URL: https://github.com/apache/camel-quarkus/pull/9509#discussion_r4588183575


##########
integration-tests/mcp-server/src/test/java/org/apache/camel/quarkus/component/mcp/server/it/McpServerKeycloakTestResource.java:
##########
@@ -0,0 +1,74 @@
+/*
+ * 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.quarkus.component.mcp.server.it;
+
+import java.time.Duration;
+import java.util.Map;
+
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import io.quarkus.test.keycloak.server.KeycloakContainer;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.utility.MountableFile;
+
+/** Starts a real Keycloak container for MCP/OIDC integration tests. */
+public class McpServerKeycloakTestResource implements 
QuarkusTestResourceLifecycleManager {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(McpServerKeycloakTestResource.class);
+    private static final String REALM_NAME = "mcp";
+
+    private KeycloakContainer keycloak;
+
+    @Override
+    public Map<String, String> start() {
+        System.setProperty("keycloak.docker.image",
+                
ConfigProvider.getConfig().getValue("keycloak.container.image", String.class));
+
+        keycloak = new KeycloakContainer()
+                .withStartupTimeout(Duration.ofMinutes(5))
+                .withLogConsumer(new Slf4jLogConsumer(LOG))
+                .withCopyFileToContainer(
+                        MountableFile.forClasspathResource("/mcp-realm.json"),
+                        "/opt/keycloak/data/import/mcp-realm.json")
+                .withCommand("start", "--import-realm", "--verbose");
+        keycloak.start();
+
+        String issuer = keycloak.getServerUrl() + "/realms/" + REALM_NAME;
+        return Map.ofEntries(
+                Map.entry("quarkus.oidc.auth-server-url", issuer),
+                Map.entry("quarkus.oidc.client-id", "mcp-test-client"),
+                Map.entry("quarkus.oidc.credentials.secret", 
"mcp-test-secret"),
+                Map.entry("quarkus.oidc.application-type", "service"),
+                Map.entry("quarkus.oidc.token.principal-claim", 
"preferred_username"),
+                Map.entry("quarkus.oidc.roles.role-claim-path", 
"realm_access/roles"),
+                Map.entry("quarkus.oidc.tenant-paths", "/mcp,/mcp/*"),
+                Map.entry("quarkus.oidc.resource-metadata.enabled", "true"),
+                Map.entry("quarkus.oidc.resource-metadata.force-https-scheme", 
"false"),
+                Map.entry("quarkus.http.host", "localhost"),

Review Comment:
   Addressed the documentation part. Updated the MCP Server usage guide to 
clarify that the built-in Origin/DNS-rebinding check from quarkus-mcp-server is 
applied only when the HTTP host is a loopback address. It is not a configurable 
allowed-Origin policy and should not be relied upon when binding to a 
non-loopback address such as `0.0.0.0`.
   
   The existing test verifies this loopback-only DNS-rebinding protection, not 
a general Origin allow-list.
   
   A follow-up issue for configurable Origin allow-list support is still 
needed; I have not opened it yet.



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