Project

General

Profile

Actions

Bug #9793

closed

querying /api/v2/fact_values with a user with view rights doesn't work

Added by Jan van Lith about 9 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Category:
API
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

When having a user with view_facts filter applied it doesn't get any result when querying the api v2.

Querying the v1 with the same user works


Related issues 1 (0 open1 closed)

Has duplicate Foreman - Bug #10816: API v2 does not return factsDuplicate06/15/2015Actions
Actions #1

Updated by Dominic Cleal about 9 years ago

  • Category set to API
Actions #2

Updated by Raul Gonzalez about 9 years ago

I am facing the exact same issue:
curl -ksH "Content-Type:application/json" -H "Accept:application/json" -H "Accept:version=1" -u foremanapi:XXXXXXXXXXXX https://foreman.dom.priv/api/hosts/623/facts | json_reformat

{
    "vme-a015.dedi.priv": {
        "macaddress": "00:1D:D8:B7:1D:FA",
        "bios_smbversion": "090004 ",
        "processorcount": "1",
        "physicalprocessorcount": "1",
        "uptime_days": "1",
        "commvault_version_instance002": "10.0.0(BUILD116)",
        "uptime_seconds": "115632",
        "facterversion": "1.7.5",
        "rubyversion": "1.9.3",
        "uptime": "1 day",
        "bios_releasedate": "20090319",
        "os_installdate": "20140116",
        "uuid": "220AA073-AB95-4AAD-8A9B-37A28AA65691",
        "netmask": "255.255.254.0",
        "uptime_hours": "32",
        "puppetversion": "3.5.1",
        "clientversion": "3.5.1",
        "memorytotal": "4.00 GB",
        "memorysize": "4.00 GB",
        "memorysize_mb": "4095.55",
        "os_maj_version": "6",
        "memoryfree_mb": "600.04",
        "memoryfree": "600.04 MB",
        "kernelmajversion": "6.1",
        "kernelversion": "6.1.7601",
        "operatingsystemrelease": "6.1.7601" 
    }
}

This retuns all facts but with v2:

curl -ksH "Content-Type:application/json" -H "Accept:application/json" -H "Accept:version=2" -u foremanapi:XXXXXXXXXXXXX https://foreman.dom.priv/api/hosts/623/facts | json_reformat

{
    "total": 0,
    "subtotal": 0,
    "page": 1,
    "per_page": 30,
    "search": " host = 623",
    "sort": {
        "by": null,
        "order": null
    },
    "results": {

    }
}

setting foremanapi as a admin v2 works as expected.

Actions #3

Updated by Martin Jackson almost 9 years ago

This also seems to affect "hammer host facts", and is still present in 1.8.0:

