-
Notifications
You must be signed in to change notification settings - Fork 898
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
Add tenant scoping for resources of performance reports in RBAC #14095
Add tenant scoping for resources of performance reports in RBAC #14095
Conversation
6a36e31
to
03569d2
Compare
03569d2
to
7013bfa
Compare
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 is great.
Will help right across the board
have been working so hard on consolidating that set logic, so would prefer to have just a single point where set logic is performed
lib/rbac/filterer.rb
Outdated
@@ -445,7 +445,12 @@ def scope_targets(klass, scope, rbac_filters, user, miq_group) | |||
# if subclasses of MetricRollup or Metric, use the associated | |||
# model to derive permissions from | |||
associated_class = rbac_class(scope) | |||
if associated_class.respond_to?(:scope_by_tenant?) && associated_class.scope_by_tenant? |
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.
if associated_class.try(:scope_by_tenant?)
lib/rbac/filterer.rb
Outdated
@@ -445,7 +445,12 @@ def scope_targets(klass, scope, rbac_filters, user, miq_group) | |||
# if subclasses of MetricRollup or Metric, use the associated | |||
# model to derive permissions from | |||
associated_class = rbac_class(scope) | |||
if associated_class.respond_to?(:scope_by_tenant?) && associated_class.scope_by_tenant? | |||
scope_associated_ids = scope_to_tenant(associated_class, user, miq_group).ids |
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.
please leave this as a scope and rename to something like tenant_filter
lib/rbac/filterer.rb
Outdated
filtered_ids = calc_filtered_ids(associated_class, rbac_filters, user, miq_group) | ||
filtered_ids = [scope_associated_ids, filtered_ids].compact.flatten |
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.
please pass this scope into filtered_ids
.
Trying hard to keep that set logic in there so we can move to the database in the future.
(all but one of those params are currently scopes)
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 cannot pass it to the first parameter because scope tenant condition in scope_tenant_filter
would be lost, so I added it as new parameter.
Is this ok for now ?
For now we need to make 1 query to determine scope_tenant_filter.ids
, in follow up PR I would like to look if it is possible to merge it to main scope
and skip this query.
thanks for review @kbrock
7013bfa
to
4521c0b
Compare
lib/rbac/filterer.rb
Outdated
klass = scope.respond_to?(:klass) ? scope.klass : scope | ||
u_filtered_ids = pluck_ids(get_self_service_objects(user, miq_group, klass)) | ||
b_filtered_ids = get_belongsto_filter_object_ids(klass, user_filters['belongsto']) | ||
m_filtered_ids = pluck_ids(get_managed_filter_object_ids(scope, user_filters['managed'])) | ||
d_filtered_ids = pluck_ids(matches_via_descendants(rbac_class(klass), user_filters['match_via_descendants'], | ||
:user => user, :miq_group => miq_group)) | ||
|
||
combine_filtered_ids(u_filtered_ids, b_filtered_ids, m_filtered_ids, d_filtered_ids) | ||
combine_filtered_ids(u_filtered_ids, b_filtered_ids, m_filtered_ids, d_filtered_ids) || |
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.
Would it be difficult to get this into combine_filtered_ids
?
(just say too difficult if so. I can fix when I'm going in there to convert to a sql scope from raw ids)
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.
yes done 👍
https://github.com/ManageIQ/manageiq/pull/14095/files#diff-8d948055de14ced0e63abf9637a9a788R383 this maybe look sort complex but there is needed previous values it returns. (nil should not be confused with an empty field)
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.
Looking good. just the one question
also, the tenant_scope can probably be always passed in, even if it is a nil. I'm guessing we probably need to change our code to always have a tenant scope (unless this makes testing harder - then leave the nil
as is)
206f5db
to
28298d3
Compare
What do you mean by this ? Do you mean somehow convert RBAC to sequence of rules or DSL ? |
28298d3
to
6b47b81
Compare
@lpichler example Current vm RBAC
Since sql's strength is set logic (e.g. using Was hoping we could keep the set logic in the But if that doesn't work for you, we can move it into that method when we are fixing step 2. |
- visible ids of resource class are determined for tenant - those ids are used for filtering as well
6b47b81
to
dce0e5d
Compare
Checked commits lpichler/manageiq@39d0469~...dce0e5d with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
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.
Thanks. this looks great
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.
…omance_reports Add tenant scoping for resources of performance reports in RBAC (cherry picked from commit f46d363) https://bugzilla.redhat.com/show_bug.cgi?id=1431168
Euwe backport details:
|
Backported to Darga via #14308 |
…for_perfomance_reports Add tenant scoping for resources of performance reports in RBAC (cherry picked from commit f46d363) https://bugzilla.redhat.com/show_bug.cgi?id=1431168
second part of
https://bugzilla.redhat.com/show_bug.cgi?id=1418961
first part (#14041)
RBAC is supported for
MetricRollups
class and his childs alsoMetricRollup#resource
but there is no support also for tenant scoping, so this PR is adding it:cc @kbrock
@miq-bot assign @gtanzillo