Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Rest api to get ranger policy for a particular user

avatar

Hi,

I want to fetch policy details of a particular user using rest api . I do want to get policies and then corresponding users to this , but in reverse way.

curl -u admin:admin -X GET http://<Ranger_hsot>:6080/service/public/api/policy

I have executed above rest api but it details policies and its all information but I wanted to get policy corresponding to user .

Basically if I pass user id or its name then when rest api is executed it should details its corresponding policy.

could some one please refer some rest api to achieve above requirement ?

5 REPLIES 5

avatar
Contributor

Same question

avatar
@Anjali Shevadkar

@Anurag Mishra

What about search a policy by username:

https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.6.4/bk_security/content/ranger_rest_api_policy_...

service/public/api/policy?userName=anurag

HTH

*** If you found this answer addressed your question, please take a moment to login and click the "accept" link on the answer.

avatar
Contributor

Best solution , it works. Thank you Anurag.

avatar
New Contributor

In Apache Ranger 0.6 the path is:

url = http://<rangerHost>:<rangerPort>/service/public/v2/api/service/<YourServiceName>/policy/user=<YourUs...;

If you want to get the result on a pretty json format you can do:

curl -u admin:admin -XGET $url | python -mjson.tool > output.json

avatar
Contributor

To fetch the policy details in Json format. Use the below command :

 

curl -v -k -u {username} -H "Content-Type: application/json" -H "Accept: application/json" -X GET https://{Ranger_Host}:6182/service/public/v2/api/service/cm_hive/policy/ | python -m json.tool