Thanks for the help.
I used a similar approach mentioned by @Iurii. Here is my solution.
I wrote a class to handle authentication and overriding the is_authenticated method. and then I can use this class in the meta definition of tastypie resource classes.
from tastypie.authentication import BasicAuthentication
from tastypie.resources import Resource, ModelResource
# class for handling authentication
class MyAuthentication (BasicAuthentication):
def is_authenticated (self, request, ** kwargs):
# put here the logic to check username and password from request object
# if the user is authenticated then return True otherwise return False
# tastypie resource class
class MyResource (ModelResource):
class Meta:
authentication = MyAuthentication ()
this will ensure that the request for access to the resource goes through your authentication code.
sanket
source share