Repository navigation
MCP server: how to map the JWT identity to a Superset user? (MCP_USER_RESOLVER in docs, not found in code) #45457
Replies: 3 comments
|
The organization that owns this space has reached its limit of To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
|
the docs list the resolver was added in #38747. in that implementation, the users must already exist. unknown identities are rejected for multi-user access:
if you trust multiple issuers, map using both before exposing the service, test with 2 users who have different dataset permissions. include concurrent calls and check their audit user ids if you need to stay on stable 6.1.0, i'm afraid there's no configuration-only fix for multi-user identity in its mcp authentication code. i'd keep multi-user mcp disabled until you have a reviewed backport or a stable release containing the resolver. cheers |
|
To answer your questions directly:
# superset_config.py
from superset.extensions import security_manager
from flask import g
def patch_mcp_auth():
try:
import superset.mcp_service.auth as mcp_auth
original_get_user = mcp_auth.get_user_from_request
def custom_get_user_from_request():
user = original_get_user()
if user:
return user
# Extract JWT from Authorization header
from fastmcp.server.dependencies import get_access_token
token = get_access_token()
if token and hasattr(token, "claims"):
username = token.claims.get("preferred_username") or token.claims.get("sub")
if username:
resolved_user = security_manager.find_user(username=username)
if resolved_user:
return resolved_user
return None
mcp_auth.get_user_from_request = custom_get_user_from_request
except (ImportError, AttributeError):
pass
# Execute during config evaluation
patch_mcp_auth()
|
Uh oh!
There was an error while loading. Please reload this page.
Version: Apache Superset 6.1.0. MCP started with superset mcp run, MCP_AUTH_ENABLED=True, JWT validation.
What I expected: following the MCP server docs, the sub claim of the token identifies the Superset user, so each person’s RBAC applies.
What happens: the JWT is validated, but nothing maps sub to a Superset user. Every tool call fails with “No authenticated user found” unless I set MCP_DEV_USERNAME. With it set, every token acts as the same user, so there is no per-user RBAC or auditing.
Docs vs code: the docs mention MCP_USER_RESOLVER. I searched the repository for it and found no results.
Questions:
@dosu
All reactions