[ckan-dev] Extending IAuthFunctions and public access - SOLVED
lucia.espona at wsl.ch
lucia.espona at wsl.ch
Wed Nov 16 20:47:26 UTC 2016
Sorry Hendrik
I swear I read the manual page at least twice... until the "See ckan/logic/auth/ for more examples.", right before the last paragraph where that with the decorator is explained.
It works now of course :)
Thanks a lot,
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
-----"ckan-dev" <ckan-dev-bounces at lists.okfn.org> wrote: -----
To: CKAN Development Discussions <ckan-dev at lists.okfn.org>
From: Hendrik Bunke
Sent by: "ckan-dev"
Date: 16.11.2016 09:59
Subject: Re: [ckan-dev] Extending IAuthFunctions and public access
Hi Lucia,
you can use a decorator provided by plugins.toolkit: auth_allow_anonymous_access
See
http://docs.ckan.org/en/latest/extensions/plugin-interfaces.html#ckan.plugins.interfaces.IAuthFunctions
for more details.
regards
hendrik
--On 2016-11-15 17:31, lucia.espona at wsl.ch wrote:
> 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
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
--
Dr. Hendrik Bunke
http://www.hbxt.org
http://twitter.com/hbunke
_______________________________________________
ckan-dev mailing list
ckan-dev at lists.okfn.org
https://lists.okfn.org/mailman/listinfo/ckan-dev
Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20161116/6ba2c80f/attachment-0003.html>
More information about the ckan-dev
mailing list