Related issue
https://www.drupal.org/project/drupal/issues/2915792
Patch #3 in https://www.drupal.org/project/drupal/issues/2915792 helps partially.
After applying patch #3 - JSON for menu_link_content/menu_link_content starts showing up fine for anonymous users.
But the problem occurs when we have fields referring to menus and we add includes to those fields in our JSON query. The include in such a scenario fails with a 403 error, as anonymous users do not have access to menu.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | jsonapi_menu_403_fix-2967986-4.patch | 1.59 KB | alex.skrypnyk |
| #2 | jsonapi_menu_403_fix-2967986-2.patch | 1.53 KB | gargsuchi |
Comments
Comment #2
gargsuchi commentedPatch attached for fix.
Comment #3
gabesulliceI'm not sure what the "1" here is supposed to mean, can you explain?
I don't think JSON API module should start making special exceptions for entity types. Unfortunately, I can't take this patch as is.
I would recommend implementing
hook_entity_accessin a custom module for themenuandmenu_link_contententity types and/or giving anonymous users the appropriate permissions to view them. Then, those access rules will be picked up automatically and honored by JSON API.Thanks for the report and patch though!
Comment #4
alex.skrypnykAttached is an updated version of the patch in #2 for those who needs this functionality.
Comment #5
wim leers#2 + #4: Note that
view labelsupport is present in JSON API 2.x: #2843922: Show label of inaccessible entities ('view' access denied) when 'view label' access is allowed. The patches in #2 and #4 introduce a security vulnerability though!