You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RBAC should validate the service name for content_type #579
The /role_definitions/ list accepts content_type as one of the fields in the format of "aap.organization". The intent is that the first prefix is the service name, for a cluster of multiple services stitched together by the JWT and resource_registry communication.
While that's the intent, the code just ignored it, test case:
deftest_service_name_is_validated(admin_api_client):
url=get_relative_url('roledefinition-list')
response=admin_api_client.post(
url,
data={
'name': 'Random custom role',
'content_type': 'justsomerandomstuff.organization',
'permissions': ['aap.view_organization', 'local.change_organization'],
},
)
assertresponse.status_code==400, response.dataassert'service name not valid for model organization'instr(response.data)
This fails with a 201 response_code.
We already had a requirement that the model name is unique within the permission registry. This is intended to change later, to be unique within the registry for a particular service... specifically to support awx.credential and eda.credential, which is a legitimate problem.
However, since we don't have any non-synced services now, model name is safely unique by itself right now, so writing the serializers, I just stopped where I was. This is a TODO for later, as we develop a permissions-provider functionality.
A fix for this has been submitted in PR #1124. The fix adds a ContentTypeSlugField subclass of SlugRelatedField in ansible_base/rbac/api/serializers.py that catches the generic "object does not exist" validation error, checks whether the model portion of the slug exists under any valid service, and raises the specific error message service name not valid for model {model_name} when the service prefix is unrecognized.
Activity
aap-platform-services-cicd-bot-sa commentedon Sep 3, 2026
A fix for this has been submitted in PR #1124. The fix adds a
ContentTypeSlugFieldsubclass ofSlugRelatedFieldinansible_base/rbac/api/serializers.pythat catches the generic "object does not exist" validation error, checks whether the model portion of the slug exists under any valid service, and raises the specific error messageservice name not valid for model {model_name}when the service prefix is unrecognized.