[BUG][AUTH]: UI/API Users with no admin privileges can no longer login
🐞 Bug Summary
Users with no admin privileges can no longer login
🧩 Affected Component
Select the area of the project impacted:
- [x]
mcpgateway- API - [x]
mcpgateway- UI (admin panel) - [ ]
mcpgateway.wrapper- stdio wrapper - [ ] Federation or Transports
- [ ] CLI, Makefiles, or shell scripts
- [ ] Container setup (Docker/Podman/Compose)
- [ ] Other (explain below)
🔁 Steps to Reproduce
- Go to http://localhost:8000/admin/login
- Add an user email and password
- Click Sign In
🤔 Results
Users with no admin privileges can no longer login
🤔 Expected Behavior
User should have the option to login and the user menu should be loaded successfully.
📓 Logs / Error Output
Paste any relevant stack traces or logs here. ⚠️ Do not paste secrets, credentials, or tokens.
🧠 Environment Info
You can retrieve most of this from the /version endpoint.
| Key | Value |
|---|---|
| Version or commit | v0.128.0 |
| Runtime | Python 3.12.3 |
| Platform / OS | Linux 6.6.87.2-microsoft-standard-WSL2 (x86_64) |
| Container | none |
🧩 Additional Context (optional)
Related to #2390
Root Cause Identified
The AdminAuthMiddleware added in commit a44ca2b5b (PR #2548 - "feat(auth): add token revocation and proxy auth to middleware") intentionally blocks ALL non-admin users from accessing any /admin/* routes.
Technical Details
Location: mcpgateway/main.py:1565-1567
if not user.is_admin:
logger.warning(f"Admin access denied for non-admin user: {username}")
return self._error_response(request, root_path, 403, "Admin privileges required", "admin_required")
The middleware only exempts:
/admin/login/admin/logout/admin/static
All other /admin/* routes return 403 Forbidden for non-admin users.
Breaking Change
Previous behavior: Non-admin users could access the admin dashboard with limited functionality. Template sections were hidden via {% if is_admin %} conditionals in admin.html.
Current behavior: Non-admin users are completely blocked from accessing the admin UI after login.
Possible Solutions
-
Add dashboard to exempt paths: Add
/admin/(main dashboard) toEXEMPT_PATHSinAdminAuthMiddlewareand continue relying on template-level access control for feature visibility -
Tiered permission system: Modify the middleware to allow authenticated users to access read-only views while restricting admin-specific actions
-
Document as intended: If blocking non-admin users is the intended behavior, update documentation to clarify that all admin UI users must have
is_admin=True
Related
This is related to issue #2390 (authentication testing) as mentioned in the bug report.
This appears to be the same root cause as #2694 - newly created users don't have any roles assigned in the user_roles table, so they fail the admin.dashboard permission check when trying to access the Admin UI.
The login itself succeeds, but the redirect to /admin fails with 403 Forbidden because users without RBAC roles have no permissions.
Duplicate of #2694 - will be fixed when default role assignment is implemented.
Canonical tracking issue is #2741 (same root cause as #2694). EmailAuthService.create_user() sets is_admin flag but never creates a user_roles entry, and the entire Admin UI uses allow_admin_bypass=False — so without an RBAC role assignment, all users (admin or not) get 403 on /admin/.