Restapi: getting roles for search results?

how do I get the roles for the items of a search result? I can get the contributors but how do I get who has permissions?

eg. /@search?Subject=subsite&metadata_fields=contributors

allowedRolesAndUsers is an index, but not part of metadata. So by default not. you need to add custom metadata to the catalog.

I added the meta in the zmi and updated the catalog but it returns

"allowedRolesAndUsers": [

not the list of users with explicit permissions on the content

Not sure which permission you are wanting to check for. allowedRolesAndUsers specifically includes the roles and users who have the View permission. If you want to check a different permission, you'll have to implement your own indexer (look at allowedRolesAndUsers in CMFPlone as a starting point)

Ah, and there is an optimization: if Anonymous is allowed, then everyone is, so it only stores Anonymous: Products.CMFPlone/ at master · plone/Products.CMFPlone · GitHub

You may want to implement a custom metadata field. But be careful, for sites with many users this can be a huge list. It is probably something we do not want in Plone core.

Just an idea: If you dont need this often, maybe you could make a new restAPI end-point ? It is 'very easy with plone-cli'.

FYI That's Access contents information nowadays, not View.

1 Like