Skip to content

Commit 8d6c0c3

Browse files
update mcp-gateway authn/authz guides
1 parent c384fd7 commit 8d6c0c3

2 files changed

Lines changed: 22 additions & 18 deletions

File tree

modules/proc-configure-mcp-gateway-authentication.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The {mcpg} supports any Istio or Gateway API compatible authentication mechanism
1818

1919
* You installed {mcpg}.
2020
* You installed {prodname}.
21-
* You configured a `Gateway` object.
21+
* You configured a `Gateway` object with an `mcp` listener.
2222
* You installed and have ready an identity provider supporting OAuth 2.0 or 2.1, for example, {keycloak}.
2323
2424
.Procedure
@@ -105,7 +105,7 @@ spec:
105105
code: 401
106106
headers:
107107
'WWW-Authenticate':
108-
value: Bearer resource_metadata=http://mcp.example.com:8001/.well-known/oauth-protected-resource/mcp
108+
value: Bearer resource_metadata=http://mcp.example.com:8001/.well-known/oauth-protected-resource
109109
body:
110110
value: |
111111
{
@@ -127,18 +127,18 @@ spec:
127127
+
128128
[source,terminal,subs="+quotes"]
129129
----
130-
$ oc apply -f _<mcp_jwt_authpolicy.yaml>_
130+
$ oc apply -f _<mcp_jwt_auth_policy.yaml>_
131131
----
132132
+
133-
Replace `_<mcp_jwt_authpolicy.yaml>_` with the name of your CR.
133+
Replace `_<mcp_jwt_auth_policy.yaml>_` with the name of your CR.
134134

135135
.Verification
136136

137137
. Test that the broker now serves OAuth discovery information by checking the protected resource metadata endpoint with the following command:
138138
+
139139
[source,terminal,subs="+quotes"]
140140
----
141-
$ curl http://_<mcp.example.com:8001/.well_known/oauth_protected_resource>_
141+
$ curl http://_<mcp.example.com:8001>_/.well-known/oauth-protected-resource
142142
----
143143
+
144144
* Replace the URL with your protected resource information.

modules/proc-mcp-gateway-authorization.adoc

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// Module included in the following assemblies:
32
//
43
// *mcp_gateway_config/mcp-gateway-authorization.adoc
@@ -14,9 +13,10 @@ The following example demonstrates using a Kuadrant `AuthPolicy` custom resource
1413

1514
* You installed {mcpg}.
1615
* You installed {prodname}.
17-
* You configured a `Gateway` object.
18-
* You completed authentication procedures.
16+
* You configured a `Gateway` object with an `mcp` listener and an `mcps` listener. The `mcps` listener is required for internal `tools/call` routing and authorization.
17+
* You completed authentication procedures, including creating an `AuthPolicy` CR on the `mcp` listener.
1918
* You configured your identity provider to include `group` and `role` claims in JSON Web Tokens (JWT).
19+
* The identity provider client IDs match the namespaced `MCPServerRegistration` name in the format `_<namespace>_/_<mcpserverregistration_name>_`.
2020
2121
.Procedure
2222

@@ -37,10 +37,15 @@ The following example demonstrates using a Kuadrant `AuthPolicy` custom resource
3737
}
3838
----
3939
+
40-
* The `"mcp-ns/arithmetic-mcp-server"` specification must match the namespaced name of the `MCPServerRegistration` CR.
40+
* The `"mcp-ns/arithmetic-mcp-server"` specification must match the namespaced name of the `MCPServerRegistration` CR in the format `{namespace}/{name}`. For example, if your `MCPServerRegistration` CR is named `arithmetic-mcp-server` and is applied in the `mcp-ns` namespace, the {keycloak} client ID must be `mcp-ns/arithmetic-mcp-server`.
4141
* The `"roles": ["add", "sum", "multiply", "divide"]` parameter and values specify the roles representing the allowed tools.
4242
43-
. Configure tool-level authorization by creating an `AuthPolicy` CR that enforces tool-level access control, as shown in the following example:
43+
. Configure tool-level authorization by creating an `AuthPolicy` CR that enforces tool-level access control on the `mcps` listener, as shown in the following example:
44+
+
45+
[IMPORTANT]
46+
====
47+
The authorization `AuthPolicy` CR must target the `mcps` listener, not the `mcp` listener. The `mcp` listener only handles public traffic and has an authentication-only `AuthPolicy` CR.
48+
====
4449
+
4550
.Example tool-level access control AuthPolicy
4651
[source,yaml,subs="+quotes"]
@@ -60,7 +65,7 @@ spec:
6065
authentication:
6166
'sso-server':
6267
jwt:
63-
issuerUrl: http://keycloak.example.com:8002/realms/mcp
68+
issuerUrl: https://_<keycloak.example.com>_/realms/mcp
6469
authorization:
6570
'tool-access-check':
6671
patternMatching:
@@ -71,7 +76,7 @@ spec:
7176
unauthenticated:
7277
headers:
7378
'WWW-Authenticate':
74-
value: Bearer resource_metadata=http://mcp.example.com:8001/.well-known/oauth-protected-resource/mcp
79+
value: Bearer resource_metadata=http://_<mcp.example.com:8001>_/.well-known/oauth-protected-resource
7580
body:
7681
value: |
7782
{
@@ -90,8 +95,8 @@ spec:
9095
* Replace `metadata.name:` with the name of the `AuthPolicy`.
9196
* Replace `metadata.namespace:` with the namespace where the `AuthPolicy` CR is applied.
9297
* Replace `spec.targetRef.name:` with the name of the `Gateway` CR.
93-
* The `spec.targetRef.sectionName:` value targets the MCP server listener.
94-
* Authentication: Validates the JWT token using the configured issuer URL
98+
* The `spec.targetRef.sectionName:` value must be `mcps`, which is the internal listener for `tool/call` authorization. This listener must exist on your `Gateway` object.
99+
* Authentication: Validates the JWT token using the configured issuer URL. Replace `_<keycloak.example.com>_` with your identity provider hostname.
95100
* Authorization Logic: CEL expression checks if user's roles allow access to the requested tool
96101
* CEL Breakdown:
97102
** `request.headers['x-mcp-toolname']`: The name of the requested MCP tool, stripped from prefix.
@@ -111,16 +116,15 @@ $ oc apply -f _<mcp_tool_auth_policy.yaml>_
111116

112117
. Monitor authorization decisions by checking the `AuthPolicy` CR `status` with the following command:
113118
+
114-
[source,terminal]
119+
[source,terminal,subs="+quotes"]
115120
----
116-
$ oc get authpolicy -A
121+
$ oc get authpolicy _<mcp_tool_auth_policy>_ -n _<gateway_system>_ -o jsonpath='{.status.conditions[?(@.type=="Enforced")].status}'
117122
----
118123
+
119124
.Example output
120125
[source,text]
121126
----
122-
NAMESPACE NAME STATUS
123-
gateway-system mcp-tool-auth-policy Enforced
127+
True
124128
----
125129

126130
. Check the authorization logs by running the following command:

0 commit comments

Comments
 (0)