[BUG]: OAUTH2 users MUST be registered to consume virtual servers
🐞 Bug Summary
When i expose a VS with OAUTH2 my users should be trusted by my IDP with associated roles without existing in the FORGE database. Or, The user should be created dynamically while performing the OAUTH2 flow. Currently, users must be registered BEFORE any consumption of the VS which complicate the onboarding process. We do not want specifically that all OAUTH2 VS consumers to be registered in the forge database because the amount of users in IDP is huge
Plus, we don't want that MCP VS consumer to be able to access to the UI.
🧩 Affected Component
Select the area of the project impacted:
- [X]
mcpgateway- API - [ ]
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
- ...Configure a public virtual server with OAUTH2 with the specific OAUTH2 server
- ...Perform the OAUTH2 flow with the specified clientID (The user do not exists in the FORGE database but in the IDP)
- ...Try to connect with inspector -> KO -> The user do not have suficient permission even if the token contains all required partterns
If you re do the steps with registering users before performing step 3 (and role admin), it works
🤔 Expected Behavior
I think that a user trusted by the IDP that forward the specific permission (With the role for example) should be able to consume public MCP VS without being registered before.
📓 Logs / Error Output
Paste any relevant stack traces or logs here. INFO [uvicorn.access] 10.89.0.2:51780 - "GET /.well-known/oauth-protected-resource/servers/2b83f14e3b054c4298ea181ededf1d56/mcp HTTP/1.1" 200 WARNI [mcpgateway.transports.streamablehttp_transport] Streamable HTTP RBAC denied: user=***, permission=servers.use INFO [uvicorn.access] 10.89.0.2:51736 - "POST /mcp/ HTTP/1.1" 403
🧠 Environment Info
You can retrieve most of this from the /version endpoint.
| Key | Value |
|---|---|
| Version or commit | e.g. v0.9.0 or main@a1b2c3d |
| Runtime | e.g. Python 3.11, Gunicorn |
| Platform / OS | e.g. Ubuntu 22.04, macOS |
| Container | e.g. Docker, Podman, none |
🧩 Additional Context (optional)
Add any configuration details, flags, or related issues.
PR #6402 implements this for the routed OAuth path. When a valid token reaches an OAuth-enabled virtual server for a user who does not exist yet, the user is provisioned just in time, after the token passed the server's issuer and audience checks. It is opt-in, gated by SSO_API_TOKEN_AUTH_ENABLED and the provider's trusted_for_api_auth and auto_create_users. The existing trusted-domain, email-verification and approval checks still apply.
It was rebased onto main on 16 Oct. We run it in our deployment for headless MCP clients. The new admin provisioning API (#7180, #7219) helps when users can be created in advance, but not for a first-time user arriving with a token.