From b62445079d0a212cde083dd7f57f5ef3c403fcec Mon Sep 17 00:00:00 2001 From: Ross Jones Date: Tue, 9 Dec 2014 14:31:22 +0000 Subject: [PATCH] Adds auth for vocabulary_list and vocabulary_show. Fixes #2104, with other relevant detail at #2128 --- ckan/logic/action/get.py | 4 ++++ ckan/logic/auth/get.py | 8 ++++++++ ckan/tests/test_coding_standards.py | 2 -- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ckan/logic/action/get.py b/ckan/logic/action/get.py index 9afdd4b13dc..49bae75409e 100644 --- a/ckan/logic/action/get.py +++ b/ckan/logic/action/get.py @@ -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) @@ -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: diff --git a/ckan/logic/auth/get.py b/ckan/logic/auth/get.py index d2a899223b6..07ca4120a7e 100644 --- a/ckan/logic/auth/get.py +++ b/ckan/logic/auth/get.py @@ -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} @@ -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} diff --git a/ckan/tests/test_coding_standards.py b/ckan/tests/test_coding_standards.py index 8126416ef66..5233693e229 100644 --- a/ckan/tests/test_coding_standards.py +++ b/ckan/tests/test_coding_standards.py @@ -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',