ramu11 commented on code in PR #9509:
URL: https://github.com/apache/camel-quarkus/pull/9509#discussion_r4588151147
##########
extensions/mcp-server/runtime/src/main/java/org/apache/camel/quarkus/component/mcp/server/QuarkusMcpServerEngine.java:
##########
@@ -86,6 +124,39 @@ public void initialize(McpServerInfo info) {
LOG.debug("quarkus-mcp-server engine initialized; serving
configuration is owned by quarkus.mcp.server.*");
}
+ /**
+ * Converts the current Quarkus request identity to the transport-neutral
Camel MCP context.
+ *
+ * The CurrentIdentityAssociation is request scoped. It is deliberately
read inside the
+ * tool callback so concurrent MCP requests cannot share or overwrite each
other's identity.
+ */
+ private McpToolCallContext currentToolCallContext() {
+ SecurityIdentity identity = currentIdentityAssociation.getIdentity();
+ if (identity == null || identity.isAnonymous()) {
+ return McpToolCallContext.EMPTY;
+ }
+
+ Principal principal = identity.getPrincipal();
+ String principalName = principal != null ? principal.getName() : null;
+ if (principalName != null && principalName.isBlank()) {
+ principalName = null;
+ }
+
+ List<String> roles = identity.getRoles().stream()
+ .filter(role -> role != null && !role.isBlank())
+ .sorted()
+ .toList();
+
+ if (principal == null && principalName == null && roles.isEmpty()) {
+ return McpToolCallContext.EMPTY;
+ }
+
+ return new McpToolCallContext(
Review Comment:
Addressed. Implemented OAuth identity extraction in `QuarkusMcpServerEngine`
for principals implementing MicroProfile `JsonWebToken`. The bridge now
propagates the JWT subject, claims and scopes (splitting the `scope` claim on
whitespace) through `McpToolCallContext`.
The MP JWT API is accessed reflectively, so it remains optional when
applications do not use JWT authentication. Principal and role propagation
continue to work if JWT extraction is unavailable.
Updated the Caller identity documentation to describe the three OAuth
exchange properties. The full `CamelOAuthTokenValidationResult` is not
synthesized by this Quarkus implementation.
The Keycloak OAuth test contains assertions for this propagation, but
remains disabled pending the Quarkus 4 compatibility fix tracked in #9362.
--
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]