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

Update WorkflowAPI to accept a list of permissions with a content submission #22418

Closed
wezell opened this issue Jun 15, 2022 · 4 comments · Fixed by #22585
Closed

Update WorkflowAPI to accept a list of permissions with a content submission #22418

wezell opened this issue Jun 15, 2022 · 4 comments · Fixed by #22585

Comments

@wezell
Copy link
Contributor

wezell commented Jun 15, 2022

If a user wants to post a new piece of content and permission it individually at the time of saving, they should be able to pass a Map<String,List> of permissions and the roles that have them, e.g.

"individualPermissions":{
   "READ":["34324324-2354325-324234","234324-23423-32432-324432","234234234-234234-324"],
   "ADD_TO":["34324324-2354325-324234","234324-23423-32432-324432","234234234-234234-324"],
   "WRITE":["34324324-2354325-324234","234324-23423-32432-324432","234234234-234234-324"],
   "PUBLISH":["34324324-2354325-324234","234324-23423-32432-324432","234234234-234234-324"],
   "EDIT_PERMISSIONS":["34324324-2354325-324234","234324-23423-32432-324432","234234234-234234-324"]
}


@jdotcms jdotcms self-assigned this Jun 16, 2022
jdotcms added a commit that referenced this issue Jun 16, 2022
jdotcms added a commit that referenced this issue Jun 17, 2022
jdotcms added a commit that referenced this issue Jun 17, 2022
jdotcms added a commit that referenced this issue Jun 17, 2022
jdotcms added a commit that referenced this issue Jun 17, 2022
jdotcms added a commit that referenced this issue Jun 27, 2022
jdotcms added a commit that referenced this issue Jun 27, 2022
nollymar pushed a commit that referenced this issue Jul 11, 2022
jdotcms added a commit that referenced this issue Jul 18, 2022
jdotcms added a commit that referenced this issue Jul 19, 2022
jdotcms added a commit that referenced this issue Jul 20, 2022
jdotcms added a commit that referenced this issue Jul 21, 2022
jdotcms added a commit that referenced this issue Jul 21, 2022
jdotcms added a commit that referenced this issue Jul 21, 2022
jdotcms added a commit that referenced this issue Jul 22, 2022
dsilvam pushed a commit that referenced this issue Jul 22, 2022
#22585)

* #22418 this refactor helps to make easier the swagger doc with the reponse entity view

* #22418 fixing it test

* #22418 fixing more unit test

* #22418 fixing more curl test
jdotcms added a commit that referenced this issue Jul 22, 2022
jdotcms added a commit that referenced this issue Jul 29, 2022
nollymar pushed a commit that referenced this issue Aug 8, 2022
* #22418 adding permissions to workflow api

* #22418 adding fixes to make it work

* #22418 adding changes to reset the permissions before add new ones

* #22418 adding the search roles

* #22418 adding doc examples

* #22418 adding search role by key

* #22418 adding doc

* #22418 adding more changes

* #22418 adding more changes

* Progress on Dot-Favorite-Page dialog

* #22357 migrate dot-favorite-page to core-web dir

* #22418 having an experiment for doc with swagger

* #22418 just adding swagger and more consistence output

* Created webcomponent dot-html-to-image

* #22418 Setting isAdmin property to map

* #22357 dot-favorite-page shows/hides SHARE WITH field based on admin role

* #22418 fixing an issue with response entity view

* FE code clean up and little improvements

* FE fix broken unit tests

* FE - added unit tests

* FE - Added dot-html-to-image webcomponent test

* FE - added gitignore path to webcomponent tests report

* FE - fix broken unit test

* FE - hide Star icon to activate Add Favorite Page

* FE - feedback dot-favorite-page

* FE - dot-alert styles z-index not needed anymore

* FE - Added component store in dot-favorite-page

* FE - PR feedback

* FE - PR feedback

* FE - fix ESLint issues

* FE - add remove eventlistener to avoid memory leaks

Co-authored-by: Alfredo Li <alfredo@dotcms.com>
Co-authored-by: nollymar <nollymarlonga@Nollymars-MacBook-Pro-2.local>
jdotcms added a commit that referenced this issue Aug 9, 2022
jdotcms added a commit that referenced this issue Aug 12, 2022
nollymar pushed a commit that referenced this issue Aug 12, 2022
* #22418 adding postman test

* #22418 adding unit test and some swagger doc

* #22418 adding unit test and some swagger doc

* #22418 adding index policy
@nollymar
Copy link
Contributor

nollymar commented Aug 12, 2022

These PRs contain part of the changes: #22717 and #22424

@nollymar
Copy link
Contributor

nollymar commented Sep 6, 2022

Internal QA: Needs work.

I found some details using System Workflow and this endpoint PUT localhost:8080/api/v1/workflow/actions/fire:

  1. The endpoint only works with Publish action.
    This works:
{
    "actionName": "publish",
    "comments": "publish content",
    "contentlet": {
      "contentType":"MyType",
      "title": "Content 1",
      "identifier": "db982967e39ffaf6262f00be12679728"
    },
    "individualPermissions": {
          "EDIT_PERMISSIONS":["02ae46fa-cb67-4ed8-82d5-f1f9a5e1d744"],
          "CAN_ADD_CHILDREN": ["e37accbd-6a67-4ff4-adfe-cff423030a0b"],
          "READ": ["9ad24203-ae6a-4e5e-aa10-a8c38fd11f17"],
          "WRITE":["b9236d3a-41d4-4efd-a695-cb0f758cbf86"],
          "PUBLISH":["d8beb217-1889-40dd-99ad-fbd3cab7c426", "d3e78673-044a-4e1e-a38a-56f48cc6d5a5", "9ad24203-ae6a-4e5e-aa10-a8c38fd11f17"]
    }
}  

but the Save action doesn't:

{
    "actionName": "save",
    "comments": "save content",
    "contentlet": {
      "contentType":"MyType",
      "title": "Content 1",
      "identifier": "db982967e39ffaf6262f00be12679728"
    },
    "individualPermissions": {
          "EDIT_PERMISSIONS":["02ae46fa-cb67-4ed8-82d5-f1f9a5e1d744"],
          "CAN_ADD_CHILDREN": ["e37accbd-6a67-4ff4-adfe-cff423030a0b"],
          "READ": ["9ad24203-ae6a-4e5e-aa10-a8c38fd11f17"],
          "WRITE":["b9236d3a-41d4-4efd-a695-cb0f758cbf86"],
          "PUBLISH":["d8beb217-1889-40dd-99ad-fbd3cab7c426", "d3e78673-044a-4e1e-a38a-56f48cc6d5a5", "9ad24203-ae6a-4e5e-aa10-a8c38fd11f17"]
    }
} 
  1. If I type an invalid roleId, the response is 200 (OK) and all the permissions added after the invalid one are ignored:
{
    "actionName": "publish",
    "comments": "publish content",
    "contentlet": {
      "contentType":"MyType",
      "title": "Content 1",
      "identifier": "db982967e39ffaf6262f00be12679728"
    },
    "individualPermissions": {
          "EDIT_PERMISSIONS":["02ae46fa-cb67-4ed8-82d5-f1f9a5e1d744"],
          "CAN_ADD_CHILDREN": ["e37accbd-6a67-4ff4-adfe-cff423030a0b"],
          "READ": ["dfgdgdfgdfg"], --> Invalid one
          "WRITE":["b9236d3a-41d4-4efd-a695-cb0f758cbf86"], --> Ignored
          "PUBLISH":["d8beb217-1889-40dd-99ad-fbd3cab7c426", "d3e78673-044a-4e1e-a38a-56f48cc6d5a5", "9ad24203-ae6a-4e5e-aa10-a8c38fd11f17"] --> Ignored
    }
}  

Question: What CAN_ADD_CHILDREN is supposed to do? I only noticed that it locks the role. Is it expected?

Screen Shot 2022-09-06 at 3 32 46 PM

Room for improvement:

  • If I send the individualPermissions field when updating a piece of content, I have to specify all the permissions for each role, otherwise, they are wiped out. For example:
    If I run:
{
    "actionName": "publish",
    "comments": "publish content",
    "contentlet": {
      "contentType":"MyType",
      "title": "Content 1",
      "identifier": "db982967e39ffaf6262f00be12679728"
    },
    "individualPermissions": {
          "EDIT_PERMISSIONS":["02ae46fa-cb67-4ed8-82d5-f1f9a5e1d744"],
          "CAN_ADD_CHILDREN": ["e37accbd-6a67-4ff4-adfe-cff423030a0b"],
          "WRITE":["b9236d3a-41d4-4efd-a695-cb0f758cbf86"], 
          "PUBLISH":["d8beb217-1889-40dd-99ad-fbd3cab7c426", "d3e78673-044a-4e1e-a38a-56f48cc6d5a5", "9ad24203-ae6a-4e5e-aa10-a8c38fd11f17"] 
    }
}  

and then:

{
    "actionName": "publish",
    "comments": "publish content",
    "contentlet": {
      "contentType":"MyType",
      "title": "Content 1",
      "identifier": "db982967e39ffaf6262f00be12679728"
    },
    "individualPermissions": {
          "EDIT_PERMISSIONS":["02ae46fa-cb67-4ed8-82d5-f1f9a5e1d744"],
          "CAN_ADD_CHILDREN": ["e37accbd-6a67-4ff4-adfe-cff423030a0b"],
          "PUBLISH":["d8beb217-1889-40dd-99ad-fbd3cab7c426", "d3e78673-044a-4e1e-a38a-56f48cc6d5a5", "9ad24203-ae6a-4e5e-aa10-a8c38fd11f17"] 
    }
}  

The WRITE permission is wiped out. I think the WRITE should be ignored unless I set []

  • Not part of the scope, but we should be able to send the userid or the role name because there is no way to get the roleId from UI (I had to query the database)

@jdotcms
Copy link
Contributor

jdotcms commented Sep 6, 2022

Good QA

Just to mention: the save works, but the save draft do not.
As an improvement the save draft actionlet should consider the permissions as the save actionlet does

@bryanboza
Copy link
Contributor

bryanboza commented Sep 15, 2022

Fixed, some things failing here, but the pending work was moved to new card #22993

@wezell wezell closed this as completed Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants