openwisp / openwisp/openwisp-controller
[feature] Allow viewing shared objects by non superadministrators as view only
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 773
- Forks
- 315
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 14
Description
⚠️ Not suited to beginner contributors.
Implement the solution devised in https://github.com/openwisp/openwisp-users/issues/238.
We must add tests (ideally reusable test logic to make maintainance sane) that for each model verify the following:
- shared objects can be viewed in readonly mode also by non superusers (admin and REST API)
- new shared object can be created only by superusers (admin and REST API)
- existing shared objects can only be changed/deleted by superusers (admin and REST API)
I found that after upgrading DRF to 3.16 endpoints using the CaListSerializer were failing with the following error:
assert not (required and default is not empty), NOT_REQUIRED_DEFAULT
AssertionError: May not set both `required` and `default`
It happens because of this line:
https://github.com/openwisp/openwisp-controller/blob/1745a0a04f43708d7b402a292d208ca20a010376/openwisp_controller/pki/api/serializers.py#L81
If I remove that line, the tests pass, but I am then able to create a shared Ca with a non superuser org admin/manager user account, which is not what we want and is worrying: we need tests to protect us from these possible security holes.
I also verified that upgrading to DRF 3.16 allows to create objects by omitting the "organization" field, hence allowing non superusers to omit this field and create shared objects, opening security holes.
I think it may be necessary to work on these changes while also upgrading DRF to 3.16 and bind the version, otherwise we may have to work on this twice.
Contributor guide
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
Read the solution linked from issue 238, then inspect openwisp_controller/pki/api/serializers.py at the CaListSerializer line cited in the report. Locate the shared-object admin and REST API tests or their existing reusable test logic. Done means shared objects are viewable by non-superusers, while creation, modification, and deletion remain restricted to superusers in both interfaces, with coverage for each model.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- api, authorization, backend, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100