Which users are Nexus Repository Manager Admins? - Sonatype Nexus Repository / Best Practices - Sonatype Community
Which users are Nexus Repository Manager Admins?
post by mworthington on Jun 1, 2018
Michael Worthington
Continuing the discussion from Advanced Use Cases for the Nexus Repository Manager API:
An important piece of information for Nexus Administrators is understanding what users have access to which parts of the application, or more specifically, what users are assigned to a specific role. With the API and UI, it is easy to look up a specific user and see all of the roles assigned to that user. But doing the opposite takes a little more work.
By leveraging the Integrations API, you can upload this groovy script nexus-scripting-examples/listRolesToUsers.groovy at master · sonatype-nexus-community/nexus-scripting-examples · GitHub and use a REST-style call to run the script to get all the roles, or one specific role, and their assigned users.
Lookup all users with Nexus Administrator privileges:
curl -X POST http://localhost:8081/service/siesta/rest/v1/script/listrolestousers/run -u username:password -H 'content-type: text/plain' -d '{ "id": "nx-admin" }' | jq -c -r '.result' | jq .
I am using jq to format the result curl stdout as json to make it nice and pretty to read. Here are all the admin users in my demo instance:
{
"nx-admin": [
"admin",
"homer",
"marge",
"mworthington",
"nrmfirewall"
]
}