-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(dashboard): draft dashboards should be viewable #14207
Conversation
10d7c27
to
695e151
Compare
@@ -105,6 +108,7 @@ class DashboardRestApi(BaseSupersetModelRestApi): | |||
list_columns = [ | |||
"id", | |||
"published", | |||
"status", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A-Z
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll approve this. Frontend code looks good. Looks like the python unit test needs to be updated.
2c5b8fb
to
e8520d4
Compare
@@ -57,16 +58,16 @@ class DashboardFavoriteFilter(BaseFavoriteFilter): | |||
model = Dashboard | |||
|
|||
|
|||
class DashboardFilter(BaseFilter): | |||
class DashboardAccessFilter(BaseFilter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 more semantic, I was always a bit confused what DashboardFilter
was really doing
e8520d4
to
aaf88e2
Compare
db.session.query(Dashboard) | ||
.filter(id_or_slug_filter(id_or_slug)) | ||
.outerjoin(Slice, Dashboard.slices) | ||
.outerjoin(Slice.table) | ||
.outerjoin(Dashboard.owners) | ||
.outerjoin(Dashboard.roles) | ||
) | ||
# Apply dashboard base filters | ||
query = DashboardFilter("id", SQLAInterface(Dashboard, db.session)).apply( | ||
query, None | ||
) | ||
dashboard = query.one_or_none() | ||
dashboard = Dashboard.get(id_or_slug) | ||
if not dashboard: | ||
raise DashboardNotFoundError() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this exposes a new security risk: it would be easy to know if a dashboard exists or not even if user doesn't have access to begin with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that's just the same as before right? The goal of this PR is to revert the behavior of non-owners having access to draft dashboards. Whether this is a risk that worth further actions is another topic.
I wonder if it would be more appropriate to change Thank you for addressing this, by the way. There have been a couple of regressions due to this so I've made a ticket for myself to write some e2e tests around drafts. |
d577a74
to
0386f47
Compare
Codecov Report
@@ Coverage Diff @@
## master #14207 +/- ##
==========================================
- Coverage 76.74% 76.73% -0.01%
==========================================
Files 952 954 +2
Lines 48043 48055 +12
Branches 5978 5972 -6
==========================================
+ Hits 36870 36877 +7
- Misses 10971 10976 +5
Partials 202 202
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@suddjian previously the list view already filters out draft dashboards for non-owners/admins, so as long as we use |
bfb4a73
to
7a9036e
Compare
7a9036e
to
6496f89
Compare
uri = DASHBOARD_API_URL_FORMAT.format(dashboard.id) | ||
rv = self.client.get(uri) | ||
self.assert404(rv) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@suddjian @pkdotson @amitmiran137 I finally fixed all the test cases but had to change some expected values because the behavior of the API endpoints has changed (what returns 404 before would now return 200---like it does before for the Dashboard page). Would appreciate an extra pair of eyes if you have time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks for the fix!
@@ -24,3 +24,8 @@ export type DashboardObject = { | |||
position?: string; | |||
metadata?: string; | |||
}; | |||
|
|||
export enum DashboardStatus { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yay, new types!
* fix(dashboard): draft dashboards should have open access * Remove a duplicate test
SUMMARY
Temp fix for #14175 with some light refactoring:
DashboardFilter
toDashboardAccessFilter
to be more specific---we should do the same for other filters too (ChartFilter
,DatasetFilter
, etc)get_by_id_or_slug
in Dashboard DAO with the same logics used previously by the dashboard view.status
to replacepublished
, butpublished
is kept for backward compatibility.TODO: we should replace the boolean column
published
with a enum columnstatus
to support the long-term solution mentioned in #14175 (comment)BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before
Gamma user visiting a draft dashboard throws unexpected JS error
After
Users with
Superset -> dashboard
view access should be able to open a draft dashboard created by other users.But they won't be able to view it in the dashboard list.
TEST PLAN
CI
For manual verification, see #14175 for details.
ADDITIONAL INFORMATION