Repository navigation
feat(semantic-layer): support per-user OAuth2 authentication - #45894
betodealmeida wants to merge 13 commits into
Conversation
9a5af7e to
76ee7e9
Compare
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #45894 +/- ##
===========================================
- Coverage 84.73% 65.61% -19.12%
===========================================
Files 3069 3072 +3
Lines 205767 206332 +565
Branches 48388 48508 +120
===========================================
- Hits 174350 135381 -38969
- Misses 28123 67872 +39749
+ Partials 3294 3079 -215
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| if isinstance(self._properties.get("configuration"), dict): | ||
| self._properties["configuration"] = _unmask_configuration( | ||
| self._properties["configuration"] = unmask_stored_configuration( |
There was a problem hiding this comment.
Suggestion: When a masked credential is nested, the helper misses it; this update can then save a changed destination with the real stored secret.
Assessment: 🔴 Critical · 🔁 Occurrence: Sometimes · 🏷️ Security
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/commands/semantic_layer/update.py
**Line:** 233:233
**Comment:**
*Security: When a masked credential is nested, the helper misses it; this update can then save a changed destination with the real stored secret.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| if (signal?.aborted || generation !== pollingGeneration) { | ||
| throw new DOMException('Aborted', 'AbortError'); | ||
| } | ||
| if (queryError.errors?.length) throw { errors: queryError.errors }; |
There was a problem hiding this comment.
Suggestion: waitForAsyncData is also used by self-contained charts, whose error handler drops this object’s errors; OAuth failures there become generic errors without an authorization prompt.
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Api mismatch
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/src/middleware/asyncEvent.ts
**Line:** 656:656
**Comment:**
*Api Mismatch: `waitForAsyncData` is also used by self-contained charts, whose error handler drops this object’s `errors`; OAuth failures there become generic errors without an authorization prompt.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| : saving || | ||
| clearing || | ||
| !name.trim() || | ||
| hasErrors || | ||
| requiredActionPending |
There was a problem hiding this comment.
Suggestion: refreshingSchema is omitted here, so Save remains enabled during dependent-schema discovery and can persist configuration before its dynamic fields are reconciled.
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Incorrect condition logic
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/src/features/semanticLayers/SemanticLayerModal.tsx
**Line:** 574:578
**Comment:**
*Incorrect Condition Logic: `refreshingSchema` is omitted here, so Save remains enabled during dependent-schema discovery and can persist configuration before its dynamic fields are reconciled.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
SUMMARY
Adds support for per-user OAuth2 authentication in Semantic Layer extensions.
With this PR, extensions can now store access and refresh tokens in encrypted, user-scoped storage that is unavailable through browser-facing extension storage APIs. Tokens remain scoped to the user who authorized access.
Semantic Layer extensions reuse Superset’s existing OAuth2 error handling and authorization UI. Authorization can be triggered from configuration dialogs, Explore, and dashboard queries. Completing authorization retries the interrupted operation. Semantic view metadata loading can require authentication before Explore renders, so that path displays the authorization prompt before loading the editor.
The change also preserves user identity in asynchronous query execution and partitions authenticated semantic-view caches by user.
A database migration adds the storage access classification. Downgrading permanently deletes backend-only secrets to prevent them from becoming browser-accessible; this behavior is documented in
UPDATING.md.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before: opening a semantic-view chart without credentials could show a permission error and “Missing datasource,” with no way to authorize access.
After: Superset displays an OAuth2 authorization link and reloads the chart after authorization completes.
Note that the behavior in Explore is slightly different with semantic views compared to datasets: with a dataset that needs OAuth2, Explore will render with metrics/columns/controls, but the dataset component will ask for auth. For semantic views, Explore doesn't know what metrics and columns exist until the user authenticates, since that information lives in the semantic layer, not in Superset. Because of this, the whole Explore UI is replaced by the authentication prompt.
TESTING INSTRUCTIONS
I wrote the specification for a generic RESTful semantic layer API at https://github.com/betodealmeida/sl-rest-api. The API is a 1:1 mapping of the Superset semantic layer Python API to JSON requests. In addition to the spec itself, the repo has:
I'm also in the process of implementing the API in DataJunction, so that Superset can be used with it: DataJunction/dj#2661
A simple way of testing this PR:
demo-clientdemo-secretADDITIONAL INFORMATION