I'd like to have multiples layers of permissions for an API using Django Rest Framework, how can I best achieve this?
Specifically the three categories of authorization I have are:
- Roles: Model level access, such as admin and different customer types.
- GroupAccess: Per object, group access such as a team of users.
- Sensitivities: Per object, additional tags for sensitive information.
The second two categories apply equally across all models and it would be nice to not need separate permissions for each model.
Idea 1:
Create a model for each category inheriting from the standard django auth group. Doing these as proxy groups, to be logically different in my code, but as consistent with standard authorization as possible. Then use django-guardian to enable the object level permissions.
Idea 2:
Use the standard groups for roles and assign model level permissions based on these groups. For the object level permissions write a custom permission classes in Django Rest Framework to check the object level permissions against the user.