ARTIFACTORY: How to view repository permissions with REST API?

David Shin
2021-11-23 09:40

Description
You may want to check the effective permissions of users/groups/permission targets for a repository for automation purposes.

Resolution
You can use the api/artifactpermissions  Internal End Point with repoKey parameter. You could use the jq to see the well structured result.
e.g.

curl -u admin 'https://ART_URL/artifactory/api/artifactpermissions?repoKey=<repo_key>' | jq
{
"userEffectivePermissions": [
{
"principal": "admin",
"admin": true,
"permissionTargets": [],
"permission": {
"delete": true,
"deploy": true,
"annotate": true,
"read": true,
"distribute": true,
"managedXrayMeta": true
},
"permissionTargetsCount": 0,
"permissionTargetsCap": false
},
{
"principal": "anonymous",
"admin": false,
"permissionTargets": [
"Anything"
],
"permission": {
"delete": false,
"deploy": false,
"annotate": false,
"read": true,
"distribute": false,
"managedXrayMeta": false
},
"permissionTargetsCount": 1,
"permissionTargetsCap": false
}
],
"groupEffectivePermissions": [
{
"principal": "readers",
"admin": false,
"permissionTargets": [
"Anything"
],
"permission": {
"delete": false,
"deploy": false,
"annotate": false,
"read": true,
"distribute": false,
"managedXrayMeta": false
},
"permissionTargetsCount": 1,
"permissionTargetsCap": false
}
],
"permissionTargets": [
{
"permissionName": "Anything",
"groups": [
"readers"
],
"users": [
"anonymous"
],
"repoKeys": [
"ANY"
]
}
]
}