mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
Allow anyone who can read an inventory to see adhoc commands run on that inventory
This implicitly solves one of the issues with #2804, but is in general a better behavior in general we believe.
This commit is contained in:
parent
33547259e2
commit
ee3d4dc42d
@ -1075,10 +1075,7 @@ class AdHocCommandAccess(BaseAccess):
|
||||
'''
|
||||
I can only see/run ad hoc commands when:
|
||||
- I am a superuser.
|
||||
- I am an org admin and have permission to read the credential.
|
||||
- I am a normal user with a user/team permission that has at least read
|
||||
permission on the inventory and the run_ad_hoc_commands flag set, and I
|
||||
can read the credential.
|
||||
- I have read access to the inventory
|
||||
'''
|
||||
model = AdHocCommand
|
||||
|
||||
@ -1089,11 +1086,8 @@ class AdHocCommandAccess(BaseAccess):
|
||||
if self.user.is_superuser:
|
||||
return qs.all()
|
||||
|
||||
credential_ids = set(self.user.get_queryset(Credential).values_list('id', flat=True))
|
||||
inventory_qs = Inventory.accessible_objects(self.user, 'read_role')
|
||||
|
||||
return qs.filter(credential_id__in=credential_ids,
|
||||
inventory__in=inventory_qs)
|
||||
return qs.filter(inventory__in=inventory_qs)
|
||||
|
||||
def can_add(self, data):
|
||||
if not data or '_method' in data: # So the browseable API will work?
|
||||
@ -1101,11 +1095,11 @@ class AdHocCommandAccess(BaseAccess):
|
||||
|
||||
self.check_license()
|
||||
|
||||
# If a credential is provided, the user should have read access to it.
|
||||
# If a credential is provided, the user should have use access to it.
|
||||
credential_pk = get_pk_from_dict(data, 'credential')
|
||||
if credential_pk:
|
||||
credential = get_object_or_400(Credential, pk=credential_pk)
|
||||
if self.user not in credential.read_role:
|
||||
if self.user not in credential.use_role:
|
||||
return False
|
||||
|
||||
# Check that the user has the run ad hoc command permission on the
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user