-
Notifications
You must be signed in to change notification settings - Fork 141
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 a set_current_group method for users #176
Conversation
config/api.yml
Outdated
@@ -2779,6 +2779,8 @@ | |||
:identifier: rbac_user_edit | |||
- :name: delete | |||
:identifier: rbac_user_delete | |||
- :name: set_current_group | |||
:identifier: rbac_user_edit |
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.
does this mean if a user does not have that role they cannot change their current group ?
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.
@abellotti yeah, I guess so. I am not sure if users should always be allowed to change their own group or if they need that particular role?
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.
May be easy to verify, in classic UI login as a user without that role but a member of a couple of groups, see if you can change the current group in the upper right hand pull-down. If you can, we'll need to somehow handle that.
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.
@abellotti verified that a user in the classic UI without this edit role is still able to change their group. updated accordingly 👍
With the role identifier removed, we probably need to make sure that the action is only run on the authenticated user, otherwise anyone can change anyone else's group. Can you verify this and add a test pertaining to that ? Thanks. |
As per an update to the api here: ManageIQ/manageiq-api#176
def set_current_group_resource(_type, id, data) | ||
User.current_user.tap do |user| | ||
raise "Can only edit authenticated user's current group" unless user.id == id | ||
group_id = parse_id(data["current_group"], :groups) |
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.
can you use parse_group(data["current_group"]) here ? it support both id/href as well as the identifying attr,i.e. be able to set current group by description.
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.
or maybe the parse_fetch_group we used earlier.
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.
@abellotti can't use parse_fetch_group
because it uses resource_search
. Will update to use parse_group
though
I know everyone is da 🐝, wanted to do a quick status check on this 👶 🙇♀️ ⭕️ |
I think I'm good with this, @jntullo can you take care of the rubocop warning ? Thanks. |
@abellotti the rubocop warning can't be fixed, it is part of the solution to the current issue |
Hmm, can |
The current way of setting a user’s current_group uses resource_search, which encounters some RBAC issues. For example, when a user changes from the super administrator group to the tenant group, they are no longer able to change to the super administrator group even though it is in their MIQ groups because resource_search does not allow them to see the super administrator group. By choosing a group based off of their current miq_groups, it resolves the issue and keeps the ability to change groups consistent with that in the classic-ui. https://bugzilla.redhat.com/show_bug.cgi?id=1467364
Checked commit jntullo@119312c with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 **
app/controllers/api/users_controller.rb
|
Thanks @jntullo for updating this. 👍 |
Add a set_current_group method for users (cherry picked from commit 8f30e9c) https://bugzilla.redhat.com/show_bug.cgi?id=1513191
Gaprindashvili backport details:
|
The current way of setting a user’s
current_group
via edit usesresource_search
, which encounters some RBAC issues. For example, when a user changes from the super administrator group to the tenant group, they are no longer able to switch back even though they belong to the group becauseresource_search
returns a forbidden error. By choosing a group based off of their current miq_groups, it resolves the issue and keeps the ability to change groups consistent with that in the classic-ui.How it works in the classic ui:

The failure present in the SUI before the fix:

The successful API call with

set_current_group
:In addition, with update_attributes! it raises a validation error saying that the superadministrator group is not in their groups, also appears to be due to RBAC. I looked to the classic UI to see how their behavior works, and chose to use
update_attribute
based off of that. Because this is different behavior than a typical edit, I felt that it also deserved a specialized method, thus removing this functionality from edit and moving it toset_current_group
.This is also a unique use case, and did not think it would apply as a collection action, but am open to discussion around that.
https://bugzilla.redhat.com/show_bug.cgi?id=1467364
@miq-bot add_label bug, gaprindashvili/yes
@miq-bot assign @abellotti
cc: @AllenBW