openwisp / openwisp/openwisp-users
[feature] Add dedicated REST API endpoints for managing user organization memberships
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 179
- Forks
- 96
- Avg merge
- 13h 40m
- Merged PRs (30d)
- 16
Description
Is your feature request related to a problem? Please describe.
Currently, there is no dedicated REST API endpoint to manage organization memberships (add, remove, or modify). Users must be added/modified through the superuser user detail endpoint (PUT /api/v1/users/user/{id}/), and removal requires changing the is_admin value in a way that is undocumented and unintuitive.
Describe the solution you'd like
Add dedicated REST API endpoints to manage organization membership:
GET /api/v1/users/user/{user_id}/organization-membership/POST /api/v1/users/user/{user_id}/organization-membership/PUT/PATCH /api/v1/users/user/{user_id}/organization-membership/{org_id}/DELETE /api/v1/users/user/{user_id}/organization-membership/{org_id}/
Both approaches should support proper permission checks (organization managers, superusers only).
Describe alternatives you've considered
- Continue using the indirect approach via the user detail endpoint with undocumented behavior
- Document the existing behavior (changing
is_adminto same value deletes membership) and consider it sufficient
Additional context
Current Issues:
- No clear way to remove a user from an organization via REST API
- The workaround (sending same
is_adminvalue to delete) is undocumented and counter-intuitive - Only superusers can manage memberships through the current endpoint
- Missing organization manager permissions checks for membership management
- The
OrganizationUserSerializerexists in the codebase but is only used internally in the superuser serializer
Benefits:
- Clearer, more intuitive API for organization membership management
- Better permission control (allow org managers to manage memberships)
- Improved documentation and discoverability
- Consistency with REST API best practices
- Enables programmatic management of organization memberships
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
Start by tracing the existing superuser user detail endpoint and the OrganizationUserSerializer, which currently is used internally in the superuser serializer. Define the GET, POST, PUT/PATCH, and DELETE organization-membership endpoints and their organization-manager and superuser permission behavior. Done means memberships can be listed, added, modified, and removed through the documented REST API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- api, authorization, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100