[ckan-dev] Extending IAuthFunctions and public access
lucia.espona at wsl.ch
lucia.espona at wsl.ch
Tue Nov 15 16:31:50 UTC 2016
Dear all
I am developing an extension to restrict the access to some resources (not the full dataset) depending in a datsaset field.
I extended IAuthFunctions by defining a custom 'resource_show' authorization function.
The problem is the function only works when a user is registered, otherwise it denies the access automatically.
For some resources, I would like them to be completely public (also available for non registered users, as default) but it seems impossible to define a custom function and allow public access some cases.
This is the code:
def restricted_resource_show(context, data_dict=None):
return {'success': True }
class RestrictedPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IAuthFunctions)
[...]
# IAuthFunctions
def get_auth_functions(self):
return {'resource_show': restricted_resource_show }
It should return always True but I get:
{"
help": "http://envidat02.wsl.ch:5000/api/3/action/help_show?name=resource_show","
success": false,"
error": {"
message": "Access denied: <function restricted_resource_show at 0x7f69e3de68c0> requires an authenticated user","
__type": "Authorization Error"}}
Any ideas will be appreciated.
Best,
Lucia
_________________________________________________________
Dr. Lucia Espona Pernas
Swiss Federal Institute for Forest, Snow and Landscape Research WSL
Hauptgebäaude Labortrakt (HL C21)
Zürcherstrasse 111
8903 Birmensdorf
Switzerland
+41 44 739 28 71 phone direct
+41 44 739 21 11 reception
www.wsl.ch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20161115/f34ab2f3/attachment-0002.html>
More information about the ckan-dev
mailing list