Apache Ranger REST API addUsersAndGroups returns 404 not found

898 views Asked by At

We have installed Apache Ranger and the Web UI works fine, most of the REST API method works fine on both PublicAPIsv2 and RoleREST as per https://ranger.apache.org/apidocs/ui/index.html.
I can get “test_role” id by calling GET /public/v2/api/roles/name/test_role which returns the id 409.
I can get test_role content by calling GET /public/v2/api/roles/409
I can change test_role users list by editing the response I get from GET /public/v2/api/roles/409 and submitting it through PUT /public/v2/api/roles/409

The body is:

{
    "id": 409,
    "isEnabled": true,
    "createdBy": "admin",
    "updatedBy": "admin",
    "createTime": 1598241102841,
    "updateTime": 1601975068428,
    "name": "test_role",
    "options": {},
    "users": [
        {
            "name": "test_user1”,
            "isAdmin": true
        },
        {
            "name": “test_user2”,
            "isAdmin": true
        },
        {
            "name": “test_user3”,
            "isAdmin": false
        }
    ],
    "groups": [
        {
            "name": "test_group”,
            "isAdmin": false
        }
    ],
    "roles": []
}

But calling PUT /public/v2/api/roles/409/addUsersAndGroups returns “404 not found”. I tried with the same body as above as parameter, and also with:

{
    "users": [
        {
            "name": “test_user4”,
            "isAdmin": true
        }
    ]
}

Would anybody know what is the correct body to send as parameter to: /public/v2/api/roles/409/addUsersAndGroups?
Also, making a wrong call such as GET /public/v2/api/roles/409/addUsersAndGroups returns “405 method not allowed”. So I believe it shows the end point does exist. I’m not sure why calling PUT public/v2/api/roles/409/addUsersAndGroups with (probably) incorrect body returns “404 not found” and not an error message related to the wrong parameter.

1

There are 1 answers

0
Bruno Rocha On

It happens because Apache Ranger API documentation is wrong, remove the suffix /addUsersAndGroups of your endpoint and it will work.

Example: https://ranger_url/service/roles/roles/409

Where 409 is the role ID, as you're using on your example.

The body that is needed:

{
    "name": "test_role",
    "users": [
        {
            "name": "test_user1",
            "isAdmin": true
        }
    ]
}