Commit b9440d7
[FIX][RBAC]: Session tokens denied tools.execute on /rpc and /mcp despite having team-scoped role (#3516)
* test(rbac): add failing tests for session-token check_any_team in _ensure_rpc_permission
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
* test(rbac): harden assertions in rpc permission team fallback tests
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
* feat(rbac): add check_any_team param to PermissionChecker.has_permission
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
* fix(rbac): pass check_any_team=True in _ensure_rpc_permission for session tokens
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
* test(rbac): add contract tests for check_any_team threading in _check_streamable_permission
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
* fix(rbac): propagate token_use in streamablehttp auth_user_ctx and pass check_any_team for session tokens
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
* test(rbac): add deny-path regression tests for rpc team-permission fallback
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
* test(rbac): accept **kwargs in _has_permission mocks to forward check_any_team
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
* fix(rbac): remove dead null-guard in call_tool and strengthen admin+deny-path tests
- streamablehttp_transport.py: drop redundant ternary guard; user_context is
guaranteed non-None at that point by _should_enforce_streamable_rbac check
- test_rpc_permission_team_fallback.py: replace vacuous admin-bypass smoke test with
a meaningful assertion that has_permission is called with check_any_team=True for
admin session tokens (bypass lives inside PermissionService, not _ensure_rpc_permission)
- test_streamable_rpc_permission_fallback.py: add deny-path integration test verifying
call_tool raises PermissionError when _check_streamable_permission returns False
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
* test(rbac): add #3515 regression Playwright tests for session-token tool execution
Three tests in TestRPCToolExecutionRBAC:
- test_developer_rpc_tools_call_not_denied: developer with team-scoped role
sends tools/call via /rpc as a session token and must NOT receive -32003
- test_viewer_rpc_tools_call_denied: viewer (no tools.execute) must still
receive -32003 (deny-path regression guard)
- test_developer_can_list_team_tool: developer can see their team-scoped tool
in GET /tools (Layer 1 visibility check)
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
* test(rbac): verify check_any_team forwarding in PermissionChecker.has_permission
Add two tests covering the db_session and fresh_db_session paths of
PermissionChecker.has_permission to assert check_any_team=True is
forwarded to PermissionService.check_permission.
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
* fix(rbac): pass check_any_team for servers.use and propagate token_use in _normalize_jwt_payload
Address Codex review findings:
- servers.use check in handle_streamable_http now detects session tokens
and passes check_any_team=True, matching the call_tool fix.
- _normalize_jwt_payload includes token_use in the returned context dict
so the re-auth fallback path preserves session-token detection.
- Update existing _normalize_jwt_payload test assertions for the new key.
- Add servers.use session-token regression test.
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
* test(rbac): add browser cookie session-token Playwright tests for #3515
Four new E2E tests in TestSessionTokenCookieRBAC:
- test_developer_cookie_rpc_tools_call: session cookie + page.evaluate
fetch to /rpc — matches the actual Admin UI Tools screen flow
- test_viewer_cookie_rpc_tools_call_denied: viewer deny-path via cookie
- test_developer_cookie_rpc_tools_list: tools.read permission via /rpc
tools/list (verifies check_any_team applies to all RPC permissions)
- test_cross_team_tool_not_visible: Layer 1 isolation — developer in
Team A cannot see Team B's tool even with check_any_team=True
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
---------
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>1 parent f271ac5 commit b9440d7
File tree
9 files changed
+824
-10
lines changed- mcpgateway
- middleware
- transports
- tests
- playwright
- unit/mcpgateway
- middleware
- transports
9 files changed
+824
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
576 | 576 | | |
577 | 577 | | |
578 | 578 | | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
579 | 582 | | |
580 | | - | |
| 583 | + | |
581 | 584 | | |
582 | 585 | | |
583 | 586 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
954 | 954 | | |
955 | 955 | | |
956 | 956 | | |
957 | | - | |
| 957 | + | |
958 | 958 | | |
959 | 959 | | |
960 | 960 | | |
961 | 961 | | |
962 | 962 | | |
963 | 963 | | |
964 | 964 | | |
| 965 | + | |
965 | 966 | | |
966 | 967 | | |
967 | 968 | | |
| |||
978 | 979 | | |
979 | 980 | | |
980 | 981 | | |
| 982 | + | |
981 | 983 | | |
982 | 984 | | |
983 | 985 | | |
| |||
991 | 993 | | |
992 | 994 | | |
993 | 995 | | |
| 996 | + | |
994 | 997 | | |
995 | 998 | | |
996 | 999 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
987 | 987 | | |
988 | 988 | | |
989 | 989 | | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
990 | 993 | | |
991 | 994 | | |
992 | 995 | | |
| 996 | + | |
993 | 997 | | |
994 | 998 | | |
995 | 999 | | |
| |||
1360 | 1364 | | |
1361 | 1365 | | |
1362 | 1366 | | |
1363 | | - | |
| 1367 | + | |
1364 | 1368 | | |
1365 | 1369 | | |
1366 | 1370 | | |
| |||
1369 | 1373 | | |
1370 | 1374 | | |
1371 | 1375 | | |
1372 | | - | |
| 1376 | + | |
1373 | 1377 | | |
1374 | 1378 | | |
1375 | 1379 | | |
| |||
1401 | 1405 | | |
1402 | 1406 | | |
1403 | 1407 | | |
| 1408 | + | |
1404 | 1409 | | |
1405 | 1410 | | |
1406 | 1411 | | |
| |||
2346 | 2351 | | |
2347 | 2352 | | |
2348 | 2353 | | |
| 2354 | + | |
2349 | 2355 | | |
2350 | 2356 | | |
2351 | 2357 | | |
| 2358 | + | |
2352 | 2359 | | |
2353 | 2360 | | |
2354 | 2361 | | |
| |||
3014 | 3021 | | |
3015 | 3022 | | |
3016 | 3023 | | |
| 3024 | + | |
3017 | 3025 | | |
3018 | 3026 | | |
3019 | 3027 | | |
| |||
0 commit comments