Bug #5945
closedRole API broken
Description
1.5 changed the Role API format, introducing 'filters' for roles, rather than straight permissions.
In 1.4.2, curl -s -u admin:changeme -k -H "Content-type:application/json" https://localhost/api/roles
returned
{ "name": "Manager", "id": 1, "builtin": 0, "permissions": [ "view_architectures", "create_architecture",<snip>
In 1.5.0, curl -s -u admin:changeme -k -H "Content-type:application/json" https://localhost/api/roles
returns
{"error":{"message":"undefined method `key?' for #<JSON::Ext::Generator::State:0x00000009afb938>"}}
The production.log stack trace is attached.
If I change the API version to 2, curl -s -u admin:changeme -k -H "Content-type:application/json" https://localhost/api/v2/roles
The response is
{
"total": 12,
"subtotal": 12,
"page": 1,
"per_page": 20,
"search": null,
"sort": {
"by": null,
"order": null
},
"results": [{"name":"Manager","id":1,"builtin":0},{"name":"Edit partition tables","id":2,"builtin":0},{"name":"View hosts","id":3,"builtin":0},{"name":"Edit hosts","id":4,"builtin":0},{"name":"Viewer","id":5,"builtin":0},{"name":"Site manager","id":6,"builtin":0},{"name":"Default user","id":7,"builtin":1},{"name":"Anonymous","id":8,"builtin":2},{"name":"Anonymous_admin","id":15,"builtin":0}]
}
Which responds with a group of filters instead of actual permissions, as the API documentation suggests.
Lastly, running the command curl -s -u admin:changeme -k -H "Content-type:application/json" -X POST -d @test.json https://localhost/api/v2/roles
, where test.json contains
{
"role": {
"permissions": [
"view_environments",
"view_facts",
"view_hostgroups",
"view_hosts",
"edit_hosts"
],
"name": "tester"
}
}
gives the error message
{ "error": {"message":"Permission(#72168980) expected, got String(#15746520)"} }
Files