fix-2185: fix listing public server#2186
Conversation
Review FeedbackHi @KKNithin, thank you for investigating this issue and submitting a fix. I've done a deep dive into the RBAC and visibility system and found some concerns we need to address. Consistency IssueThe proposed change makes gateway visibility behavior inconsistent with all other entity types:
The original Root Cause AnalysisThe reported bug ("Non-Admin user unable to list public gateways") likely occurs because:
This is actually by design - when you filter by team, you see that team's items. The "All Teams" view (no What Would Be Needed for a Complete FixIf we decide to change the semantics so that public items are always visible regardless of team filter, we would need to:
Alternative Approaches to Consider
What WorksThe Let's discuss the right approach here before proceeding. We can use this same PR/issue to implement the complete fix once we've agreed on the direction. |
Add GATEWAYS_CREATE, GATEWAYS_READ, GATEWAYS_UPDATE, and GATEWAYS_DELETE permission constants to the Permissions class for consistency with other resource types (tools, resources, prompts, servers). Note: The original PR IBM#2186 attempted to fix issue IBM#2185 by modifying the visibility query logic, but that change was incorrect. The team filter should only show resources BELONGING to the filtered team, not all public resources globally. See todo/rbac.md for documentation. Issue IBM#2185 needs further investigation - the reported bug may have a different root cause. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Add gateway routes to token scoping middleware for consistent permission
enforcement:
- Add gateway pattern to _RESOURCE_PATTERNS for ID extraction
- Add gateway CRUD patterns to _PERMISSION_PATTERNS:
- POST /gateways (exact) -> gateways.create
- POST /gateways/{id}/... (sub-resources) -> gateways.update
- PUT/DELETE -> gateways.update/delete
- Add gateway handling in _check_resource_team_ownership:
- Public: accessible by all
- Team: accessible by team members
- Private: owner-only access (per RBAC doc)
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
…urces Per RBAC doc, private visibility means "owner only" - not "team members". Fixed private visibility checks for all resource types to validate owner_email == requester instead of team membership: - Servers - Tools - Resources - Prompts - Gateways (already correct from previous commit) This aligns token scoping middleware with the documented RBAC model. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Add unit tests covering: - Gateway permission patterns (POST create vs POST update sub-resources) - Private visibility enforces owner-only access - Team visibility allows team members only - Public visibility allows all authenticated users These tests validate the RBAC fixes in token scoping middleware. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
PR Rework SummaryThis PR has been significantly reworked from the original submission. Here's what changed: Design Decision: Team Filter Semantics (Option A)After deep analysis of the RBAC model, we chose Option A (pure filter semantics):
The original "fix" conflated Changes in This PR1. Gateway Permission Constants (
|
2dc98ee to
874004e
Compare
crivetimihai
left a comment
There was a problem hiding this comment.
Please retest, and open a new issue if necessary.
* feat: Add Gateway permission constants Add GATEWAYS_CREATE, GATEWAYS_READ, GATEWAYS_UPDATE, and GATEWAYS_DELETE permission constants to the Permissions class for consistency with other resource types (tools, resources, prompts, servers). Note: The original PR IBM#2186 attempted to fix issue IBM#2185 by modifying the visibility query logic, but that change was incorrect. The team filter should only show resources BELONGING to the filtered team, not all public resources globally. See todo/rbac.md for documentation. Issue IBM#2185 needs further investigation - the reported bug may have a different root cause. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> * feat: Add gateway permission patterns to token scoping middleware Add gateway routes to token scoping middleware for consistent permission enforcement: - Add gateway pattern to _RESOURCE_PATTERNS for ID extraction - Add gateway CRUD patterns to _PERMISSION_PATTERNS: - POST /gateways (exact) -> gateways.create - POST /gateways/{id}/... (sub-resources) -> gateways.update - PUT/DELETE -> gateways.update/delete - Add gateway handling in _check_resource_team_ownership: - Public: accessible by all - Team: accessible by team members - Private: owner-only access (per RBAC doc) Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> * fix: Enforce owner-only access for private visibility across all resources Per RBAC doc, private visibility means "owner only" - not "team members". Fixed private visibility checks for all resource types to validate owner_email == requester instead of team membership: - Servers - Tools - Resources - Prompts - Gateways (already correct from previous commit) This aligns token scoping middleware with the documented RBAC model. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> * test: Add tests for gateway permissions and visibility RBAC Add unit tests covering: - Gateway permission patterns (POST create vs POST update sub-resources) - Private visibility enforces owner-only access - Team visibility allows team members only - Public visibility allows all authenticated users These tests validate the RBAC fixes in token scoping middleware. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
resolves issue #2185
closes #2185