Skip to content

Commit

Permalink
[#1373] Give datastore_search_sql own auth function. Before it was go…
Browse files Browse the repository at this point in the history
…ing though normal datastore_search auth function which made no sense as their was no resource to check. It was picking a random resource to check agaist! This patch also fixes a very minor unicode bug.
  • Loading branch information
kindly committed Dec 9, 2013
1 parent 4e89ef8 commit 6e8859a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ckanext/datastore/db.py
Expand Up @@ -292,6 +292,8 @@ def convert(data, type_name):
if type_name.startswith('_'):
sub_type = type_name[1:]
return [convert(item, sub_type) for item in data]
if type_name == 'tsvector':
return unicode(data, 'utf-8')
if isinstance(data, datetime.datetime):
return data.isoformat()
if isinstance(data, (int, float)):
Expand Down
2 changes: 1 addition & 1 deletion ckanext/datastore/logic/action.py
Expand Up @@ -380,7 +380,7 @@ def datastore_search_sql(context, data_dict):
'(; equals chr(59)) and string concatenation (||). ')]
})

p.toolkit.check_access('datastore_search', context, data_dict)
p.toolkit.check_access('datastore_search_sql', context, data_dict)

data_dict['connection_url'] = pylons.config['ckan.datastore.read_url']

Expand Down
3 changes: 3 additions & 0 deletions ckanext/datastore/logic/auth.py
Expand Up @@ -34,6 +34,9 @@ def datastore_delete(context, data_dict):
def datastore_search(context, data_dict):
return datastore_auth(context, data_dict, 'resource_show')

@p.toolkit.auth_allow_anonymous_access
def datastore_search_sql(context, data_dict):
return {'success': True}

def datastore_change_permissions(context, data_dict):
return datastore_auth(context, data_dict)
1 change: 1 addition & 0 deletions ckanext/datastore/plugin.py
Expand Up @@ -221,6 +221,7 @@ def get_auth_functions(self):
'datastore_upsert': auth.datastore_upsert,
'datastore_delete': auth.datastore_delete,
'datastore_search': auth.datastore_search,
'datastore_search_sql': auth.datastore_search_sql,
'datastore_change_permissions': auth.datastore_change_permissions}

def before_map(self, m):
Expand Down

0 comments on commit 6e8859a

Please sign in to comment.