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

fix allowedRolesAndUsers by using 'Access contents information' #2723

Merged
merged 2 commits into from
Feb 6, 2019

Conversation

agitator
Copy link
Member

@agitator agitator commented Feb 6, 2019

fixes #260

@ale-rt
Copy link
Member

ale-rt commented Feb 6, 2019

As discussed in the Alpine city sprint we merge this

@ale-rt ale-rt merged commit 184d80d into master Feb 6, 2019
@ale-rt ale-rt deleted the fix_allowed_users_and_roles branch February 6, 2019 10:36
@jaroel
Copy link
Member

jaroel commented Feb 6, 2019

Can we get the discussion in here as well?

I doubt if this is correct, as allowedRolesAndUsers is used to filter out objects that the user cannot view.
If you also want to check for Access contents information as well, that's great!

@ale-rt
Copy link
Member

ale-rt commented Feb 6, 2019

I see your point and we can even use both permission or even list permissions in a registry record so that everybody can do what he prefers.
I think the point here is that once the proper permission for getting catalog items was the "Access contents information" and then it was changed to "View", at least this is what I heard so this is resetting the behavior this permission was introduced for.
I would appreciate some more insights about this PR by other people and some example of how this commit can cause problems.

@jaroel
Copy link
Member

jaroel commented Feb 6, 2019 via email

@agitator
Copy link
Member Author

agitator commented Feb 6, 2019

Which workflow within Plone doesn't use those two permissions in combination?

@jaroel
Copy link
Member

jaroel commented Feb 6, 2019 via email

@jensens
Copy link
Sponsor Member

jensens commented Feb 6, 2019

@jaroel I dont agree. -1 on revert.

If you used the permission in a different way as it was intended to use, then you need to fix the customization.

Access Content Information is meant for metadata such as in listings. View is meant for object access and viewing it. Both was mixed in past. And that was very bad. Now, with this change, View is free for the real intended meaning to use.

In case of your customization you either need to check if you want to set a link to it if you do not have view access or you need to redirect the user to a login page with came_from to the page. This could be done in core as well, but I am pretty sure there is no way satisfying all use-cases.

@jaroel
Copy link
Member

jaroel commented Feb 6, 2019 via email

@jensens
Copy link
Sponsor Member

jensens commented Feb 6, 2019

so, @ale-rt just brought up the idea to make this configureable - for special cases like yours - in the security controlpanel. What about that?

@jensens
Copy link
Sponsor Member

jensens commented Feb 6, 2019

and View is not the correct permission check, there I strongly disagree.

@jaroel
Copy link
Member

jaroel commented Feb 6, 2019

@jensens View is not the right permission to check if a user can view an object??

@jensens
Copy link
Sponsor Member

jensens commented Feb 6, 2019

View is not the right permission to check to get the metadata. What we do with the catalog. Your assumption is wrong or at least different than ours here.

@jaroel
Copy link
Member

jaroel commented Feb 6, 2019 via email

@jensens
Copy link
Sponsor Member

jensens commented Feb 6, 2019

so, allowedRolesAndUsers is used in the filtered searchResults. Which returns catalog brains. And catalog brains are metadata. We may need two indexes then, one for searchResults and one specific for for object access. But I dont like to blow up the catalog for a case the standard Plone anyways would not run in. Since you use it different, I propose to make the cataloged permission configurable for your specific use-case, but stick to what one would expect to get from the catalog: brains one is allowed to see by quering the catalog, not objects to access.

@jaroel
Copy link
Member

jaroel commented Feb 6, 2019

so, allowedRolesAndUsers is used in the filtered searchResults.

Correct, so users don't get links to objects they cannot view.

Which returns catalog brains. And catalog brains are metadata.

Correct, but not relevant. We're not permission checking the brain, but the actual object.

We may need two indexes then, one for searchResults and one specific for for object access. But I dont like to blow up the catalog for a case the standard Plone anyways would not run in. Since you use it different, I propose to make the cataloged permission configurable for your specific use-case, but stick to what one would expect to get from the catalog: brains one is allowed to see by quering the catalog, not objects to access.

For object acces one can use unrestrictedSearchResults at the point where you need it.

I'd like allowedRolesAndUsers to be the same as it was since the introduction as it never was broken to begin with.

@lukasgraf
Copy link
Member

I completely agree with @jaroel here.

This change is not correct in my opinion. It breaks a contract that has been around for what seems like forever. The docstring (which hasn't even been updated in this PR) clearly states:

Return a list of roles and users with View permission.
Used to filter out items you're not allowed to see.

allowedRolesAndUsers is used to limit the set of objects that are returned from the filtered searchResults. If you now want to control access to metadata (on the brains) using Access contents information - why not.

+1 for revert from me.

@MrTango
Copy link
Contributor

MrTango commented Feb 24, 2020

one common use case to use "Access content information" is, to show folders in th navigation and when the user clicks on it having a login form because the user does not have the view permission.

@jensens
Copy link
Sponsor Member

jensens commented Feb 24, 2020

Better open a new issue than discussing on an closed PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Access Contents Information is not respected for Navigation and Listings
6 participants