Skip to content

Commit

Permalink
Adds auth for vocabulary_list and vocabulary_show.
Browse files Browse the repository at this point in the history
Fixes #2104, with other relevant detail at #2128
  • Loading branch information
rossjones committed Dec 9, 2014
1 parent 5119209 commit b624450
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ckan/logic/action/get.py
Expand Up @@ -2266,6 +2266,8 @@ def vocabulary_list(context, data_dict):
:rtype: list of dictionaries
'''
_check_access('vocabulary_list', context, data_dict)

model = context['model']
vocabulary_objects = model.Session.query(model.Vocabulary).all()
return model_dictize.vocabulary_list_dictize(vocabulary_objects, context)
Expand All @@ -2280,6 +2282,8 @@ def vocabulary_show(context, data_dict):
:rtype: dictionary
'''
_check_access('vocabulary_show', context, data_dict)

model = context['model']
vocab_id = data_dict.get('id')
if not vocab_id:
Expand Down
8 changes: 8 additions & 0 deletions ckan/logic/auth/get.py
Expand Up @@ -66,6 +66,10 @@ def license_list(context, data_dict):
# Licenses list is visible by default
return {'success': True}

def vocabulary_list(context, data_dict):
# List of all vocabularies are visible by default
return {'success': True}

def tag_list(context, data_dict):
# Tags list is visible by default
return {'success': True}
Expand Down Expand Up @@ -157,6 +161,10 @@ def organization_show(context, data_dict):
# anyone can see a organization
return {'success': True}

def vocabulary_show(context, data_dict):
# Allow viewing of vocabs by default
return {'success': True}

def tag_show(context, data_dict):
# No authz check in the logic function
return {'success': True}
Expand Down
2 changes: 0 additions & 2 deletions ckan/tests/test_coding_standards.py
Expand Up @@ -776,8 +776,6 @@ class TestActionAuth(object):
'get: user_activity_list_html',
'get: user_followee_count',
'get: user_follower_count',
'get: vocabulary_list',
'get: vocabulary_show',
'update: package_relationship_update_rest',
'update: task_status_update_many',
'update: term_translation_update_many',
Expand Down

0 comments on commit b624450

Please sign in to comment.