3

I have a Django application (mainly a rest API) with a completely custom User model (not inhered from Django). My authentication is based on JWT tokens.

I would like to make sure a user cannot access to data of another user. I have checked the django-guardian and django-rules. It provides stuff to call a has_perm function. However, in the case the developer does not perform the check and makes a mistake (for example hardcoding the user id in a query), a user might be able to access someone else data

Is there any way to enforce some kind of rule at the ORM level?

poiuytrez
  • 21,330
  • 35
  • 113
  • 172
  • 3
    You might be able to use Database instrumentation, not however that I'm not certain this is a good practice for your use case. https://docs.djangoproject.com/en/4.1/topics/db/instrumentation/ – Felix Eklöf Oct 11 '22 at 10:15

0 Answers0