mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 04:10:44 -03:30
consolidate RBAC is_implicit_parent code
This commit is contained in:
parent
169384ddbe
commit
49faf212ef
@ -111,7 +111,11 @@ def is_implicit_parent(parent_role, child_role):
|
||||
|
||||
# Check to see if the role matches any in the implicit parents list
|
||||
for implicit_parent_path in implicit_parents:
|
||||
if '.' in implicit_parent_path:
|
||||
if implicit_parent_path.startswith('singleton:'):
|
||||
# Singleton role isn't an object role, `singleton_name` uniquely identifies it
|
||||
if parent_role.is_singleton() and parent_role.singleton_name == implicit_parent_path[10:]:
|
||||
return True
|
||||
else:
|
||||
# Walk over multiple related objects to obtain the implicit parent
|
||||
related_obj = child_role.content_object
|
||||
for next_field in implicit_parent_path.split('.'):
|
||||
@ -120,14 +124,6 @@ def is_implicit_parent(parent_role, child_role):
|
||||
break
|
||||
if related_obj and parent_role == related_obj:
|
||||
return True
|
||||
elif implicit_parent_path.startswith('singleton:'):
|
||||
# Singleton role isn't an object role, `singleton_name` uniquely identifies it
|
||||
if parent_role.is_singleton() and parent_role.singleton_name == implicit_parent_path[10:]:
|
||||
return True
|
||||
else:
|
||||
# Direct field on the content object
|
||||
if parent_role == getattr(child_role.content_object, implicit_parent_path):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user