feat(ui): allow non-owner users to authorize on accessible OAuth gateways#3935
feat(ui): allow non-owner users to authorize on accessible OAuth gateways#3935kimsehwan96 wants to merge 3 commits intoIBM:mainfrom
Conversation
08bfef8 to
9924ec2
Compare
There was a problem hiding this comment.
@kimsehwan96 - thanks for your contribution!!!
Summary
Fixes a UI gap where non-owner team members and users of public gateways could not see the "Authorize" button on OAuth gateways, even though the backend already stores tokens per user. The change is clean and minimal — one new Jinja
variable, one guarded block updated — with solid test coverage.
Findings
-
tests/unit/mcpgateway/test_admin.py:19151— Test coverage gap in existing testThe existing test_gateways_hides_buttons_for_non_owner uses authType: "none", so it doesn't exercise the OAuth path for a non-owner. Low risk since Authorize is gated on
authType == 'oauth', but there's a small gap in the negative-case matrix. Worth adding a case with authType: "oauth" and a non-owner to confirm the Authorize link is absent when it should be (e.g. a non-member on a team gateway). -
fix pre-commit check for
.secrets.baselineissue
Notes (no action required)
- The five new tests cover the matrix well: two positive (team member, public gateway), two regression (owner, admin), one negative (non-member). Good shape.
- The can_authorize logic — can_modify OR public OR team-member — is correct and the short-circuit order is sound.
- Template-only change; the OAuth endpoint at /oauth/authorize/{gateway_id} retains responsibility for backend authorization enforcement.
- No linter issues observed in the patch.
4409ef1 to
f25b9d5
Compare
marekdano
left a comment
There was a problem hiding this comment.
Summary
This is a clean, well-tested UI fix that correctly broadens OAuth authorization button visibility to team members and public gateway users while maintaining proper access control for destructive operations.
What Changed
Template Change (gateways_partial.html)
- Added
can_authorizevariable:can_modify OR public OR team-member - Changed Authorize button condition from
can_modifytocan_authorize - Edit/Delete/Deactivate remain gated by
can_modify(unchanged)
Test Coverage (test_admin.py)
- ✅ 5 new OAuth-specific tests added
- ✅ Covers positive cases (team member, public gateway)
- ✅ Covers regression cases (owner, admin)
- ✅ Covers negative case (non-member on team gateway)
Security Analysis
✅ No Security Concerns:
- Template-only change, no backend logic modified
- Destructive operations (Edit/Delete) remain properly gated
- OAuth authorization is a per-user operation (not destructive)
- Backend token storage is already per-user (
oauth_tokens.app_user_email) - Non-members correctly blocked from team gateways
LGTM 🚀
|
Thanks! @marekdano I can rebase and resolve the .secrets.baseline conflict, but it will likely conflict again as other PRs get merged (the baseline shifts with every line-number change in test files). Feel free to rebase this branch right before merge it. |
ec3a792 to
29afb76
Compare
|
@marekdano Rebased and got through CI. |
29afb76 to
95954ae
Compare
…ways Non-owner team members and public gateway users could not see the Authorize button, preventing them from completing the OAuth flow and storing their own tokens. The backend already supports per-user OAuth tokens (keyed by gateway_id + app_user_email), but the UI gated the Authorize button behind can_modify which requires owner/admin status. Introduce can_authorize — a broader visibility check that includes team members and public gateway users — and apply it to the Authorize and Fetch Tools buttons while keeping Edit/Deactivate/Delete behind can_modify. Closes: IBM#3934 Signed-off-by: kimsehwan96 <sktpghks138@gmail.com>
Signed-off-by: kimsehwan96 <sktpghks138@gmail.com>
Signed-off-by: Gabriel Costa <gabrielcg@proton.me>
95954ae to
63f139b
Compare
🔗 Related Issue
Closes #3934
📝 Summary
Non-owner team members and public gateway users cannot see the "🔐 Authorize" button on OAuth gateways, preventing them from completing the OAuth flow. The backend already stores tokens per-user (oauth_tokens.app_user_email), so this is purely a UI visibility fix.
🏷️ Type of Change
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)📓 Notes (optional)
Changed files:
Visibility logic:
Screenshot as team member but not the mcp owner.
(AWS Docs MCP set as no auth type)
E2E Verification (manual):