REST requests should mirror Alyx user group permissions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 52
- Forks
- 12
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 4
Description
Most (but maybe not all) REST views use permissions defined in alyx.base.BestRestPublicPermission: https://github.com/cortex-lab/alyx/blob/95c2e40de451f02b24e3b3de908a99e7ff513ec0/alyx/alyx/base.py#L648-L664, while most (but maybe not all) model admin instances use the alyx.base.BaseAdmin.has_change_permission method: https://github.com/cortex-lab/alyx/blob/95c2e40de451f02b24e3b3de908a99e7ff513ec0/alyx/alyx/base.py#L374-L413
This means that users have far more permissions when making REST queries than via the admin interface which is extremely insecure and confusing to users. Below are some suggested improvements:
- Ensure all REST views are using a shared base permissions set (i.e.
permission_classes = rest_permission_classes()is present everywhere) - Ensure all model admin classes use the same basic permissions system (i.e. super class call to
BaseAdmin.has_change_permission) - Consolidate base permissions between APIs (the above two methods can call a common base permissions function)
- Permit test Alyx to allow all REST permissions for testing purposes - check library tests still pass after changes
- Add method to BaseTests to check that REST API permissions are suitable. This can be a generic test for all apps.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing alyx/base.py's BestRestPublicPermission, BaseAdmin.has_change_permission, and BaseTests with the REST views and model admin classes across the project. Run the library tests while auditing permission_classes and superclass calls. Done means the APIs and admin share the intended permission behavior, test Alyx remains usable for permission tests, and generic REST permission coverage passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- api, backend, security, testing-qa
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100