-
Notifications
You must be signed in to change notification settings - Fork 899
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 my_settings_view product feature for the My Settings page #22779
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -628,17 +628,35 @@ def scope_to_cloud_tenant(scope, user, miq_group) | |
def scope_for_user_role_group(klass, scope, miq_group, user, managed_filters) | ||
user_or_group = miq_group || user | ||
|
||
if user_or_group.try!(:self_service?) && MiqUserRole != klass | ||
if user_or_group.try!(:self_service?) && klass != MiqUserRole | ||
scope.where(:id => klass == User ? user.id : miq_group.id) | ||
else | ||
role = user_or_group.miq_user_role | ||
# hide creating admin group / roles from non-super administrators | ||
|
||
# Exclude users/groups/roles tied to the super admin user if the current user isn't also | ||
# a super admin user. This prevents a tenant admin from creating a super admin and then | ||
# escalating privileges. | ||
unless role&.super_admin_user? | ||
scope = scope.with_roles_excluding(MiqProductFeature::SUPER_ADMIN_FEATURE) | ||
# In the case that the user is not currently in a super admin group, but can _become_ | ||
# a super admin by virtue of being in multiple groups, then they will be filtered by | ||
# with_roles_excluding. The allowed_ids option ensures the user can still see themselves. | ||
Comment on lines
+640
to
+642
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea, this edge case is only for when an admin changes to another group to determine what that other group can see. (to view what one of their users can see) Such an edge case, but an important one to help admins understand the security implications |
||
# | ||
# TODO: Determine if this same logic should apply to MiqUserRole as well | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we would want role here to prevent a tenant admin from creating a group with super admin privs? i.e.: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not really sure here. I need to allow the user themselves when it gets filtered out, but if a currently-non-admin user can be a super-admin, does that mean they should or shouldn't be able to see the super admin role? I'm just not sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the goal here is to prevent a tenant admin from creating a super user. (that they then know the password so they can escalate privileges. You can do that via using a super group, or creating a group and assigning a super role |
||
with_roles_excluding_options = | ||
if klass == User | ||
{:allowed_ids => user.id} | ||
elsif klass == MiqGroup | ||
{:allowed_ids => miq_group.id} | ||
else | ||
{} | ||
end | ||
|
||
scope = scope.with_roles_excluding(MiqProductFeature::SUPER_ADMIN_FEATURE, **with_roles_excluding_options) | ||
end | ||
|
||
if MiqUserRole != klass | ||
if klass != MiqUserRole | ||
filtered_ids = pluck_ids(get_managed_filter_object_ids(scope, managed_filters)) | ||
|
||
# Non tenant admins can only see their own groups. Note - a super admin is also a tenant admin | ||
scope = scope.with_groups(user.miq_group_ids) unless role&.tenant_admin_user? | ||
end | ||
|
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.
Note to self - we might want a database migration adding this to any existing role that has one of the other my_settings permissions.