Commit Graph

19746 Commits

Author SHA1 Message Date
Amin Ghadersohi
d8db1c9230 refactor(mcp): delegate load_user_with_relationships to SecurityManager.find_user_with_relationships
Fixes a gap identified in code review: the standalone load_user_with_relationships()
in auth.py duplicated SecurityManager.find_user() logic but dropped two FAB behaviors:
- auth_username_ci (case-insensitive username lookup)
- MultipleResultsFound guard (username uniqueness not guaranteed at DB level in all FAB versions)
It also hard-coded User/Group models instead of sm.user_model.

Changes:
- Add SupersetSecurityManager.find_user_with_relationships() to security/manager.py,
  mirroring FAB's find_user() (auth_username_ci, MultipleResultsFound handling,
  self.user_model) and adding eager loading of roles and group.roles via joinedload
- Simplify load_user_with_relationships() in auth.py to a thin delegate to the
  new method, removing the duplicated query logic and raw Group/User imports
- Add regression test asserting find_user_with_relationships() exists on the SM

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 22:10:36 +00:00
Amin Ghadersohi
202b19951a fix(mcp): harden auth — PermissionError propagation, passthrough client_id guard, fail-closed on missing token
- _tool_allowed_for_current_user (server.py): catch PermissionError
  alongside ValueError so invalid API keys return False instead of
  propagating through the tool-search permission filter
- _setup_user_context (auth.py): catch PermissionError alongside
  ValueError so g.user is cleared and the error is logged consistently
  regardless of which failure type get_user_from_request() raises
- _resolve_user_from_api_key (auth.py): require client_id=="api_key"
  (set by CompositeTokenVerifier) in addition to API_KEY_PASSTHROUGH_CLAIM
  to prevent an external IdP JWT that happens to include the claim name
  from being misclassified as an API-key pass-through (DoS vector)
- _resolve_user_from_jwt_context (auth.py): same client_id guard so
  a rogue-claim JWT continues through JWT resolution instead of deferring
  to the API-key path (which would raise PermissionError for the user)
- _resolve_user_from_api_key (auth.py): raise PermissionError (not
  return None) when the pass-through claim is present but the raw token
  is absent — fail closed rather than falling through to weaker auth
- Tests: set client_id="api_key" on _passthrough_access_token helper;
  update test_jwt_context_with_api_key_passthrough_returns_none docstring;
  add test for namespaced claim on non-API-key client_id being ignored

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 21:26:42 +00:00
Amin Ghadersohi
d675a97686 refactor(mcp): extract duplicated app context + sm setup into helper
Add _mock_sm_ctx() context manager to eliminate repeated boilerplate
(g.user = None / app.appbuilder = MagicMock() / appbuilder.sm = mock_sm)
across seven API key auth unit tests.
2026-05-13 19:57:41 +00:00
Amin Ghadersohi
ba97a29468 fix(mcp): fix stale patch target in auth tests and update stale docstring
- Use superset.mcp_service.auth.has_request_context as patch target in
  test_mcp_auth_hook_clears_stale_g_user tests; patching flask.has_request_context
  has no effect on the module-level import already bound in auth.py
- Update test_jwt_access_token_skips_api_key_auth docstring to reference
  API_KEY_PASSTHROUGH_CLAIM instead of the legacy _api_key_passthrough name
- Add noqa: BLE001 to broad exception catch in mcp_config.py to document
  that the wide catch is intentional (JWT libs raise many types, secrets guard)
2026-05-13 06:34:46 +00:00
Amin Ghadersohi
637f74d0d8 Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-08 16:04:09 -04:00
Amin Ghadersohi
5649b28495 refactor(mcp): hoist JWT verifier imports to module top
DetailedJWTVerifier and JWTVerifier have no circular-import or optional-
dependency reason to be imported inline — fastmcp is already pulled in
at module top via composite_token_verifier, and authlib is already a
hard dependency. Moving them up for consistency with the rest of the
module's imports.
2026-05-08 14:57:06 -04:00
Amin Ghadersohi
aaabec317e fix(security): drop redundant explicit ApiKey perm creation
``superset init`` calls ``appbuilder.add_permissions(update_perms=True)``
before ``sync_role_definitions()`` (cli/main.py:84), which forces FAB to
walk all registered baseviews — including ``ApiKeyApi`` (registered when
``FAB_API_KEY_ENABLED=True``) — and create their PVMs via
``add_permissions_view``. The explicit ``add_permission_view_menu`` calls
in ``create_custom_permissions`` were redundant.

