Skip to content

feat: introductin root_role and derived_role (based on tags)#1282

Open
bolmsten wants to merge 49 commits intodevelopfrom
poc_dynamic_role_creation
Open

feat: introductin root_role and derived_role (based on tags)#1282
bolmsten wants to merge 49 commits intodevelopfrom
poc_dynamic_role_creation

Conversation

@bolmsten
Copy link
Contributor

@bolmsten bolmsten commented Dec 3, 2025

Screenshot 2025-12-10 at 11 46 35

Description

My proposal is to continue using pre-defined roles (now called root roles) and dashboards, but allow for the creation of dervied roles that has two attributes: “data access” and “permissions/config”. The derived roles link to the root roles and inherits the dashboard and the permissions of the root role. This means that much of the code can stay the same.

For example: I added a new root role with associated dashboard and created two derived roles ISIS_READ and CLF_READ—both using from the root role proposal_reader role. The only difference between the dervied roles is the data access tags. That would allow users to login and see a proposal table with only the proposals that has the instrument associated with their data access tag.

We can do minor configurations for each dashboard using a permission/config defined on the derived role and we can set the data access either by using tags.

It would also allow for different facilities to rename roles like FAP Reviewer to PEP Reviewer.

A derived role has the same functionality like the root role until tagged and then the data access is determined by the tag.

image image

@bolmsten bolmsten requested a review from a team as a code owner December 3, 2025 13:38
@bolmsten bolmsten requested review from TCMeldrum and removed request for a team December 3, 2025 13:38
@bolmsten bolmsten requested a review from janosbabik December 4, 2025 08:39
@bolmsten bolmsten changed the title Poc dynamic role creation Poc derivated role creation Dec 10, 2025
@bolmsten bolmsten changed the title Poc derivated role creation PoC: derivated role creation Jan 16, 2026
@bolmsten bolmsten changed the title PoC: derivated role creation PoC: Role creation Jan 16, 2026
@bolmsten bolmsten changed the title PoC: Role creation PoC: role creation Jan 16, 2026
@jekabs-karklins jekabs-karklins self-assigned this Feb 4, 2026
@jekabs-karklins jekabs-karklins changed the title feat: role creation feat: introductin root_role and derived_role (based on tags) Feb 13, 2026
@jekabs-karklins
Copy link
Contributor

Hello @mutambaraf,

After a couple of false positives, I got the PR to pass the end‑to‑end tests.

This PR introduces the proposal_reader role. It lets a tagged user view all proposals for the tagged instruments or calls—same access as a User Officer, but without permission to modify anything

Copy link
Contributor

@mutambaraf mutambaraf left a comment

Choose a reason for hiding this comment

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

Just this one comment still trying to get it to work on my dev.

DO
$$
BEGIN
IF register_patch('Add tags to role and set variable for default roles', 'Fredrik Bolmsten', 'tag_to_role', '2025-12-09') THEN
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to update this date its now to far in the past.

Copy link
Contributor

@mutambaraf mutambaraf left a comment

Choose a reason for hiding this comment

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

Looks good l have added some few comments

};

export default context;

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we also need this comment

if (!featureFlags.getEnabledFeatures().get(FeatureId.TAGS)) {
if (
!featureFlags.getEnabledFeatures().get(FeatureId.TAGS) ||
!featureFlags.getEnabledFeatures().get(FeatureId.OAUTH) // TODO implement method setUserRoles in StfcUserDataSource and remove this condition
Copy link
Contributor

Choose a reason for hiding this comment

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

I have opened this issue to remove this comment.

Comment on lines +116 to +124
: api({
toastSuccessMessage: 'Role created successfully',
}).createRole({
args: {
shortCode,
title,
description,
permissions,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

We have not implemented this but l am getting a success message when l try to create a role we may need to find a way to wait because the backend looks okay.

Comment on lines +38 to +42
const role = (await context.mutations.user.createRole(
context.user,
args
)) as Role | Error;
if (role instanceof Error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be nice to also log the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants