Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TastyPie - Override_urls ignores Authentication and Authorization

I have the following resource:

class MyUserResource(resources.MongoEngineResource):

    class Meta:
        ...
        authentication = MyKeyAuthentication()
        authorization = ApiKeyAuthorization()

    def override_urls(self):
        return [...] 

All API calls which are standard-tastypie are routed through the authentification and authorization. But all customized functions/urls (which are in my override_urls) simply ignore the auth/auth functions...

Any ideas why?

Edit:

Maybe the problem is that the dispatcher isn't called. The question remains why that is... and how I can change this behavior!

like image 340
Ron Avatar asked Aug 06 '12 11:08

Ron


1 Answers

Ok, finally I found out that when customizing / overriding my urls I also override the standard behavior of calling wrap_view. This causes the not-calling of dispatch which is in charge of checking the auth-methods.

So I just put the auth-checks manually in evey of my functions (like this):

self.is_authenticated(request)
self.is_authorized(request)

Hope this helps other desperate tastypie-developers :)

like image 199
Ron Avatar answered Sep 18 '22 23:09

Ron