Skip to content

feat: add APIs to list roles a user can assign for a dataset or dataverse#11919

Open
vera wants to merge 10 commits into
IQSS:developfrom
vera:feat/user-assignable-roles
Open

feat: add APIs to list roles a user can assign for a dataset or dataverse#11919
vera wants to merge 10 commits into
IQSS:developfrom
vera:feat/user-assignable-roles

Conversation

@vera

@vera vera commented Oct 22, 2025

Copy link
Copy Markdown
Member

What this PR does / why we need it:

This PR adds two API endpoints that list the roles a user is allowed to assign to others for a given dataset or dataverse.

The endpoints return all roles that have no more permissions than the current user. Roles with higher permissions are excluded.

This is needed for our custom UI’s role assignment form, so that users only see roles they are actually allowed to assign. The same endpoints could also be used by the new SPA.

For reference, the current Dataverse UI lists all roles, even those the user cannot assign:

image

If a user tries to assign a role they are not allowed to assign, they currently see an error message:

image

With this PR, the UI could also be updated to show only assignable roles, preventing this error, by applying the following change in ManagePermissionsPage.java:

-         return roleService.availableRoles(dvObject).stream()
+         return roleService.availableRoles(dvObject, session.getUser()).stream()

Which issue(s) this PR closes:

Not aware of an issue

Special notes for your reviewer:

/

Suggestions on how to test this:

I've added tests here:

mvn test -Dtest="DataversesIT#testListAssignableRoles"

mvn test -Dtest="DatasetsIT#testListAssignableRoles"

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

/

Is there a release notes update needed for this change?:

I've added a release note.

Additional documentation:

/

cc @johannes-darms

@coveralls

coveralls commented Oct 22, 2025

Copy link
Copy Markdown

Coverage Status

coverage: 24.334% (-0.002%) from 24.336%
when pulling 817eceb on vera:feat/user-assignable-roles
into a843c84 on IQSS:develop.

# Conflicts:
#	src/main/java/edu/harvard/iq/dataverse/DataverseRoleServiceBean.java
#	src/main/java/edu/harvard/iq/dataverse/ManagePermissionsPage.java
#	src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java
@johannes-darms

Copy link
Copy Markdown
Contributor

@pdurbin Could you assign a ready for review label?

@pdurbin pdurbin moved this to Ready for Triage in IQSS Dataverse Project Apr 29, 2026
@pdurbin

pdurbin commented Apr 29, 2026

Copy link
Copy Markdown
Member

@johannes-darms sure! Well, I put it in triage, for Triage Tuesday. 😅

@vera can you please resolve the merge conflicts? Thanks! ❤️

# Conflicts:
#	src/main/java/edu/harvard/iq/dataverse/api/Dataverses.java
#	src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java
@vera

vera commented May 7, 2026

Copy link
Copy Markdown
Member Author

@vera can you please resolve the merge conflicts? Thanks! ❤️

done :)

@jp-tosca jp-tosca moved this from Ready for Triage to Ready for Review ⏩ in IQSS Dataverse Project May 19, 2026
@cmbz cmbz added FY26 Sprint 23 FY26 Sprint 23 (2026-05-06 - 2026-05-20) FY26 Sprint 24 FY26 Sprint 24 (2026-05-20 - 2026-06-03) labels May 20, 2026
@stevenwinship stevenwinship self-assigned this Jun 1, 2026
@stevenwinship stevenwinship moved this from Ready for Review ⏩ to In Review 🔎 in IQSS Dataverse Project Jun 1, 2026
@stevenwinship

stevenwinship commented Jun 1, 2026

Copy link
Copy Markdown
Contributor
  •     return roleService.availableRoles(dvObject).stream()
    
  •     return roleService.availableRoles(dvObject, session.getUser()).stream()
    

I think adding this change is a good idea but I will not hold up this PR

@github-project-automation github-project-automation Bot moved this from In Review 🔎 to Ready for QA ⏩ in IQSS Dataverse Project Jun 1, 2026
@stevenwinship stevenwinship removed their assignment Jun 1, 2026
@cmbz cmbz added the FY26 Sprint 25 FY26 Sprint 25 (2026-06-03 - 2026-06-17) label Jun 3, 2026
@cmbz cmbz added the FY26 Sprint 26 FY26 Sprint 26 (2026-06-17 - 2026-07-01) label Jun 18, 2026
@cmbz cmbz added the FY27 Sprint 1 FY27 Sprint 1 (2026-07-01 - 2026-07-15) label Jul 1, 2026
@pdurbin pdurbin added the Status: Merge Conflicts Merge conflicts must be resolved. label Jul 14, 2026
@pdurbin pdurbin moved this from Ready for QA ⏩ to In Review 🔎 in IQSS Dataverse Project Jul 14, 2026
@pdurbin pdurbin self-assigned this Jul 14, 2026
Comment on lines +1336 to +1338
@GET
@AuthRequired
@Path("{identifier}/assignments/userAssignableRoles")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all APIs, please add new annotations described here:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, also fixed the merge conflicts.

Vacuum score is back up to 98:

$ vacuum lint -r scripts/openapi/vacuum-recommended.yaml target/classes/META-INF/openapi.json

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I eyeballed the annotations added in 8ff3b24 and they look fine to me. Moving this pack to "ready for QA". Thanks, @vera!

@cmbz cmbz added the FY27 Sprint 2 FY27 Sprint 2 (2026-07-15 - 2026-07-29) label Jul 15, 2026
@pdurbin pdurbin moved this from In Review 🔎 to Ready for QA ⏩ in IQSS Dataverse Project Jul 17, 2026
@pdurbin pdurbin removed the Status: Merge Conflicts Merge conflicts must be resolved. label Jul 17, 2026
@pdurbin pdurbin removed their assignment Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FY26 Sprint 23 FY26 Sprint 23 (2026-05-06 - 2026-05-20) FY26 Sprint 24 FY26 Sprint 24 (2026-05-20 - 2026-06-03) FY26 Sprint 25 FY26 Sprint 25 (2026-06-03 - 2026-06-17) FY26 Sprint 26 FY26 Sprint 26 (2026-06-17 - 2026-07-01) FY27 Sprint 1 FY27 Sprint 1 (2026-07-01 - 2026-07-15) FY27 Sprint 2 FY27 Sprint 2 (2026-07-15 - 2026-07-29)

Projects

Status: Ready for QA ⏩

Development

Successfully merging this pull request may close these issues.

7 participants