-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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(sqllab): remove link to sqllab if missing perms #22566
Conversation
0acf6fd
to
f742039
Compare
Codecov Report
@@ Coverage Diff @@
## master #22566 +/- ##
==========================================
+ Coverage 66.91% 67.02% +0.10%
==========================================
Files 1851 1859 +8
Lines 70709 71046 +337
Branches 7766 7771 +5
==========================================
+ Hits 47316 47619 +303
- Misses 21371 21404 +33
- Partials 2022 2023 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
/testenv up |
@zhaoyongjie Ephemeral environment spinning up at http://18.236.102.188:8080. Credentials are |
f742039
to
2a32627
Compare
2a32627
to
aaf3a71
Compare
/testenv up |
@villebro Ephemeral environment spinning up at http://34.219.163.111:8080. Credentials are |
superset/views/core.py
Outdated
or "sql_lab" in (role.name for role in security_manager.get_user_roles()) | ||
): | ||
flash(__("You do not have access to SQL Lab"), "danger") | ||
return redirect("/") |
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 probably makes more sense to fix on security manager, where all roles are created
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.
Good idea, I'll move it over 👍
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.
Frontend part looks great to me!
/testenv up |
@villebro Ephemeral environment spinning up at http://54.187.147.88:8080. Credentials are |
import { | ||
canUserAccessSqlLab, | ||
canUserEditDashboard, | ||
isUserAdmin, | ||
} from './permissionUtils'; |
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.
TODO: these should probably be moved to a general util outside the dashboard section, but refactoring it seems outside the scope of this PR
8a4cc4b
to
b91afd6
Compare
4589668
to
318529e
Compare
@@ -157,12 +157,12 @@ def test_get_list_saved_query_gamma(self): | |||
""" | |||
Saved Query API: Test get list saved query | |||
""" | |||
gamma = self.get_user("gamma") | |||
user = self.get_user("gamma_sqllab") |
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.
The gamma_sqllab
test user has both Gamma
and sql_lab
roles.
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.
did we had to change this user for the tests to pass?
/testenv up |
@villebro Ephemeral environment spinning up at http://35.89.82.98:8080. Credentials are |
FYI, I've recreated the ephemeral environment with the same test users as previously (same UID/PWD):
The users that have access to SQL Lab also have a saved query which one should be able to see from the Welcome page |
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.
@@ -157,12 +157,12 @@ def test_get_list_saved_query_gamma(self): | |||
""" | |||
Saved Query API: Test get list saved query | |||
""" | |||
gamma = self.get_user("gamma") | |||
user = self.get_user("gamma_sqllab") |
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.
did we had to change this user for the tests to pass?
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.
Re-tested after latest changes, LGTM!
Ephemeral environment shutdown and build artifacts deleted. |
SUMMARY
Currently the "View in SQL Lab" option is available in the Dataset menu in Explore view even when the user doesn't belong to the
sql_lab
role. In addition, SQL Lab is accessible (albeit doesn't work properly) when the necessary permissions are missing.This PR does the following:
sql_lab
roleAFTER
Now when a user that doesn't have the
sql_lab
role will no longer see the "View in SQL Lab" menu item:For admin and users with
sql_lab
role the menu is unchanged:When attempting to access SQL Lab without correct perms via a direct URL, the user gets redirected to the welcome page with an error toast. Also, the welcome page doesn't show the "Saved Queries" section if the user doesn't belong to the
sql_lab
role (we could optionally check the specific perms for saved queries, but maybe we can do that in a follow up if that's really needed):Note that due to the way we're currently caching bootstrap data, toasts don't always appear correctly (they can appear delayed or not get cleared after displaying). I will follow up separately to fix this.
TESTING INSTRUCTIONS
For testing instructions, please see the following comment in this PR: #22566 (comment)
ADDITIONAL INFORMATION