Skip to content

Commit

Permalink
Merge pull request ansible#1612 from AlanCoding/token_no
Browse files Browse the repository at this point in the history
Make user_capabilities False for read tokens
  • Loading branch information
AlanCoding authored Mar 21, 2018
2 parents a13ddff + 4f1f578 commit b3e15f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion awx/main/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,10 @@ def get_user_capabilities(self, obj, method_list=[], parent_obj=None, capabiliti

# Actions not possible for reason unrelated to RBAC
# Cannot copy with validation errors, or update a manual group/project
if display_method == 'copy' and isinstance(obj, JobTemplate):
if 'write' not in getattr(self.user, 'oauth_scopes', ['write']):
user_capabilities[display_method] = False # Read tokens cannot take any actions
continue
elif display_method == 'copy' and isinstance(obj, JobTemplate):
if obj.validation_errors:
user_capabilities[display_method] = False
continue
Expand Down
1 change: 1 addition & 0 deletions awx/main/tests/unit/api/serializers/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def fn(summary, summary_field_name):
def get_summary_fields_mock_and_run():
def fn(serializer_class, model_obj):
serializer = serializer_class()
serializer.show_capabilities = []
serializer.context['view'] = mock.Mock(kwargs={})
return serializer.get_summary_fields(model_obj)
return fn
Expand Down

0 comments on commit b3e15f7

Please sign in to comment.