Skip to content

Commit

Permalink
Merge pull request #127 from isimluk/92-with-specs
Browse files Browse the repository at this point in the history
Fix for #13291, Tenant admin can escalate rights
  • Loading branch information
martinpovolny authored Jan 11, 2017
2 parents c6ae722 + 8e67251 commit c6b67f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions app/controllers/ops_controller/ops_rbac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,8 @@ def rbac_user_set_form_vars
:password => @user.password,
:verify => @user.password)
end
# load all user groups
@edit[:groups] = MiqGroup.non_tenant_groups_in_my_region.sort_by { |g| g.description.downcase }.collect { |g| [g.description, g.id] }
# load all user groups, filter available for tenant
@edit[:groups] = Rbac.filtered(MiqGroup.non_tenant_groups_in_my_region).sort_by { |g| g.description.downcase }.collect { |g| [g.description, g.id] }
# store current state of the new users information
@edit[:current] = copy_hash(@edit[:new])
end
Expand Down Expand Up @@ -1020,6 +1020,9 @@ def rbac_user_validate?
if @edit[:new][:group].blank?
add_flash(_("A User must be assigned to a Group"), :error)
valid = false
elsif Rbac.filtered([MiqGroup.find_by_id(@edit[:new][:group])].compact).empty?
add_flash(_("A User must be assigned to an allowed Group"), :error)
valid = false
end
valid
end
Expand Down
5 changes: 3 additions & 2 deletions spec/controllers/ops_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
end

describe 'rbac_user_edit' do
let(:group) { FactoryGirl.create(:miq_group) }
before do
ApplicationController.handle_exceptions = true
end
Expand All @@ -58,7 +59,7 @@
:name => 'test7',
:userid => 'test7',
:email => '[email protected]',
:group => 'test_group',
:group => group.id,
:password => 'test7',
:verify => 'test7',
}
Expand All @@ -75,7 +76,7 @@
:name => 'test7',
:userid => 'test7',
:email => '[email protected]',
:group => 'test_group',
:group => group.id,
:password => 'test7',
:verify => 'test8',
}
Expand Down

0 comments on commit c6b67f5

Please sign in to comment.