I know how to setup authentication/authortization for tastypie resources: via settings in the resource Meta class. How do I authenticate/authorize access to the top-level schema though?
For example, I can authenticate/authorize the resource at /api/v1/resource
, but how do I authenticate/authorize the schema at /api/v1
?
There is no easy way to do this by default with tastypie's default mechanisms. If you look inside api.py file you will see that the top_level
method doesn't have the authentication/authorization mechanism applied.
I think the cleanest way to achieve what you want would be by extending the Api class and overriding the top_level
method to check that the user is allowed to see the result.
This however may be overcomplicated becuase the Api itself doesn't use the autorisation and authentication methods. So you may want to override the Api's urls method by removing the top_level
definition there and putting it inside the urls in your Resources.