With ``"ApiKey"`` already in ``ADMIN_ONLY_VIEW_MENUS``, the role
predicate ``_is_admin_only`` gates the auto-created PVMs to Admin.

Per Daniel Gaspar's review: "Adding ApiKey to ADMIN_ONLY_VIEW_MENUS
should just work when FAB_API_KEY_ENABLED is True".
2026-05-08 14:47:58 -04:00
Amin Ghadersohi
9ece5f42d7 refactor(mcp): hoist API key auth imports to module top
The API_KEY_PASSTHROUGH_CLAIM constant in auth.py and CompositeTokenVerifier
in mcp_config.py have no circular-import or optional-dependency reason to
be imported inline. Moved them to module top.
2026-05-08 14:36:16 -04:00
Amin Ghadersohi
76ad5e1bf7 fix(mcp): validate API keys via FastMCP AccessToken and lock down ApiKey perms
Three independent bugs let MCP requests presenting Bearer tokens with the
sst_ prefix authenticate as MCP_DEV_USERNAME without any validation under
streamable-http:

1. _resolve_user_from_api_key read the token from flask.request.headers,
   but the streamable-http transport never pushes a Flask request context
   — has_request_context() was always False, so the function returned
   None before validating, falling through to the dev-user fallback.
   Now reads the token from FastMCP's per-request AccessToken (which the
   CompositeTokenVerifier already populated) and fails closed when the
   key is invalid.

2. CompositeTokenVerifier was only installed when MCP_AUTH_ENABLED=True.
   With FAB_API_KEY_ENABLED=True alone, no transport-level verifier
   existed at all. The factory now builds an API-key-only verifier in
   that case (jwt_verifier=None) that rejects non-API-key Bearer tokens
   at the transport instead of silently accepting them.

3. The pass-through AccessToken was minted with scopes=[], which would
   make FastMCP's RequireAuthMiddleware 403 every API-key request when
   MCP_REQUIRED_SCOPES is non-empty. Pass-through now propagates
   self.required_scopes.

Also addresses Daniel's review comment on superset/security/manager.py:
adds "ApiKey" to ADMIN_ONLY_VIEW_MENUS so the FAB ApiKeyApi PVMs are
gated to Admin instead of leaking to Alpha and Gamma.

Renames the pass-through claim from _api_key_passthrough to the
namespaced _superset_mcp_api_key_passthrough (exported as
API_KEY_PASSTHROUGH_CLAIM) so a custom claim from an external IdP can't
accidentally divert a JWT into the API-key validation path.

Tests updated to mock get_access_token instead of app.test_request_context
(the simulated Flask context was the reason the prior tests passed while
production failed). New tests cover API-key-only verifier mode, scope
propagation on pass-through, and the namespaced-claim isolation.
2026-05-08 14:26:05 -04:00
Amin Ghadersohi
38b9ea5484 fix(mcp): remove prefixes from log to satisfy CodeQL
Remove API key prefixes from log message to avoid CodeQL
false positive about clear-text logging of sensitive data.
2026-05-08 11:42:45 -04:00
Amin Ghadersohi
135579b8e1 fix(mcp): add type annotations to test fixtures and parameters
Address code review feedback: add explicit type annotations
to all new test function parameters and fixture return types.
2026-05-08 11:42:45 -04:00
Amin Ghadersohi
b9aee62f5f fix(mcp): wire composite verifier and add ApiKey permission sync
Wire CompositeTokenVerifier into create_default_mcp_auth_factory,
add _api_key_passthrough detection in _resolve_user_from_jwt_context,
create ApiKey permissions in create_custom_permissions, and update
test_auth_api_key with pass-through and non-matching prefix tests.
2026-05-08 11:42:45 -04:00
Amin Ghadersohi
7ad0b5e3f8 fix(mcp): create ApiKey permissions on init and support API keys with JWT auth
Two fixes for MCP API key authentication:

