Active
Project:
Paragraphs
Version:
8.x-1.5
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Nov 2018 at 14:28 UTC
Updated:
29 Dec 2022 at 15:39 UTC
Jump to comment: Most recent
Getting error 403 and "message": {} in response while trying to add paragraphs to the node.
Comments
Comment #2
leet249 commentedComment #3
berdirYes, previously we didn't have any check there.
We could add a custom permission and check that in \Drupal\paragraphs\ParagraphAccessControlHandler::checkCreateAccess(), you can also do the same in a custom hook_ENTITY_TYPE_create_access() implementation.
Comment #4
leet249 commentedI'm struggling to understand why an additional permission is required. I'm authenticating each request made by a consumer using OAuth, which is assigned a role that already has the create paragraph permission.
Therefore, I was under the impression that I would be able to create the paragraph for any request format (i.e xml, json)?
Alternatively, would it be enough to add the request formats that can be enabled by REST (i.e xml, json) to the checkCreateAccess function?
Comment #5
berdir> which is assigned a role that already has the create paragraph permission.
That's the point. There is no such permission. Paragraphs access without any additional modules like the type permissions (which should actually work if you use that), *solely* work through the parent field access check in the UI. But if you create them through REST, then there is no such check and anyone can create paragraphs.
That is why the security update made this change as a stop-gap until a better solution can be found.
Comment #6
leet249 commentedThe paragraph type permissions is what I was missing!
I can confirm that it works with this additional module enabled and configured.
Comment #7
edmargomes commentedDoesn't work for me
Can someone help me?
Comment #8
edmargomes commentedI need only enable Paragraphs Type Permissions module
Comment #9
davisa commentedThis is actually an issue which should be addressed - by displaying correct error message or something of that sort. The #8 comment points it out, that Paragraphs Type Permissions module actually allows the paragraph to be created by using REST API.
Without it enabled I got error 403 and "message": {} response and was completely lost. I didn't do any extra configuration for Paragraphs Type Permissions though - enabling just worked.
Comment #10
stingray commentedI'm enabled Text: Create content, Video: Create content In Paragraphs Type Permissions for my REST user role, but still getting the error 403 and {"message":""} in response while trying to add some paragraphs to node created earlier.
here JSON for the Text Paragraph:
Here for the Video paragraph:
What permission am I missing here?
Comment #11
stingray commentedCheck on permission Paragraphs Type Permissions -> Bypass Paragraphs type content access control was missing here.
There was also a problem with the JSON request payload of the video paragraph, here the correct version:
And a correct/working version of the text paragraph JSON payload:
After fixing those issues and passing a successful (status: 200) update (patch) to the node with next JSON, I sill cant see those paragraphs in the node:
Code in python:
What I'm missing here?
Comment #12
markj commentedAlso reporting that I'm getting a 403 with
{"message":""}when trying to create a paragraph via REST. I have the Paragraphs Type Permissions enabled and my user is in the Bypass role. Here's my request:curl -v -i -u xxx:yyy -d "@node_1009_paragraph.json" -H "Content-type: application/json" "http://localhost:8000/entity/paragraph?_format=json"
and here's my paragraph JSON:
I'm running Drupal 9.4.0-dev and Paragraphs 8.x-1.14.
Comment #13
nnevillThere is quite similar issue - https://www.drupal.org/project/paragraphs/issues/3047678 so I've added it as related. Patches are the same but not sure which issue could be labeled as "duplicated".