1👍
✅
Here is an example of how you might use Django’s Basic Authentication when presenting Users as RESTful resources:
# REST endpoint for authenticating user accounts
class UserResource(ModelResource):
class Meta:
queryset = User.objects.all()
resource_name = 'auth/user'
authentication = BasicAuthentication()
authorization = DjangoAuthorization()
def apply_authorization_limits(self, request, object_list):
return object_list.filter(username=request.user)
Authentication can be as simple as the one line:
authentication = BasicAuthentication()
depending on how you implement it.
Source:stackexchange.com