mjackson@mithrandir ~ % hammer host list
---|-------------------------|---------------------|------------------------------------------|---------------|------------------
ID | NAME                    | OPERATING SYSTEM    | HOST GROUP                               | IP            | MAC              
---|-------------------------|---------------------|------------------------------------------|---------------|------------------
8  | anduril.minas.tirith    | Debian 8.0          | base/monitored/hypervisor/centralstorage |               | e0:69:95:d2:09:92
7  | balin.minas.tirith      | Debian 8.0          | base/monitored/netmgr                    | 192.168.5.20  | 52:54:00:d5:db:46
13 | barliman.minas.tirith   | Debian 8.0          | base/monitored/mailhub                   | 192.168.5.23  | 52:54:00:12:47:60
2  | bifur.minas.tirith      | Debian 8.0          | minimal/mco                              | 192.168.5.103 | 52:54:00:fb:6b:88
6  | bilbo.minas.tirith      | Debian 8.0          | base/monitored/adminstation              | 192.168.4.106 | 52:54:00:e4:81:eb
26 | bofur.minas.tirith      | Debian 8.0          | base/monitored                           | 192.168.5.91  | 52:54:00:52:b4:13
22 | bombur.minas.tirith     | Ubuntu Vivid Vervet | base/monitored                           | 192.168.5.83  | 52:54:00:51:31:3e
1  | cirdan.minas.tirith     | CentOS 7.1          | base/monitored/foreman                   | 192.168.5.25  | 52:54:00:f3:ef:05
19 | dwalin.minas.tirith     | OpenSuSE 13.2       | null                                     | 192.168.5.95  | 52:54:00:cf:c6:31
17 | fili.minas.tirith       | FreeBSD 10.1        | null                                     | 192.168.5.64  | 52:54:00:94:3a:85
4  | ftfw-a.minas.tirith     | Debian 8.0          | base/monitored/ftfirewall                |               |                  
5  | ftfw-b.minas.tirith     | Debian 8.0          | base/monitored/ftfirewall                | 192.168.4.3   | 52:54:00:b3:ee:a0
3  | gimli.minas.tirith      | Debian 8.0          | minimal/mco                              | 192.168.5.93  | 52:54:00:25:4e:0a
9  | glamdring.minas.tirith  | Debian 8.0          | base/monitored/hypervisor                |               | 90:2b:34:52:54:b3
16 | kili.minas.tirith       | CentOS 7.1          | base/monitored                           | 192.168.5.80  | 52:54:00:27:f7:45
24 | mithrandir.minas.tirith | Debian 8.0          | base/monitored/laptop                    |               | c4:54:44:7d:93:19
20 | narsil.minas.tirith     | Debian 8.0          | base/monitored/hypervisor/workstation    |               | 00:1d:09:8f:b2:56
12 | narvi.minas.tirith      | Debian 8.0          | base/monitored/devhost                   | 192.168.5.22  | 52:54:00:f4:e9:0b
21 | nori.minas.tirith       | Archlinux 1.0       | null                                     | 192.168.5.106 | 52:54:00:9d:63:a6
10 | orcrist.minas.tirith    | Debian 8.0          | base/monitored/hypervisor                |               | 00:1e:c9:50:be:78
18 | ori.minas.tirith        | Fedora 21           | base/monitored                           | 192.168.5.94  | 52:54:00:a4:bb:bb
25 | pippin.minas.tirith     | Debian 8.0          | base/monitored/laptop                    | 192.168.4.114 | 00:1e:64:32:b2:46
23 | radagast.minas.tirith   | Debian 8.0          | base/monitored/dataserver                | 192.168.5.21  | 52:54:00:bb:b9:c7
11 | sting.minas.tirith      | Debian 8.0          | base/monitored/hypervisor                |               | 00:1e:8c:df:dd:47
14 | thorin.minas.tirith     | Debian 8.0          | base/monitored/mediaserver               | 192.168.4.9   | 52:54:00:a7:7d:6a
---|-------------------------|---------------------|------------------------------------------|---------------|------------------
mjackson@mithrandir ~ % hammer host facts --name anduril.minas.tirith
-----|------
FACT | VALUE
-----|------

Strangely; I can get it to work with Chrome's postman tool (using APIv2), but neither ruby rest-client nor python requests. I suspect that some header or cookie may be needed?

Meanwhile, the APIv1 workaround also still works.

Actions #4

Updated by Pedro Cachaldora almost 9 years ago

Same problem in Foreman 1.8.0

Actions #5

Updated by Dominic Cleal almost 9 years ago

  • Has duplicate Bug #10816: API v2 does not return facts added
Actions #6

Updated by Daniel Lobato Garcia almost 9 years ago

  • Assignee set to Daniel Lobato Garcia
Actions #7

Updated by The Foreman Bot almost 9 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2467 added
  • Pull request deleted ()
Actions #8

Updated by Daniel Lobato Garcia almost 9 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #9

Updated by Marek Hulán almost 9 years ago

  • translation missing: en.field_release set to 35
Actions

Also available in: Atom PDF