diff --git a/ckan/logic/auth/get.py b/ckan/logic/auth/get.py index 7ec753c0580..e60ca89be35 100644 --- a/ckan/logic/auth/get.py +++ b/ckan/logic/auth/get.py @@ -159,11 +159,29 @@ def resource_show(context, data_dict): def resource_view_show(context, data_dict): - return authz.is_authorized('resource_show', context, data_dict) + + model = context['model'] + resource = context.get('resource') + if not resource: + resource_view = model.ResourceView.get(data_dict['id']) + if not resource_view: + raise logic.NotFound(_('Resource view not found, cannot check auth.')) + resource = model.Resource.get(resource_view.resource_id) + + return authz.is_authorized('resource_show', context, {'id': resource.id}) def resource_view_list(context, data_dict): - return authz.is_authorized('resource_show', context, data_dict) + + model = context['model'] + resource = context.get('resource') + if not resource: + resource_view = model.ResourceView.get(data_dict['id']) + if not resource_view: + raise logic.NotFound(_('Resource view not found, cannot check auth.')) + resource = model.Resource.get(resource_view.resource_id) + + return authz.is_authorized('resource_show', context, {'id': resource['id']}) def revision_show(context, data_dict):