1. superset init now creates ApiKey FAB permissions (can_list, can_create,
   can_get, can_delete) when FAB_API_KEY_ENABLED=True. Previously, because
   Superset uses AppBuilder(update_perms=False), FAB skipped permission
   creation during blueprint registration and superset init never picked
   them up, causing 403 errors on /api/v1/security/api_keys/.

2. CompositeTokenVerifier allows API key tokens (e.g. sst_...) to coexist
   with JWT auth on the MCP transport layer. Previously, when
   MCP_AUTH_ENABLED=True, the JWTVerifier rejected all non-JWT Bearer
   tokens at the transport layer before they could reach the Flask-level
   _resolve_user_from_api_key() handler. The composite verifier detects
   API key prefixes and passes them through with a marker claim, letting
   the existing auth priority chain handle validation.
2026-05-08 11:42:45 -04:00
Richard Fogaca Nienkotter
549aff7cf9 fix(mcp): clarify chart preview URL metadata (#39731) 2026-04-29 12:37:40 -03:00
Daniel Vaz Gaspar
c7c9a17d6b fix(mysql): fallback to pymysql when MySQLdb is not installed in get_datatype() (#39729)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-29 14:40:39 +01:00
JUST.in DO IT
54f1e32763 fix(dashboard): escape emoji in position_json before saving to prevent truncation (#39737)
Co-authored-by: Michael S. Molina <michael.s.molina@gmail.com>
2026-04-29 10:08:50 -03:00
dependabot[bot]
2a884e8456 chore(deps-dev): bump @swc/core from 1.15.30 to 1.15.32 in /superset-frontend (#39692)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-29 09:03:54 -04:00
dependabot[bot]
7b02c21bff chore(deps): bump @ant-design/icons from 6.1.1 to 6.2.2 in /superset-frontend (#39697)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-29 09:03:32 -04:00
dependabot[bot]
1dd28c6fcd chore(deps-dev): bump @typescript-eslint/eslint-plugin from 8.59.0 to 8.59.1 in /superset-frontend (#39696)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-29 09:03:16 -04:00
Daniel Vaz Gaspar
eba08ae52a fix(ci): switch Dependabot Python ecosystem from uv to pip (#39726)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-29 12:30:38 +01:00
Jean Massucatto
171414f165 fix(chart): use categorical axis for bar charts with numeric x-axis (#39141)
Co-authored-by: Enzo Martellucci <52219496+EnxDev@users.noreply.github.com>
2026-04-29 09:41:19 +02:00
dependabot[bot]
dbd7984ce9 chore(deps-dev): bump oxlint from 1.61.0 to 1.62.0 in /superset-frontend (#39701)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-29 00:19:48 -04:00
Amin Ghadersohi
4b42f82f13 fix(mcp): restore typed ChartConfig in tool schemas for LLM visibility (#39732) 2026-04-28 19:46:57 -04:00
dependabot[bot]
ea3a1955b7 chore(deps): bump @swc/core from 1.15.30 to 1.15.32 in /docs (#39695)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-28 16:26:57 -04:00
Richard Fogaca Nienkotter
d0abb66fdf fix(mcp): default chart previews to ascii (#39719) 2026-04-28 13:30:39 -03:00
Shantanu Khond
ef50b688ee fix(docs): add split Get Started button to main docs page with audience links (#39467) 2026-04-28 10:35:26 -04:00
Daniel Vaz Gaspar
3aa99c577e chore(deps): bump python-dotenv from 1.1.0 to 1.2.2 (#39723) 2026-04-28 14:53:57 +01:00
Amin Ghadersohi
09c7e1fc08 fix(mcp): rename _FastMCPValidationFilter to public symbol (#39722) 2026-04-28 09:53:13 -04:00
Amin Ghadersohi
6947881ba7 fix(mcp): classify user errors as WARNING, system errors as ERROR (#39634)
Co-authored-by: Elizabeth Thompson <eschutho@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 08:55:17 -04:00
Michael S. Molina
7bee2afa8e fix(theme): set color-scheme on html to fix dark mode scrollbars (#39704)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 09:17:11 -03:00
Michael S. Molina
c4a8b34b11 fix(query-history): enable sorting by Duration column (#39637)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 08:49:58 -03:00
Sam Firke
3395620b6e fix(table chart): fix rerender bug that continuously cleared search box (#39707) 2026-04-28 08:40:56 -03:00
Mehmet Salih Yavuz
3f28f5d012 fix(mcp): surface structured errors for generate_chart validation failures (#39484)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 11:13:53 +03:00
Mehmet Salih Yavuz
cf587caca7 fix(plugin-chart-handlebars): preserve template on explore open (#39442)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 11:13:37 +03:00
dependabot[bot]
523ecb65a4 chore(deps-dev): bump typescript-eslint from 8.59.0 to 8.59.1 in /superset-websocket (#39687)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-27 19:46:11 -04:00
Đỗ Trọng Hải
5fe3a1c2cd fix(dev): revert react-checkbox-tree from 2.1.0 to 1.8.0 in /superset-frontend (#39660)
Signed-off-by: hainenber <dotronghai96@gmail.com>
Co-authored-by: Evan Rusackas <evan@rusackas.com>
2026-04-27 14:17:17 -04:00
SkinnyPigeon
90f8fafbb4 docs(rls): adding additional rls filter documentation (#38829)
Co-authored-by: codeant-ai-for-open-source[bot] <244253245+codeant-ai-for-open-source[bot]@users.noreply.github.com>
2026-04-27 14:12:25 -04:00
Amin Ghadersohi
7774ec7e3c fix(mcp): database filter columns, timeseries SQL, and unsaved chart datasource name (#39636) 2026-04-27 13:41:06 -04:00
innovark
6da04fa51d fix(Modal): prevent title overlapping with close button in long header titles (#36536) 2026-04-27 13:33:02 -04:00
Evan Rusackas
7c4b2b137c fix(explore): ensure unsaved-changes dialog renders above View SQL modal (#39569)
Co-authored-by: yousoph <sophieyou12@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 10:02:25 -07:00
Đỗ Trọng Hải
9ccd37de1c chore(ci): update Node.js version used in building CI image (#38635) 2026-04-27 22:46:52 +07:00
dependabot[bot]
b791f4c2cd chore(deps): bump d3-cloud from 1.2.8 to 1.2.9 in /superset-frontend (#39677)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-27 11:42:42 -04:00
dependabot[bot]
44d1f50b7c chore(deps): bump baseline-browser-mapping from 2.10.21 to 2.10.23 in /docs (#39671)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-27 11:42:15 -04:00
David
b9de3dba95 fix(docs): fix 404s in documentation (#38974)
Co-authored-by: Evan Rusackas <evan@preset.io>
2026-04-27 08:36:58 -07:00
SBIN2010
4c4905f689 fix: d3 format for table (#37454) 2026-04-27 11:54:41 +03:00
Đỗ Trọng Hải
2b13e07521 fix(ci): resolve OOM issues when building docs locally with Docusaurus Faster + sync docs with latest build result (#38486)
Signed-off-by: hainenber <dotronghai96@gmail.com>
Co-authored-by: Evan Rusackas <evan@preset.io>
Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 15:45:53 +07:00
dependabot[bot]
7c24214857 chore(deps): bump caniuse-lite from 1.0.30001790 to 1.0.30001791 in /docs (#39674)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-27 04:40:16 -04:00
dependabot[bot]
37bf729f75 chore(deps-dev): bump jsdom from 29.0.2 to 29.1.0 in /superset-frontend (#39678)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-27 04:39:46 -04:00
dependabot[bot]
0b78ffbb9c chore(deps): bump react-syntax-highlighter from 16.1.0 to 16.1.1 in /superset-frontend (#39672)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-27 04:38:33 -04:00
dependabot[bot]
41823a3057 chore(deps): bump @ant-design/icons from 6.1.1 to 6.2.0 in /docs (#39673)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-27 04:38:16 -04:00