Project

General

Profile

Bug #24056

Permissions fail when connected to Facets

Added by Partha Aji 6 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Users
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Consider the following steps
  1. create a role with the following filters -> [ :view_facts, (:view_hosts, :search => "content_view_id = 1")] note I used content_view_id as the search filter for the host. You could use any facet attribute for this.
  2. create a user associated to this role
  3. execute api call
  4. curl -s -u 'apiuser:redhat' -k https://<url>/api/v2/hosts/3/facts

Expected:
Assuming Host with id 3 is associated to cv 1, we should get the facts

Actual:
$ curl -s -u 'apiuser:redhat' -k https://<url>/api/v2/hosts/3/facts
{
  "error": {"message":"Can't join 'Host::Base' to association named 'content_facet'; perhaps you misspelled it?"}
}

Problem here is with this call -> https://github.com/theforeman/foreman/blob/develop/app/services/authorizer.rb#L62

Basically the code does the equivalent of

> FactValue.joins(:host => :content_facet).to_sql
ActiveRecord::ConfigurationError: Can't join 'Host::Base' to association named 'content_facet'; perhaps you misspelled it?

Any facet attribute associated to the host is going to hit this issue.

Associated revisions

Revision 42febfe8 (diff)
Added by Shimon Shtein 3 months ago

Fixes #24056 - Moved facets to Host::Base

History

#1 Updated by Partha Aji 6 months ago

  • Bugzilla link set to 1569395

#2 Updated by The Foreman Bot 6 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5739 added

#3 Updated by Partha Aji 5 months ago

  • Triaged set to No
  • Assignee changed from Partha Aji to Shimon Shtein

#4 Updated by The Foreman Bot 5 months ago

  • Pull request https://github.com/theforeman/foreman/pull/5837 added

#5 Updated by Michael Moll 3 months ago

  • Fixed in Releases 1.20.0 added

#6 Updated by Shimon Shtein 3 months ago

  • Status changed from Ready For Testing to Closed

#7 Updated by Eric Helms 3 months ago

  • Pull request deleted (https://github.com/theforeman/foreman/pull/5739)

#8 Updated by The Foreman Bot 3 months ago

  • Pull request https://github.com/theforeman/foreman/pull/6110 added

#9 Updated by Eric Helms about 1 month ago

  • Pull request deleted (https://github.com/theforeman/foreman/pull/6110)

Also available in: Atom PDF