Red Hat Bugzilla – Bug 1312916
Some pages return "undefined method `profile=' for nil:NilClass" as non-admin user
Last modified: 2016-07-27 05:02:53 EDT
Description of problem: Some pages and api endpoints throw an error on master Version-Release number of selected component (if applicable): 6.2.0 (Snap1) How reproducible: always Steps to Reproduce: 1. Create a role with a two filters * unlimited 'view_hosts' * 'view_statistics' under '(Miscellaneous)' 2. Create a user with that role 3. * As that user try to fetch: /api/v2/statistics * Try to view applicable errata as that user * Try to view installed packages as that user Expected results: ISE with: | NoMethodError: undefined method `profile=' for nil:NilClass | /opt/theforeman/tfm/root/usr/share/gems/gems/scoped_search-3.2.2/lib/scoped_search/query_builder.rb:38:in `initialize' | /opt/theforeman/tfm/root/usr/share/gems/gems/scoped_search-3.2.2/lib/scoped_search/query_builder.rb:22:in `new' | /opt/theforeman/tfm/root/usr/share/gems/gems/scoped_search-3.2.2/lib/scoped_search/query_builder.rb:22:in `build_query' | /usr/share/foreman/app/services/authorizer.rb:85:in `build_filtered_scope_components' | /usr/share/foreman/app/services/authorizer.rb:49:in `find_collection' | /usr/share/foreman/app/models/concerns/authorizable.rb:21:in `block (2 levels) in <module:Authorizable>' | /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/scoping/named.rb:180:in `call' | /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/scoping/named.rb:180:in `block (2 levels) in scope' | /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/scoping/default.rb:41:in `block in unscoped' | /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/relation.rb:241:in `block in scoping' | /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/scoping.rb:98:in `with_scope' | /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/relation.rb:241:in `scoping' | /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/scoping/default.rb:41:in `unscoped' | /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/scoping/named.rb:180:in `block in scope' | /usr/share/foreman/app/models/concerns/authorizable.rb:66:in `authorized' | /usr/share/foreman/app/models/host.rb:15:in `method_missing' Additional info:
Connecting redmine issue http://projects.theforeman.org/issues/13545 from this bug
Two small caveats, in the UI in order to do: * fetch: /api/v2/statistics The user also needs 'view_statistics' under '(miscellaneous)' in order to: * Try to view applicable errata as that user * Try to view installed packages as that user the user also needs: view_lifecycle_environments, view_content_views, view_organizations, view_products
Upstream bug component is Provisioning Templates
How I verified: * create role with filters mentioned in #0 and #2, add user to role * register satellite to itself w/ sub-man, install katello-agent statistics API is viewable (used curl with newly created user), package list for host is viewable, errata page for host is viewable. No stacks in production.log.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2016:1500