Bug #5945

Role API broken

Added by Michael Griffin about 4 years ago. Updated 9 days ago.

Status:Closed
Priority:Normal
Assignee:Tomáš Strachota
Category:API
Target version:1.6.0
Difficulty: Team Backlog:
Triaged: Fixed in Releases:
Bugzilla link: Found in Releases:1.5.0
Pull request:https://github.com/theforeman/foreman/pull/1486

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)"}
}

stacktrace.txt Magnifier - "error":{"message":"undefined method `key?' (17.1 KB) Michael Griffin, 05/27/2014 03:27 PM


Related issues

Related to Foreman - Bug #6532: API for permission related operations lacks some function... Closed 07/09/2014
Blocks Foreman - Tracker #4552: New permissions/authorization system issues New 03/05/2014

History

#1 Updated by Marek Hulán about 4 years ago

  • Blocks Tracker #4552: New permissions/authorization system issues added

#2 Updated by Joseph Magen about 4 years ago

  • Status changed from New to Assigned
  • Assignee set to Joseph Magen
  • Target version set to 1.8.2

#3 Updated by Joseph Magen about 4 years ago

  • Status changed from Assigned to Ready For Testing

https://github.com/theforeman/foreman/pull/1486

Michael, can you check if the return information is what you are looking for in v2.

Btw, POSTing or PUTing "permissions": [ "view_architectures", "create_architecture, etc] is not supported afaik in both v1 and v2. Did this work for you in v1?

#4 Updated by Michael Griffin about 4 years ago

Joseph Magen wrote:

https://github.com/theforeman/foreman/pull/1486

Michael, can you check if the return information is what you are looking for in v2.

Btw, POSTing or PUTing "permissions": [ "view_architectures", "create_architecture, etc] is not supported afaik in both v1 and v2. Did this work for you in v1?

I'm not sure exactly how to check whether the return info is correct. But, yes, the POST/PUT worked in v1. That was how I created my Role definitions. If that is not supported, what is the supported way of creating Roles without clicking through the GUI?

#5 Updated by Dmitri Dolguikh about 4 years ago

  • Target version changed from 1.8.2 to 1.8.1

#6 Updated by Dmitri Dolguikh about 4 years ago

  • Target version changed from 1.8.1 to 1.8.0

#7 Updated by Dmitri Dolguikh almost 4 years ago

  • Target version changed from 1.8.0 to 1.7.5

#8 Updated by The Foreman Bot almost 4 years ago

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

#9 Updated by Dominic Cleal almost 4 years ago

  • Related to Bug #6532: API for permission related operations lacks some functionality added

#10 Updated by Dominic Cleal almost 4 years ago

  • Status changed from Ready For Testing to Closed
  • Assignee changed from Joseph Magen to Tomáš Strachota
  • % Done changed from 0 to 100
  • Legacy Backlogs Release (now unused) set to 10

Should have been fixed via #6532.

Also available in: Atom PDF