I'm learning Django + DRF + React and I reached the phase where it's time to protect some endpoints. Some are easier to protect, just a permission so only the user which created a particular object (and the admins) are able to see it. There is one endpoint which is tricky for me. It's a GET call and returns something like:
{book: "Who am I and how come",
id: "whatever31",
reading: ["user1", "user2"]}
I want to protect this endpoint based on the user making the request (Session auth) so only calls coming from user1
and user2
can access this object (also, not exposing reading
field, but that's probably a different discussion). Should I use a custom permission on DRF view? Should I use a filter instead in queryset
method? Maybe both?