Repository navigation
fix(rbac): backfill admin.overview and servers.use permissions to viewer roles - #3390
Conversation
27ede39 to
7e3dd7c
Compare
|
Minor: the revision ID |
|
@madhav165 : Regenerated the alembic id based on review comments |
97bc03f to
be8d9ed
Compare
crivetimihai
left a comment
There was a problem hiding this comment.
Review: APPROVED
Rebased onto main (clean, no conflicts), squashed 5 commits into a single conventional commit preserving original author.
Changes Reviewed
Migration (abf8ac3b6008)
- Migration chain verified:
down_revision = "d9e0f1a2b3c4"is correct (single head confirmed viaalembic heads) - Logic is correct: idempotent add/remove, PostgreSQL JSONB CAST + SQLite plain JSON branching
- Consistent with established codebase patterns (
9f5d93ced2b3,b2d9c6e4f1a7,a31c6ffc2239) print()is the correct convention (412 uses across 44 migration files; only 1 outlier useslogging)- Symmetric downgrade properly reverses the upgrade
Bootstrap (bootstrap_db.py)
- Additions match the migration backfill exactly
- Subset hierarchy preserved: viewer < developer < team_admin
Security
admin.overviewis enforced atadmin.py:1557withallow_admin_bypass=False— all roles need it explicitlytools.executeis enforced on tool invocation endpoints (main.py,streamablehttp_transport.py)- No write/create/update/delete permissions granted to viewer roles — only read + execute access
tools.executefor viewers is appropriate: MCP protocol requires tool invocation for basic functionality
Fixes Applied During Review
- Removed emoji from print statement (consistency with reference migrations)
- Added
# pylint: disable=no-member(matchesd9e0f1a2b3c4pattern) - Updated
test_rbac_permission_matrix.py— synced permission constants with new bootstrap definitions (280 tests pass) - Added
test_rbac_permission_backfill_migration.py— 33 tests covering module structure,_load_permissionsedge cases, upgrade/downgrade logic, idempotency, edge cases
Test Results
- 33/33 migration tests pass
- 280/280 permission matrix tests pass
be8d9ed to
9493e84
Compare
|
start working on issue #3415 to include servers.user permission for team_admin and developer, viewer and plat_viewer role in alembic script. |
22824e8 to
3448628
Compare
|
e3e6036 to
bc95080
Compare
|
Thanks, please leave this with me now, I've started the code review. |
5f9a64c to
eefe7cc
Compare
crivetimihai
left a comment
There was a problem hiding this comment.
Review: Approved with fixes applied
Reviewed the full diff, rebased onto latest main (b4d8770), and applied the following fixes:
Issues found and fixed
-
Downgrade regression (high): The migration included
servers.useinROLE_PERMISSION_ADDITIONSfordeveloperandteam_admin, but those roles already haveservers.usein their baseline definitions. This meantdowngrade()would strip a pre-existing permission, breaking transport access. Fixed by removingservers.usefrom developer/team_admin entries — upgrade is still idempotent (skips if present), but downgrade no longer destroys pre-existing state. -
Bootstrap/migration inconsistency:
servers.usewas being backfilled by the migration forviewerandplatform_viewerbut was missing frombootstrap_db.py. New deployments would lack it while migrated deployments would have it. Fixed by addingservers.useto both roles in bootstrap. -
E2E test alignment: The new RBAC transport e2e tests (merged in #3424) expected non-admin users to be denied
tools.executeon the default/mcpendpoint. However, all non-admin users auto-receiveplatform_viewer(global scope), which now includestools.execute. Fixed by updating 4 e2e tests to expect success instead of denial, matching the intent of #3329. -
Test coverage gaps: Migration test fixtures used unrealistic baselines (developer/team_admin missing
servers.use), masking the downgrade regression. Fixed with realistic fixtures and a new round-trip restoration test. -
Documentation drift: Updated RBAC docs (role tables, permission categories, available permissions, info boxes) and role descriptions to reflect the new viewer/platform_viewer capabilities.
-
Unrelated changes: Reverted
uv.lockdependency bumps (cookiecutter, fastapi, filelock) that were unrelated to the RBAC fix.
Verification
- 323 unit tests passing
- Migration/bootstrap/test constants/docs all cross-checked for consistency
- Downgrade safety verified: no pre-existing permissions in removal lists
Closes #3329
crivetimihai
left a comment
There was a problem hiding this comment.
Review: Approved with fixes applied
Reviewed the full diff, rebased onto latest main, and applied the following fixes:
Issues found and fixed
-
Downgrade regression (high): The migration included
servers.useinROLE_PERMISSION_ADDITIONSfordeveloperandteam_admin, but those roles already haveservers.usein their baseline definitions. This meantdowngrade()would strip a pre-existing permission, breaking transport access. Fixed by removingservers.usefrom developer/team_admin entries — upgrade is still idempotent (skips if present), but downgrade no longer destroys pre-existing state. -
Bootstrap/migration inconsistency:
servers.usewas being backfilled by the migration forviewerandplatform_viewerbut was missing frombootstrap_db.py. New deployments would lack it while migrated deployments would have it. Fixed by addingservers.useto both roles in bootstrap. -
E2E test alignment: The new RBAC transport e2e tests (merged in #3424) expected non-admin users to be denied
tools.executeon the default/mcpendpoint. However, all non-admin users auto-receiveplatform_viewer(global scope), which now includestools.execute. Fixed by updating 4 e2e tests to expect success instead of denial, matching the intent of #3329. -
Test coverage gaps: Migration test fixtures used unrealistic baselines (developer/team_admin missing
servers.use), masking the downgrade regression. Fixed with realistic fixtures and a new round-trip restoration test. -
Documentation drift: Updated RBAC docs (role tables, permission categories, available permissions, info boxes) and role descriptions to reflect the new viewer/platform_viewer capabilities.
-
Unrelated changes: Reverted
uv.lockdependency bumps (cookiecutter, fastapi, filelock) that were unrelated to the RBAC fix.
Verification
- 323 unit tests passing
- Migration/bootstrap/test constants/docs all cross-checked for consistency
- Downgrade safety verified: no pre-existing permissions in removal lists
Closes #3329
Follow-up: Viewer role permissions model — read-only vs read+executeThis PR fixes #3329 correctly, but raises a broader design question worth tracking. The concern
Why this mattersTool execution is a mutation operation — it runs side effects on external systems (MCP servers). Granting this to all users by default may not be appropriate for all deployments, particularly those with compliance or least-privilege requirements. Options to consider
Decision needed
If the current model is intentional, no action needed. If this warrants further discussion, consider opening a follow-up issue. |
687eab1 to
f11e740
Compare
Review: Consistency fixes for
|
| File | Issue | Fix |
|---|---|---|
| Migration docstring | "admin.overview,, double commas, extra spaces from hasty find/delete |
Cleaned up formatting |
| bootstrap_db.py | viewer/platform_viewer description said "Read and test access" — misleading without tools.execute |
Reverted to "Read-only access" |
| docs/rbac.md | Permission tables still listed tools.execute for viewer/platform_viewer; descriptions said "read and test" |
Removed tools.execute, restored "read-only" |
| test_rbac_permission_matrix.py | VIEWER_PERMISSIONS and PLATFORM_VIEWER_PERMISSIONS included tools.execute |
Removed |
| test_rbac_permission_backfill_migration.py | Hardcoded ["admin.overview", "tools.execute"] in individual tests instead of using the actual ROLE_PERMISSION_ADDITIONS values; module docstring stale |
Replaced with ROLE_PERMISSION_ADDITIONS["viewer"] references throughout |
| test_mcp_rbac_transport.py (e2e) | Tests changed from deny→success with docstrings claiming "platform_viewer grants global tools.execute" — but platform_viewer no longer has it | Restored original deny assertions from main |
Tests added
test_upgrade_via_entry_point— callsupgrade()with mockedalembic.op.get_bindagainst a populated DB, verifies all permissions applied and pre-existing permissions preservedtest_downgrade_via_entry_point— full round-trip via public entry points, verifies exact restoration of original state
Verification
- 43/43 migration backfill tests pass
- 282/282 permission matrix tests pass
- Single alembic head confirmed (
abf8ac3b6008)
Open design question
Per the earlier discussion: viewer roles are now read-only + admin.overview + servers.use (transport access), but do NOT have tools.execute. This means the original issue #3329 ("Test on tools fails") is only partially addressed — the Overview page now loads, but tool testing for non-admin users still requires a follow-up (either adding tools.execute to viewer roles, or implementing team-scoped tool execution in the admin UI).
2c2d4fd to
e677db3
Compare
…iewer roles Add Alembic migration to backfill missing permissions into existing role records and update bootstrap_db.py so new deployments receive the correct permissions from first boot. Roles updated: - viewer: admin.overview, tools.execute - platform_viewer: admin.overview, tools.execute - developer: admin.overview - team_admin: admin.overview The migration is idempotent, supports both PostgreSQL (JSONB) and SQLite, and includes a symmetric downgrade. Closes #3329 Signed-off-by: Rakhi Dutta <[email protected]> Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Rakhi Dutta <[email protected]>
Signed-off-by: Rakhi Dutta <[email protected]>
…st coverage Add servers.use permission to viewer and platform_viewer role definitions in bootstrap_db.py to match what the Alembic migration backfills. Without this, new deployments would lack servers.use for viewer roles while migrated deployments would have it, causing inconsistent tool-testing behavior. Also adds migration tests covering servers.use addition/removal for all roles and reverts unrelated uv.lock dependency bumps. Signed-off-by: Mihai Criveti <[email protected]>
… roles Update viewer and platform_viewer role descriptions from "Read-only" to "Read and test" to reflect the addition of tools.execute and servers.use permissions. Update RBAC documentation to include admin.overview, tools.execute, and servers.use in the built-in roles table, permission categories, and available permissions reference. Signed-off-by: Mihai Criveti <[email protected]>
The module docstring and upgrade/downgrade docstrings only mentioned admin.overview and tools.execute, but ROLE_PERMISSION_ADDITIONS also includes servers.use for all four roles. Align documentation with code. Signed-off-by: Mihai Criveti <[email protected]>
Fix migration downgrade regression: remove servers.use from developer and team_admin entries in ROLE_PERMISSION_ADDITIONS since those roles already have it in their baseline definitions. Without this, a downgrade would strip a pre-existing permission, breaking transport access. Update migration test fixtures with realistic baselines (developer and team_admin include servers.use) and add a round-trip test that verifies upgrade->downgrade restores exact original permissions for all roles. Update e2e RBAC tests: since all non-admin users auto-receive platform_viewer (global) which now includes tools.execute, the tests that expected denial on the default /mcp endpoint now correctly expect success. This aligns with the intent of issue #3329. Fix remaining stale "read-only" text in rbac.md migration info box for platform_viewer. Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Rakhi Dutta <[email protected]>
…ency The previous commit removed tools.execute from the migration and bootstrap_db.py but left it in docs, test constants, and e2e tests. This commit completes the cleanup: - Fix migration docstring formatting artifacts (double commas, extra spaces) - Revert viewer/platform_viewer description to "Read-only access" - Remove tools.execute from rbac.md viewer/platform_viewer permission tables - Remove tools.execute from test_rbac_permission_matrix.py constants - Replace hardcoded stale permission lists in migration backfill tests with ROLE_PERMISSION_ADDITIONS references - Restore original e2e deny assertions for tool execution (non-admin users lack global tools.execute) - Add integration tests for upgrade()/downgrade() via public entry points Signed-off-by: Mihai Criveti <[email protected]>
…tools.execute Signed-off-by: Madhav Kandukuri <[email protected]>
Signed-off-by: Rakhi Dutta <[email protected]>
Signed-off-by: Rakhi Dutta <[email protected]>
Signed-off-by: Rakhi Dutta <[email protected]>
Point migration abf8ac3b6008 down_revision from e1f2a3b4c5d6 to 64acf94cb7f2 (the actual current Alembic head on main) to eliminate the multiple-heads condition that would break alembic upgrade. Update the corresponding test constant to match. Signed-off-by: Mihai Criveti <[email protected]>
7423a3f to
78a8212
Compare
crivetimihai
left a comment
There was a problem hiding this comment.
Review: fix(rbac): backfill admin.overview and servers.use permissions to viewer roles
Rebased & Fixed
- Rebased onto current
main(3c5375e), resolved 3 merge conflicts (uv.lock x2, e2e tests). - Fixed critical issue: migration
down_revisionpointed toe1f2a3b4c5d6which created multiple Alembic heads. Updated to64acf94cb7f2(actual current head on main). Without this fix,alembic upgrade headwould fail on any deployment.
Code Review
Migration (abf8ac3b6008) — Correct and well-structured:
- Idempotent: skips if permissions already present, skips if roles table missing
- Handles both SQLite (plain JSON) and PostgreSQL (CAST AS JSONB)
- Symmetric downgrade removes only what was added
- Downgrade is safe for developer/team_admin: their pre-existing
servers.useis preserved because it's not in theirROLE_PERMISSION_ADDITIONSentry
Bootstrap ↔ Migration consistency — Verified exact match:
| Role | Migration adds | Bootstrap now includes |
|---|---|---|
| viewer | admin.overview, servers.use |
✅ both present |
| platform_viewer | admin.overview, servers.use |
✅ both present |
| developer | admin.overview |
✅ present (already had servers.use) |
| team_admin | admin.overview |
✅ present (already had servers.use) |
New and migrated deployments will have identical permission sets.
Security — No privilege escalation:
admin.overviewis read-only (dashboard visibility via token scoping middleware)servers.useenables MCP transport access (SSE/WS/Streamable HTTP) but does not granttools.execute- Viewers still cannot execute tools — e2e tests still verify denial on the default global endpoint
Test coverage — 98% on migration file (43 tests), 282 permission matrix tests pass. Only uncovered line is the PostgreSQL CAST branch (expected with SQLite test DB).
Minor notes (non-blocking):
- E2e test assertions are slightly weaker after removing
_assert_access_denied_tool_callhelper (inline checks don't verify "access denied" message text for all roles). Acceptable for e2e where error format varies. test_main.pypatches fora2a_service=Noneare unrelated but fix pre-existing test failures. Harmless.
All 325 unit tests pass. Single Alembic head confirmed.
Restore _assert_access_denied_tool_call() in the e2e test — the replacement inline assertions were broken (checked result.isError but the actual response uses the error key with JSON-RPC code -32003) and weaker (did not verify "access denied" message or error code). Add a migration test documenting the known downgrade limitation: if a role already had a backfilled permission before the migration ran, downgrade() will remove it. This is an accepted trade-off for a simple data migration targeting system-bootstrapped roles. Signed-off-by: Mihai Criveti <[email protected]>
There was a problem hiding this comment.
Updated review after addressing feedback:
- Restored
_assert_access_denied_tool_call()helper in e2e tests — the inline replacements were broken (checkedresult.isErrorbut actual response useserrorkey with JSON-RPC code -32003). E2e file now has zero diff vs main. - Added
test_downgrade_strips_pre_existing_permissionsdocumenting the known limitation: downgrade is not provenance-aware and will remove listed permissions even if they pre-existed. Accepted trade-off for a migration targeting system-bootstrapped roles with known baselines. - admin.overview for team-scoped roles: real gap (template omits
team_id), but pre-existing in main — not introduced by this PR.platform_viewer(global) benefits immediately.
All 332 unit tests pass. Single Alembic head confirmed.
…wer roles (#3390) * fix(rbac): backfill admin.overview and tools.execute permissions to viewer roles Add Alembic migration to backfill missing permissions into existing role records and update bootstrap_db.py so new deployments receive the correct permissions from first boot. Roles updated: - viewer: admin.overview, tools.execute - platform_viewer: admin.overview, tools.execute - developer: admin.overview - team_admin: admin.overview The migration is idempotent, supports both PostgreSQL (JSONB) and SQLite, and includes a symmetric downgrade. Closes #3329 Signed-off-by: Rakhi Dutta <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> * lint Signed-off-by: Mihai Criveti <[email protected]> * alembic Signed-off-by: Rakhi Dutta <[email protected]> * test case fix Signed-off-by: Rakhi Dutta <[email protected]> * fix(rbac): add missing servers.use to viewer bootstrap and improve test coverage Add servers.use permission to viewer and platform_viewer role definitions in bootstrap_db.py to match what the Alembic migration backfills. Without this, new deployments would lack servers.use for viewer roles while migrated deployments would have it, causing inconsistent tool-testing behavior. Also adds migration tests covering servers.use addition/removal for all roles and reverts unrelated uv.lock dependency bumps. Signed-off-by: Mihai Criveti <[email protected]> * docs(rbac): update role descriptions and permission tables for viewer roles Update viewer and platform_viewer role descriptions from "Read-only" to "Read and test" to reflect the addition of tools.execute and servers.use permissions. Update RBAC documentation to include admin.overview, tools.execute, and servers.use in the built-in roles table, permission categories, and available permissions reference. Signed-off-by: Mihai Criveti <[email protected]> * fix(rbac): correct migration docstrings to include servers.use The module docstring and upgrade/downgrade docstrings only mentioned admin.overview and tools.execute, but ROLE_PERMISSION_ADDITIONS also includes servers.use for all four roles. Align documentation with code. Signed-off-by: Mihai Criveti <[email protected]> * fix(rbac): safe downgrade, realistic test fixtures, e2e test alignment Fix migration downgrade regression: remove servers.use from developer and team_admin entries in ROLE_PERMISSION_ADDITIONS since those roles already have it in their baseline definitions. Without this, a downgrade would strip a pre-existing permission, breaking transport access. Update migration test fixtures with realistic baselines (developer and team_admin include servers.use) and add a round-trip test that verifies upgrade->downgrade restores exact original permissions for all roles. Update e2e RBAC tests: since all non-admin users auto-receive platform_viewer (global) which now includes tools.execute, the tests that expected denial on the default /mcp endpoint now correctly expect success. This aligns with the intent of issue #3329. Fix remaining stale "read-only" text in rbac.md migration info box for platform_viewer. Signed-off-by: Mihai Criveti <[email protected]> * remove tools.execute Signed-off-by: Rakhi Dutta <[email protected]> * fix(rbac): remove stale tools.execute references and fix test consistency The previous commit removed tools.execute from the migration and bootstrap_db.py but left it in docs, test constants, and e2e tests. This commit completes the cleanup: - Fix migration docstring formatting artifacts (double commas, extra spaces) - Revert viewer/platform_viewer description to "Read-only access" - Remove tools.execute from rbac.md viewer/platform_viewer permission tables - Remove tools.execute from test_rbac_permission_matrix.py constants - Replace hardcoded stale permission lists in migration backfill tests with ROLE_PERMISSION_ADDITIONS references - Restore original e2e deny assertions for tool execution (non-admin users lack global tools.execute) - Add integration tests for upgrade()/downgrade() via public entry points Signed-off-by: Mihai Criveti <[email protected]> * fix: rename alembic migration file to reflect servers.use instead of tools.execute Signed-off-by: Madhav Kandukuri <[email protected]> * down_revision Signed-off-by: Rakhi Dutta <[email protected]> * down revision in test Signed-off-by: Rakhi Dutta <[email protected]> * test case fix Signed-off-by: Rakhi Dutta <[email protected]> * fix(rbac): update migration down_revision to current head Point migration abf8ac3b6008 down_revision from e1f2a3b4c5d6 to 64acf94cb7f2 (the actual current Alembic head on main) to eliminate the multiple-heads condition that would break alembic upgrade. Update the corresponding test constant to match. Signed-off-by: Mihai Criveti <[email protected]> * fix(rbac): restore e2e denial helper and add downgrade edge-case test Restore _assert_access_denied_tool_call() in the e2e test — the replacement inline assertions were broken (checked result.isError but the actual response uses the error key with JSON-RPC code -32003) and weaker (did not verify "access denied" message or error code). Add a migration test documenting the known downgrade limitation: if a role already had a backfilled permission before the migration ran, downgrade() will remove it. This is an accepted trade-off for a simple data migration targeting system-bootstrapped roles. Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Rakhi Dutta <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> Signed-off-by: Madhav Kandukuri <[email protected]> Co-authored-by: Mihai Criveti <[email protected]> Co-authored-by: Madhav Kandukuri <[email protected]>
…wer roles (IBM#3390) * fix(rbac): backfill admin.overview and tools.execute permissions to viewer roles Add Alembic migration to backfill missing permissions into existing role records and update bootstrap_db.py so new deployments receive the correct permissions from first boot. Roles updated: - viewer: admin.overview, tools.execute - platform_viewer: admin.overview, tools.execute - developer: admin.overview - team_admin: admin.overview The migration is idempotent, supports both PostgreSQL (JSONB) and SQLite, and includes a symmetric downgrade. Closes IBM#3329 Signed-off-by: Rakhi Dutta <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> * lint Signed-off-by: Mihai Criveti <[email protected]> * alembic Signed-off-by: Rakhi Dutta <[email protected]> * test case fix Signed-off-by: Rakhi Dutta <[email protected]> * fix(rbac): add missing servers.use to viewer bootstrap and improve test coverage Add servers.use permission to viewer and platform_viewer role definitions in bootstrap_db.py to match what the Alembic migration backfills. Without this, new deployments would lack servers.use for viewer roles while migrated deployments would have it, causing inconsistent tool-testing behavior. Also adds migration tests covering servers.use addition/removal for all roles and reverts unrelated uv.lock dependency bumps. Signed-off-by: Mihai Criveti <[email protected]> * docs(rbac): update role descriptions and permission tables for viewer roles Update viewer and platform_viewer role descriptions from "Read-only" to "Read and test" to reflect the addition of tools.execute and servers.use permissions. Update RBAC documentation to include admin.overview, tools.execute, and servers.use in the built-in roles table, permission categories, and available permissions reference. Signed-off-by: Mihai Criveti <[email protected]> * fix(rbac): correct migration docstrings to include servers.use The module docstring and upgrade/downgrade docstrings only mentioned admin.overview and tools.execute, but ROLE_PERMISSION_ADDITIONS also includes servers.use for all four roles. Align documentation with code. Signed-off-by: Mihai Criveti <[email protected]> * fix(rbac): safe downgrade, realistic test fixtures, e2e test alignment Fix migration downgrade regression: remove servers.use from developer and team_admin entries in ROLE_PERMISSION_ADDITIONS since those roles already have it in their baseline definitions. Without this, a downgrade would strip a pre-existing permission, breaking transport access. Update migration test fixtures with realistic baselines (developer and team_admin include servers.use) and add a round-trip test that verifies upgrade->downgrade restores exact original permissions for all roles. Update e2e RBAC tests: since all non-admin users auto-receive platform_viewer (global) which now includes tools.execute, the tests that expected denial on the default /mcp endpoint now correctly expect success. This aligns with the intent of issue IBM#3329. Fix remaining stale "read-only" text in rbac.md migration info box for platform_viewer. Signed-off-by: Mihai Criveti <[email protected]> * remove tools.execute Signed-off-by: Rakhi Dutta <[email protected]> * fix(rbac): remove stale tools.execute references and fix test consistency The previous commit removed tools.execute from the migration and bootstrap_db.py but left it in docs, test constants, and e2e tests. This commit completes the cleanup: - Fix migration docstring formatting artifacts (double commas, extra spaces) - Revert viewer/platform_viewer description to "Read-only access" - Remove tools.execute from rbac.md viewer/platform_viewer permission tables - Remove tools.execute from test_rbac_permission_matrix.py constants - Replace hardcoded stale permission lists in migration backfill tests with ROLE_PERMISSION_ADDITIONS references - Restore original e2e deny assertions for tool execution (non-admin users lack global tools.execute) - Add integration tests for upgrade()/downgrade() via public entry points Signed-off-by: Mihai Criveti <[email protected]> * fix: rename alembic migration file to reflect servers.use instead of tools.execute Signed-off-by: Madhav Kandukuri <[email protected]> * down_revision Signed-off-by: Rakhi Dutta <[email protected]> * down revision in test Signed-off-by: Rakhi Dutta <[email protected]> * test case fix Signed-off-by: Rakhi Dutta <[email protected]> * fix(rbac): update migration down_revision to current head Point migration abf8ac3b6008 down_revision from e1f2a3b4c5d6 to 64acf94cb7f2 (the actual current Alembic head on main) to eliminate the multiple-heads condition that would break alembic upgrade. Update the corresponding test constant to match. Signed-off-by: Mihai Criveti <[email protected]> * fix(rbac): restore e2e denial helper and add downgrade edge-case test Restore _assert_access_denied_tool_call() in the e2e test — the replacement inline assertions were broken (checked result.isError but the actual response uses the error key with JSON-RPC code -32003) and weaker (did not verify "access denied" message or error code). Add a migration test documenting the known downgrade limitation: if a role already had a backfilled permission before the migration ran, downgrade() will remove it. This is an accepted trade-off for a simple data migration targeting system-bootstrapped roles. Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Rakhi Dutta <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> Signed-off-by: Madhav Kandukuri <[email protected]> Co-authored-by: Mihai Criveti <[email protected]> Co-authored-by: Madhav Kandukuri <[email protected]>
closes issue #3329
Description
Ensures
viewer,platform_viewer,developer, andteam_adminroles have the correct permission set on both new and existing deployments.Problem
The
admin.overviewandservers.usepermissions were missing from certain roles in existing databases. These permissions existed in the bootstrap definition but were never backfilled via a migration for users who had already run prior migrations.Solution
abf8ac3b6008to backfill the missing permissions into existing role records.bootstrap_db.pydefault role definitions so new deployments receive the correct permissions from first boot.Changes
mcpgateway/alembic/versions/abf8ac3b6008_add_admin_overview_and_tools_execute_to_.py(new)Data migration that adds missing permissions to existing role records:
vieweradmin.overview,servers.useplatform_vieweradmin.overview,servers.usedeveloperadmin.overviewteam_adminadmin.overviewCAST … AS JSONB)downgrade()removes the added permissionsrolestable (fresh DBs handled bybootstrap_db.py)mcpgateway/bootstrap_db.pyUpdated default role definitions in
bootstrap_default_roles():team_admin: addedadmin.overviewdeveloper: addedadmin.overviewviewer: addedadmin.overview,servers.useplatform_viewer: addedadmin.overview,servers.usedocs/docs/manage/rbac.mdUpdated permission tables and role listings to reflect the new permissions.
tests/unit/mcpgateway/db/test_rbac_permission_backfill_migration.py(new)Tests for the migration covering module structure, upgrade/downgrade logic, idempotency, edge cases, and round-trip verification.
tests/unit/mcpgateway/services/test_rbac_permission_matrix.pyUpdated permission fixtures to match the new role definitions.
Testing
alembic upgrade headon an existing SQLite or PostgreSQL database and verify the four roles have the new permissions.alembic downgrade -1and verify the permissions are removed.bootstrap_db.py.