Skip to content
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

Check selected Cloud Volumes for RBAC #770

Merged
merged 1 commit into from
Mar 31, 2017

Conversation

romanblanco
Copy link
Member

Storage -> Block Storage -> Volumes

@miq-bot miq-bot added the wip label Mar 22, 2017
@romanblanco
Copy link
Member Author

romanblanco commented Mar 22, 2017

I'm not sure how to test this, is there a way to restrict some Cloud Volumes to some users?

@miq-bot
Copy link
Member

miq-bot commented Mar 22, 2017

Checked commit romanblanco@451475a with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks good. 🏆

@romanblanco
Copy link
Member Author

Also:

It seems strange to me, that there is Unauthorized exception handling in cloud_volume_controller.rb:

  459         begin                                                                                                                   
  460           valid_delete = volume.validate_delete_volume                                                                          
  461           if valid_delete[:available]                                                                                           
  462             volumes_to_delete.push(volume)                                                                                      
  463           else                                                                                                                  
  464             add_flash(_("Couldn't initiate deletion of %{model} \"%{name}\": %{details}") % {                                   
  465               :model   => ui_lookup(:table => 'cloud_volume'),                                                                  
  466               :name    => volume.name,                                                                                          
  467               :details => valid_delete[:message]}, :error)                                                                      
  468           end                                                                                                                   
  469         rescue Excon::Error::Unauthorized => e                                                                                  
  470           add_flash(_("Couldn't initiate deletion of %{model} \"%{name}\": %{details}") % {                                     
  471             :model   => ui_lookup(:table => 'cloud_volume'),                                                                    
  472             :name    => volume.name,                                                                                            
  473             :details => e}, :error)                                                                                             
  474         end    

when the validate_delete_volume method is only checking for provider status:

 45   def validate_delete_volume                                                                                                      
 46     msg = validate_volume                                                                                                         
 47     return {:available => msg[:available], :message => msg[:message]} unless msg[:available]                                      
 48     if with_provider_object(&:status) == "in-use"                                                                                 
 49       return validation_failed("Create Volume", "Can't delete volume that is in use.")                                            
 50     end                                                                                                                           
 51     {:available => true, :message => nil}                                                                                         
 52   end 

maybe I'm missing something, but it seems to me that the code can never get to the exception. ❓

@ZitaNemeckova
Copy link
Contributor

@romanblanco I'm pretty sure I was getting Excon::Error::Unauthorized exception at some point. But I agree that checking for authorization in validate_delete_volume would be nicer.

@romanblanco romanblanco changed the title [WIP] Check selected Cloud Volumes for RBAC Check selected Cloud Volumes for RBAC Mar 23, 2017
@miq-bot miq-bot removed the wip label Mar 23, 2017
@martinpovolny
Copy link
Member

This is probably a question for the OpenStackers. @mansam, @tzumainn. If I remember correctly they used to call the OpenStack API directly so the exception handling might be a remnant of that.

@romanblanco
Copy link
Member Author

@martinpovolny it's not remnant of that i think, it was added by @ZitaNemeckova in ManageIQ/manageiq@6ada628, but I believe I can remove it now.

@martinpovolny martinpovolny merged commit 690aed4 into ManageIQ:master Mar 31, 2017
@martinpovolny martinpovolny added this to the Sprint 58 Ending Apr 10, 2017 milestone Mar 31, 2017
@romanblanco romanblanco deleted the fix_rbac_cloud_volume branch March 31, 2017 08:30
simaishi pushed a commit that referenced this pull request Mar 31, 2017
Check selected Cloud Volumes for RBAC
(cherry picked from commit 690aed4)
@simaishi
Copy link
Contributor

Fine backport details:

$ git log -1
commit c1fdd88bfc51d59af9f43bc9e35bf560273c832d
Author: Martin Povolny <[email protected]>
Date:   Fri Mar 31 09:08:31 2017 +0200

    Merge pull request #770 from romanblanco/fix_rbac_cloud_volume
    
    Check selected Cloud Volumes for RBAC
    (cherry picked from commit 690aed4c06f46eed1509e720b1f7d9ba99ca8eff)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants