fix(ui): Disable ability to export data when user does not have the correct permission#28429
fix(ui): Disable ability to export data when user does not have the correct permission#28429rusackas merged 9 commits intoapache:masterfrom edjannoo:fix/disable_downloads
Conversation
…csv on Superset' is not allowed
… results when 'can_export_csv on SQLLab' is not allowed
…perset' is not allowed
…o clipboard (new since 2.1)
|
Approving CI 🤞 |
|
@rusackas Any chance I could get this PR reviewed please? I've had to update it a couple of times after merge conflicts have arisen due to other change. I'm worried that it will be hard to keep it up to date if any more wide ranging changes get merged. |
rusackas
left a comment
There was a problem hiding this comment.
Thanks for your patience. I was hoping to get a second opinion on this since it messes with permissions and that always makes me nervous, personally ;)
Running CI again, hopefully it passes. I think this looks OK to me in general, so I'll go ahead and approve it. I would still like a second opinion from @dpgaspar or @villebro if possible.
My only other (minor, probably non-blocking) thought is that we're now using can_export_csv and can_csv to control a lot more than csv. From a permissions standpoint, that seems reasonable. From a naming standpoint, I can't help but wonder if there's something more... inclusive. Maybe can_export_data or something similar. But... making that kind of change might be considered a breaking change and would have to wait for 5.0.
villebro
left a comment
There was a problem hiding this comment.
I agree with the changes here, and I'm super impressed with the general quality of the PR, especially the awesome tests ❤️ LGTM, but let's do a quick round of eph env testing before merging. I'm not at my laptop right now, but I should be able to do testing within the next 24 hours.
| import ExploreResultsButton from '../ExploreResultsButton'; | ||
| import HighlightedSql from '../HighlightedSql'; | ||
| import QueryStateLabel from '../QueryStateLabel'; | ||
| import { findPermission } from '../../../utils/findPermission'; |
There was a problem hiding this comment.
nit: I feel three steps down would look better by just starting from src/...
Thanks for reviewing. I also felt that the permission name feels wrong however the same permission is already used for controlling export to Excel so it's a logical extension of that. Perhaps this will be improved by the new permission model I saw a SIP for? |
|
Hello, running Superset 4.0.2 version and still observing COPY TO CLIPBOARD button. Steps to reproduce:
So looks like it has half functionality described, and permission is not applied to both download to CSV and copy to clipboard functions. p.s. also cannot find this: #28429 PR in the CHANGELOG files even though the code was merged and present in 4.0.2 version. Is that intentional ? TIA |
|
Hello again, just tested same in Superset 4.1.0rc2 and this issue is no longer present. Steps to reproduce (tested on local superset instance deployed with docker-compose):
So 🤞 for the successful 4.1.0 version release :) TIA |
SUMMARY
Disables
Export to .JSONandExport to Excelfrom theDownloadsubmenu when viewing a chart unless the user hascan_csv on Supersetpermission. The same permission is already required forDownload to .CSV.Disables
DOWNLOAD TO CSVandCOPY TO CLIPBOARDfrom the query results pane in SQL Lab unless the user hascan_export_csv on SQLLabpermission. The permission should be applied to both download to CSV and copy to clipboard functions since both are means of exporting data.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Verify that a user with the
can_csv on Supersetpermission (for example a user with theAlpharole) is able to export as CSV, JSON and Excel when viewing a chart. Verify that a user without that permission is not able to do any of those.Verify that a user with the
can_export_csv on SQLLabpemission (for example a user with thesql_labrole) is able to download to CSV or copy to clipboard from the SQL Lab query results pane. Verify that a user without that permission is not able to do either of those.ADDITIONAL INFORMATION