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

Fixes #5261: Adds CRUD permissions for Products and Repositories. #4017

Merged
merged 1 commit into from
May 1, 2014

Conversation

ehelms
Copy link
Member

@ehelms ehelms commented Apr 29, 2014

No description provided.

@@ -142,8 +142,7 @@ def available_puppet_modules
param :id, :identifier, :desc => "content view numeric identifier", :required => true
def available_puppet_module_names
current_names = @view.content_view_puppet_modules.map(&:name).reject{|p| p.nil?}
repo_ids = @view.organization.library.puppet_repositories.readable(
@view.organization.library).pluck(:pulp_id)
repo_ids = @view.organization.library.puppet_repositories.pluck(:pulp_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensuring these are readable is no longer required here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was already being handled here -

Repository.readable(self).where(:content_type => Katello::Repository::PUPPET_TYPE)

@parthaa
Copy link
Contributor

parthaa commented Apr 29, 2014

@ehelms -> Why did ya need a direct mapping between org and product. Considering the mapping was available from the provider ? .. Did you just feel it was cleaner/easier ?

@ehelms
Copy link
Member Author

ehelms commented Apr 29, 2014

@parthaa In order for organization scoping to work with the permissions, the entity needs mapping to the organization directly and given the reduction of provider as an entity, it seemed to make sense that products should be attached to an organization directly.

@waldenraines
Copy link
Contributor

  • Showing/hiding the remove product button seems to be tied to the update product permission (although the actual removal is correctly associated with delete product)
  • I get a 403 when attempting to sync a product unless I am an admin (i.e. even if I have all product permissions): An error occurred saving the Product: User readonly is not allowed to access katello/api/v2/sync/create

@parthaa
Copy link
Contributor

parthaa commented Apr 29, 2014

@ehelms sounds good.. Could you add a foreign key rule or a validation rule that some how maintains the the product and the provider map to the same org...

@ehelms
Copy link
Member Author

ehelms commented Apr 29, 2014

@waldenraines from what page? can you give me a little more of a workflow

@parthaa
Copy link
Contributor

parthaa commented Apr 29, 2014

Actually ignore the comment.. I see that in the plan for product create you are ensuring the they are the same...

@parthaa
Copy link
Contributor

parthaa commented Apr 29, 2014

No more issues with this PR from me.. ACK once @waldenraines is satisfied ...

@waldenraines
Copy link
Contributor

@ehelms sorry, 403 when syncing from the product details page.

@ehelms
Copy link
Member Author

ehelms commented Apr 29, 2014

@waldenraines updated

@ehelms
Copy link
Member Author

ehelms commented Apr 29, 2014

@waldenraines forgot to address the index remove issue, please re-test with latest

deletable_products = @products.deletable
undeletable = @products - deletable_products

deletable_products.each{ |product| product.destroy }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tip: deletable_products.each(&:destroy)

@ehelms
Copy link
Member Author

ehelms commented Apr 30, 2014

@iNecas @pitr-ch updated

@pitr-ch
Copy link
Member

pitr-ch commented Apr 30, 2014

thanks for updating

end

private

def find_products
params.require(:ids)
@products = params[:ids].map { |id| Product.find_by_cp_id!(id) }
@products = Product.where(:cp_id => params[:ids])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking products up by cp_id is very very bad, at least without scoping on organization as well. They are not unique across organizations. Ideally the client would send the actual product id instead of the cp_id, and we should file an issue for that. In the meantime, we should add .where(:organization_id => @organization.id)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll also have to lock these routes and actions down by requiring an organization_id won't we?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, didn't realize that wasn't already available. Feel free leave it as is and file an issue for it. The result could be assignment of sync plans in other orgs!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is already an issue for it - http://projects.theforeman.org/issues/5343

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, i'll bump the priority and assign to 1.5

@jlsherrill
Copy link
Member

APJ pending a story being opened to cover fixing 'content' related items later.

@waldenraines
Copy link
Contributor

APJ from me as well.

@ehelms
Copy link
Member Author

ehelms commented May 1, 2014

[test]

1 similar comment
@ehelms
Copy link
Member Author

ehelms commented May 1, 2014

[test]

ehelms added a commit that referenced this pull request May 1, 2014
Fixes #5261: Adds CRUD permissions for Products and Repositories.
@ehelms ehelms merged commit a587444 into Katello:roles May 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants