Skip to content

feat(ui): allow non-owner users to authorize on accessible OAuth gateways#3935

Open
kimsehwan96 wants to merge 3 commits intoIBM:mainfrom
kimsehwan96:feat/authorize-non-owner-access
Open

feat(ui): allow non-owner users to authorize on accessible OAuth gateways#3935
kimsehwan96 wants to merge 3 commits intoIBM:mainfrom
kimsehwan96:feat/authorize-non-owner-access

Conversation

@kimsehwan96
Copy link
Copy Markdown
Contributor

@kimsehwan96 kimsehwan96 commented Mar 31, 2026

🔗 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.

  • Add can_authorize template variable (broader than can_modify) for Authorize/Fetch Tools buttons
  • Keep can_modify for Edit/Deactivate/Delete (unchanged)

🏷️ Type of Change

  • Bug fix
  • Feature / Enhancement
  • Documentation
  • Refactor
  • Chore (deps, CI, tooling)
  • Other (describe below)

🧪 Verification

Check Command Status
Lint suite make lint pass
Unit tests make test pass
Coverage ≥ 80% make coverage

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • Tests added/updated for changes
  • Documentation updated (if applicable)
  • No secrets or credentials committed

📓 Notes (optional)

Changed files:

  • gateways_partial.html: 1 line added + 1 line modified
  • test_admin.py: 5 tests added (2 positive, 2 regression, 1 negative)

Visibility logic:

  ┌─────────────────────────────────┬───────────┬─────────────┐
  │            User type            │ Authorize │ Edit/Delete │
  ├─────────────────────────────────┼───────────┼─────────────┤
  │ Admin                           │    ✅     │     ✅      │
  ├─────────────────────────────────┼───────────┼─────────────┤
  │ Gateway owner                   │    ✅     │     ✅      │
  ├─────────────────────────────────┼───────────┼─────────────┤
  │ Team member (non-gateway-owner) │    ✅     │     ❌      │
  ├─────────────────────────────────┼───────────┼─────────────┤
  │ Any user (public gw)            │    ✅     │     ❌      │
  ├─────────────────────────────────┼───────────┼─────────────┤
  │ Non-member (team gw)            │    ❌     │     ❌      │
  └─────────────────────────────────┴───────────┴─────────────┘

Screenshot as team member but not the mcp owner.

스크린샷 2026-03-31 오전 11 30 46

(AWS Docs MCP set as no auth type)

E2E Verification (manual):

  • Built and deployed from this commit to a live K8s cluster
  • Tested as a team member who is not the gateway owner
  • Confirmed Authorize button is visible and OAuth flow completes successfully
  • As team owner: authorization, tool fetch, and tool invocation all work with the user's own token
  • As team member: authorization works, but tool fetch/invocation is blocked due to missing tools.execute permission (pending feat(rbac): add tools.execute permission to team-scoped viewer role #3882)

Copy link
Copy Markdown
Collaborator

@marekdano marekdano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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 test

    The 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.baseline issue

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.

@kimsehwan96 kimsehwan96 force-pushed the feat/authorize-non-owner-access branch from 4409ef1 to f25b9d5 Compare April 10, 2026 13:36
marekdano
marekdano previously approved these changes Apr 10, 2026
Copy link
Copy Markdown
Collaborator

@marekdano marekdano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_authorize variable: can_modify OR public OR team-member
  • Changed Authorize button condition from can_modify to can_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 🚀

@marekdano marekdano added release-fix Critical bugfix required for the release ui User Interface labels Apr 10, 2026
@kimsehwan96
Copy link
Copy Markdown
Contributor Author

kimsehwan96 commented Apr 10, 2026

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.

@gcgoncalves gcgoncalves force-pushed the feat/authorize-non-owner-access branch 2 times, most recently from ec3a792 to 29afb76 Compare April 13, 2026 10:08
@gcgoncalves
Copy link
Copy Markdown
Collaborator

@marekdano Rebased and got through CI.

@gcgoncalves gcgoncalves requested a review from marekdano April 13, 2026 10:20
marekdano
marekdano previously approved these changes Apr 13, 2026
Copy link
Copy Markdown
Collaborator

@marekdano marekdano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

marekdano
marekdano previously approved these changes Apr 14, 2026
kimsehwan96 and others added 3 commits April 16, 2026 15:14
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-fix Critical bugfix required for the release ui User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE][AUTH]: Allow non-owner users to initiate OAuth authorization on accessible gateways

5 participants