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

Possible to create duplicate SecurableResourceGroupRoles #347

Closed
joe-crawford opened this issue Jul 21, 2022 · 0 comments · Fixed by #349
Closed

Possible to create duplicate SecurableResourceGroupRoles #347

joe-crawford opened this issue Jul 21, 2022 · 0 comments · Fixed by #349
Assignees
Labels
bug Something isn't working

Comments

@joe-crawford
Copy link
Contributor

Description

Validation in SecurableResourceGroupRole class on securableResourceId field should prevent creating multiple SRGRs with the same securableResourceId and userGroupId, however repeated POSTs to the /api/${securableResourceDomainType}/${securableResourceId}/groupRoles/${groupRoleId}/userGroups/${userGroupId} endpoint in quick succession can bypass this validation. The system then will be unable to start again once shut down as SRGR validation will fail at next startup.

Steps to reproduce

  1. Using the UI as Admin, create a top level folder.
  2. Open folder and click change permissions button to open user access groups modal
  3. Select Add Group, select editors, Editor in Group name and Access Level columns
  4. Quickly click green tick multiple times, multiple requests to add the SRGR will succeed

Expected behavior

Only one request to create the same SRGR should succeed, as per the SecurableResourceGroupRole domain validation.

Environment

Please complete the following information:

  • mdm-core latest develop
  • recent version of mdm-ui

Additional context

Related to mdm-ui/443 which has an approach to workaround the issue in the UI by greying out submission buttons. Creating multiple DataModels with the same label is likely to be a similar issue with non-atomic validation.

Grails unique documentation: http://docs.grails.org/latest/ref/Constraints/unique.html. Save does not fail in this case because the unique constraint isn't enforced at the database level.

Some thoughts:

  • Try to add constraint at DB level where possible so that save fails after validate
  • Can validates be removed so they happen within the save methods?
@joe-crawford joe-crawford added the bug Something isn't working label Jul 21, 2022
@joe-crawford joe-crawford moved this to Backlog in MDM State Jul 21, 2022
@aaronforshaw aaronforshaw self-assigned this Jul 22, 2022
@aaronforshaw aaronforshaw moved this from Backlog to In Progress in MDM State Jul 22, 2022
aaronforshaw added a commit that referenced this issue Jul 22, 2022
joe-crawford added a commit that referenced this issue Jul 25, 2022
gh-347 add a database constraint to prevent duplicate SecurableResourceGroupRole
Repository owner moved this from In Progress to Merged to Develop / Waiting to release in MDM State Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Merged to Develop / Waiting to release
2 participants