feat(users)!: backend for managing user roles in admin panel#197
Open
Samk13 wants to merge 1 commit intoinveniosoftware:masterfrom
Open
feat(users)!: backend for managing user roles in admin panel#197Samk13 wants to merge 1 commit intoinveniosoftware:masterfrom
Samk13 wants to merge 1 commit intoinveniosoftware:masterfrom
Conversation
10 tasks
f9c9c47 to
a998f11
Compare
* add bulk role update/delete via `/users/<id>/groups` * support role name or id in bulk mutations * optimize role resolution with batched DB lookup * enforce secure permission/validation behavior (403 on unknown roles) * update tests BREAKING CHANGE: users index data/behavior changed; rebuild indices. invenio index destroy --yes-i-know invenio index init invenio rdm rebuild-all-indices
a998f11 to
d93feee
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
❤️ Thank you for your contribution!
Description
/users/<id>/groups.403for unknown roles.depends on: inveniosoftware/invenio-app-rdm#3354
Breaking change
Users' index behavior changed; reindex is required:
Screen.Recording.2026-03-05.at.13.33.44.mov
User Roles API (Bulk + Incremental)
This PR introduces an API model for managing user roles with both bulk and incremental operations:
Bulk replace (
PUT) is used by the UI for performance and consistency:one request applies the full desired role state
avoids multiple round-trip when updating many roles
supports deterministic add/remove in a single call
Incremental add (
POST) and incremental remove (DELETE) are intended for API consumers that want non-destructive, stepwise updates.1. List user roles
GET/api/users/<user_id>/groupsExample:
response:
2. Bulk replace roles (UI-oriented)
PUT/api/users/<user_id>/groupsExample:
3. Add roles without removing existing ones (API-oriented)
POST/api/users/<user_id>/groupsExample:
4. Remove specific roles (API-oriented)
DELETE/api/users/<user_id>/groupsExample:
Payload Notes
groups(list of role IDs/names as strings).role_idsis also accepted for backward compatibility.Checklist
Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:
Frontend
Reminder
By using GitHub, you have already agreed to the GitHub’s Terms of Service including that: