将现有用户添加到现有组 apache ranger

时间:2020-12-22 08:35:40

标签: rest apache-ranger

我正在查看 apache Ranger rest API 以将现有的内部用户添加到现有的内部组。

我一直在查看文档,但似乎找不到有用的东西,是否有相应的 API?

1 个答案:

答案 0 :(得分:1)

尝试以下 api 调用:-

curl -ivk -u admin:admin -H "Content-Type: application/json" -d '{"id":13,"createDate":"2020-12-23T07:55:04Z","updateDate":"2020-12-23T07:55:04Z","owner":"rangerusersync","updatedBy":"rangerusersync","name":"atlas","password":"*****","description":"atlas - add from Unix box","groupIdList":[6,59,4,131,133],"groupNameList":["atlas","hadoop","shadow"],"status":0,"isVisible":1,"userSource":1,"userRoleList":["ROLE_USER"],"otherAttributes":"{\"full_name\":\"atlas\",\"original_name\":\"atlas\"}"}'  -X PUT https://RANGER_HOST:6182/service/xusers/users

它有点大,但如果用户已经添加到 Ranger,则运行以下 api 以获取用户的 id 信息:-

curl -ivk -u admin:admin -H "Accept : application/json" -X GET https://RANGER_HOST:6182/service/xusers/users

一旦您拥有所有用户的 ID,您就可以运行以下 curl api 以获取可用于修改的 json 格式数据,然后在我提到的第一个 API 中使用 PUT 方法:-

curl -ivk -u admin:admin -H "Accept: application/json" -X GET https://RANGER_HOST:6182/service/xusers/users/13

上面的 Curl api 应该返回如下内容:-

{"id":13,"createDate":"2020-12-23T07:55:04Z","updateDate":"2020-12-23T16:45:14Z","owner":"rangerusersync","updatedBy":"admin","name":"atlas","password":"*****","description":"atlas - add from Unix box","groupIdList":[133,6],"groupNameList":["apitest","atlas","hadoop","shadow","ssb"],"status":0,"isVisible":1,"userSource":1,"userRoleList":["ROLE_USER"],"otherAttributes":"{\"full_name\":\"atlas\",\"original_name\":\"atlas\"}"}

你必须从上面的输出中修改 "groupIdList":[133,6] 复制整个输出并使用 PUT 方法传递它,如上面提到的第一个 api 调用所示。