1.1 KiB
1.1 KiB
Object permissions with django-rules
EUSRR combines Django model permissions, DRF permission classes and
django-rules object predicates. Authentication alone never implies access to a
domain object.
Rule modules currently exist in employees, communications, documents, feed, requests, procurement and scheduling. Each domain owns its predicates; do not create a central list that duplicates their implementation.
Usage
if request.user.has_perm("communications.change_chat", chat):
...
DRF viewsets must also restrict list querysets. An object permission applied only
after get_object() does not protect list/search endpoints.
When adding a rule:
- implement small predicates in the domain's
rules.py; - register a namespaced rule or permission;
- use it from the API permission layer and service boundary;
- cover owner, allowed member, unrelated user and superuser behavior;
- test list visibility separately from detail mutation.
Frontend flags may hide unavailable actions but are not an authorization
boundary. See backend/docs/guides/CHAT_ROLES.md
for the communications role mapping.