Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fine grained access #208

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

fine grained access #208

wants to merge 13 commits into from

Conversation

palagdan
Copy link
Collaborator

@palagdan palagdan commented Sep 4, 2024

Resolves partially #202
Resolves partially #158

@palagdan palagdan requested a review from blcham September 4, 2024 14:21
@palagdan
Copy link
Collaborator Author

palagdan commented Sep 4, 2024

In the internal authorization, an admin user can assign roles using a multi-select input and can also remove roles as needed. These roles are then saved to the repository.
I can also add a group field, so admin can choose the specific group and roles will be added automatically.
Screenshot from 2024-09-04 16-19-56

Copy link

@blcham blcham left a comment

Choose a reason for hiding this comment

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

see my comments + tests are failing

@@ -4,15 +4,16 @@ import withI18n from "../../i18n/withI18n";
import { injectIntl } from "react-intl";
import HorizontalInput from "../HorizontalInput";
import UserValidator from "../../validation/UserValidator";
import { ACTION_STATUS, ROLE } from "../../constants/DefaultConstants";
import { ACTION_STATUS, ROLE, ROLE_TYPE } from "../../constants/DefaultConstants";
Copy link

Choose a reason for hiding this comment

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

what is role_type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is a mapper between roles and types

};

export const TYPE_ROLE = {
Copy link

Choose a reason for hiding this comment

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

Do we really need to duplicate strings from ROLE?

Copy link

Choose a reason for hiding this comment

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

can we use convention instead? see below

Copy link
Collaborator Author

@palagdan palagdan Sep 5, 2024

Choose a reason for hiding this comment

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

There may be an issue because some roles, such as admin and doctor, do not have the 'rm' prefix, making it difficult to differentiate them. Also there is a problem if we want to display roles in readable form such as "Publish Records" etc.

export const DELETE_ALL_RECORDS_TYPE = "http://onto.fel.cvut.cz/ontologies/record-manager/delete-all-records";
export const EDIT_ALL_RECORDS_TYPE = "http://onto.fel.cvut.cz/ontologies/record-manager/edit-all-records";
export const VIEW_ALL_RECORDS_TYPE = "http://onto.fel.cvut.cz/ontologies/record-manager/view-all-records";
export const DELETE_ORGANIZATION_RECORDS_TYPE =
Copy link

Choose a reason for hiding this comment

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

I suggest to infer local name from url by convention:

rm_ <--- 'http://onto.fel.cvut.cz/ontologies/record-manager/'

view_all_records <--- view-all-records

convention is that _ is used instead -

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I initially chose the (-) as the divider because I noticed in mode.ttl that other resources and properties use it, such as:

###  http://onto.fel.cvut.cz/ontologies/record-manager/has-last-editor
rm:has-last-editor rdf:type owl:ObjectProperty ;
                   rdfs:subPropertyOf rm:relates-to .


###  http://onto.fel.cvut.cz/ontologies/record-manager/has-member
rm:has-member rdf:type owl:ObjectProperty ;
              rdfs:subPropertyOf rm:relates-to ;
              owl:inverseOf rm:is-member-of .


###  http://onto.fel.cvut.cz/ontologies/record-manager/has-owner
rm:has-owner rdf:type owl:ObjectProperty ;
             rdfs:subPropertyOf rm:relates-to .

However, I will change it to _.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -8,3 +8,17 @@ export const RDFS_COMMENT = "http://www.w3.org/2000/01/rdf-schema#comment";
export const ADMIN_TYPE = "http://onto.fel.cvut.cz/ontologies/record-manager/administrator";
export const DOCTOR_TYPE = "http://onto.fel.cvut.cz/ontologies/record-manager/doctor";
export const IMPERSONATOR_TYPE = "http://onto.fel.cvut.cz/ontologies/record-manager/impersonator";
export const COMPLETE_RECORDS_TYPE = "http://onto.fel.cvut.cz/ontologies/record-manager/record-complete";
Copy link

Choose a reason for hiding this comment

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

inconsistent with reject_records ---> complete-records

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@palagdan
Copy link
Collaborator Author

palagdan commented Sep 5, 2024

@blcham
Now it looks like this:
Screenshot from 2024-09-05 19-45-33

The admin can choose the roles for users if he have role EDIT_USER. The group input currently does not function because we need to discuss how it should be implemented. It might be better to disable the Roles input and assign roles based on the chosen group.

The next point for discussion is how Keycloak will retrieve information about roles. Currently, Keycloak only gets information about roles for the current user, which makes it impossible to display accurate information about other users. I think it would be beneficial to configure the Keycloak plugin to also save this information.

@blcham
Copy link

blcham commented Sep 5, 2024

we do not want to assign roles, but role groups !! --- as we discussed we want to keep label "role" in RM-UI but assign there ONE role group ... but as i said if it is not changeable or even not visible there i fo not care that much -- it is not that important, we have keycloak for that.

@palagdan
Copy link
Collaborator Author

palagdan commented Sep 6, 2024

@blcham
I understand that we prefer not to assign roles manually but instead through group roles. However, I made manual role assignment possible solely for testing the UI with specific roles, such as the "edit user," "reject," and "complete" buttons, etc. I have developed a solution using internal authorization where users will only need to select a group role. Based on the selected group role, specific roles will automatically be assigned to the user, as you mentioned in a previous review.

In Keycloak authorization, I recommend not displaying the group role, as doing so would require storing it in a triple (via the plugin change).

So we will have these group roles if undestand correctly:

[OPERATOR_ADMIN]

  • publishing records
  • rejecting records
  • complete records
  • delete/edit/view organization records
  • edit users
  • codelist import

[OPERATOR_USER]

  • complete records

[SUPPLIER_ADMIN]

  • rejecting records
  • complete records
  • delete/edit/view organization records
  • delete/edit/view all records
  • edit users
  • codelist import

[SUPPIER]

  • complete records

[NON-ANONYMOUS QUESTIONARE]

  • complete records

@palagdan
Copy link
Collaborator Author

palagdan commented Sep 6, 2024

There is now a "Role Group" input that automatically assigns a roles to the user based on a group. I've left disabled roles input because there’s currently no other way to see which roles are assigned to the user, similar to how it's displayed in Keycloak. I can remove this if it’s not necessary for internal authorization.
Screenshot from 2024-09-06 16-36-38

In Keycloak, there is no "Role Group" or "Roles" option because, as mentioned before, this information should be stored in triples to show valid information. As you said, it’s not necessary for keycloak profile, as all the relevant information is already in Keycloak. Additionally, I’m not sure if we want to retrieve the role group from the token, as you previously mentioned that all the logic is based on roles, and the groups are only for demonstration purposes.
Screenshot from 2024-09-06 16-41-55

@@ -81,8 +82,45 @@ export const ACTION_STATUS = {

export const ROLE = {
ADMIN: "Admin",
DOCTOR: "Regular User",
DOCTOR: "Doctor",
Copy link

Choose a reason for hiding this comment

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

add comment that this is deprecated and will be replaced

@blcham
Copy link

blcham commented Oct 7, 2024

@palagdan I rebased this PR

@blcham blcham force-pushed the 202-fine-grained branch 6 times, most recently from 4351437 to 9b15576 Compare November 13, 2024 16:55
@blcham
Copy link

blcham commented Nov 13, 2024

@palagdan could you describe what the issue is and in which profile (I've lost it somehow :(

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.

2 participants