-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
[metric] Exposing security methods for visualizations and query-context #8175
[metric] Exposing security methods for visualizations and query-context #8175
Conversation
8d728bd
to
7683b7c
Compare
I really think we should deprecate restricted metrics as they don't work as expected since the adhoc metrics have been added. Also agree with moving more data-access logic and context to the security manager. |
@mistercrunch are you ok with the security manager having logic like I agree that we should probably deprecate restricted metrics seeing as i) ad-hoc metrics completely bypass the restrictedness, and ii) there’s currently no check for SQL datasources. Do you think it best if I provide the change to deprecate restricted metrics in this PR or a followup PR? |
The idea of The only concern is whether the BaseViz interface is settled enough to expose externally through SecurityManager. There's another underlying issue I'd like to fix, it's the fact that Also we should clarify if these security assertions call each other or, the view calls them individually/sequentially. It works either way, but what's important is having something super intuitive and readable. Currently there's quite a bit of indirection (the decorator with the callback + a complex method hierarchy) and it's hard to reason about and easy to eff this up and introduce some regression. Knowing all this, what we want to accomplish:
I'm not sure how to roll this out best, but a chain of small PRs is probably best. About restricted metrics, you could start partially deprecating here by not trying to migrate the code, idk how involved deprecating the feature will be, but shouldn't be too hard. |
I was curious to give deprecation of restricted metrics a shot and it took me ~15 minutes to get to this draft: #8197 |
I merged the PR deprecating |
Thanks @mistercrunch. I’ll update the logic in this PR. I agree that the security manager is overly complex and will try to simplify where possible. |
5ffa99c
to
5fc3d7d
Compare
5fc3d7d
to
ca30ca4
Compare
@mistercrunch thanks for deprecating the restricted metrics (as a side note I wonder if there should be another migration to remove all the obsolete I've updated the PR which removes the now obsolete metric checks. Are you still supportive of having the:
methods which now have the same behavior as the datasource access but simply provide more context, i.e., the fully defined current context, if a custom security manager would like to override. Let me know how best to proceed. |
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
@mistercrunch could you take another look at this? |
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
Not a dealbreaker but caution around having external code (in your security manager) around BaseViz
as it's not guaranteed it will stay the same in the future.
Noted @mistercrunch. |
CATEGORY
Choose one
SUMMARY
For both the Druid and SQLA connectors metrics can be restricted (via themetric_access
permission) however there were not really any security checks associated with this. For the Druid connector there was a check to see if restricted metrics were being used at query time (though this can be pushed higher in the stack to the views given that the Druid REST API doesn't support SQL).I realize that with the advent of ad-hoc metrics the notion of restricted metrics is probably somewhat obsoletebut there seems to be merit in having the security manager be more context aware from a permission standpoint for theexplore_json
,slice_json
, orv1/query
routes where rather than checking whether the user has access to the datasource the check should be at the visualization or query context level (higher fidelity).This PR adds a couple of more context aware (higher fidelity) public methods to the security manager:
assert_query_context_permission
assert_viz_permission
replacing calls to
assert_datasource_permission
where appropriate.TEST PLAN
Added unit tests.
ADDITIONAL INFORMATION
REVIEWERS
to: @betodealmeida @DiggidyDave @michellethomas @mistercrunch @villebro