-
Notifications
You must be signed in to change notification settings - Fork 101
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
BrowserViews implement IPublishTraverse in Zope 4 which breaks allowed_attributes and allowed_interface #397
Comments
Anyone have a idea how to deal with this? The commits that refactorded |
I found out that Yuppie was the author of the changes in The changenotes make me guess these might be responsible for the issue:
|
…r on BrowserView" no bueno This reverts commit c897100.
@pbauer Is this issue still a problem for Plone or did you manage to find a proper workaround? (At least in union.cms it did not bite us, probably because we do not use this feature.) |
@jensens Do you have any info about this topic? |
Yes, this is still an issue. |
First of all, I don't know much about the internals here, but bear with me. I've tried to look at Yuppie's checkins from that period and it's clear that there's so much changed it's not going to be possible to unravel that and make sense of it. I'm looking at that mixed in class IMHO implementing a |
I have found code in In PR #610 I have done the first step and added a failing test. For comparison, it exercises the code path that would have been taken if the view did not implement Now we should think of a sensible |
Maybe the Another option would be to have Note: I don't think anything in Plone world is relying on the |
I've openend an issue for this and provided a workaround, |
I added a regression-test for this in plone/plone.app.event#306. With the first implementation (7febc46) that worked, with the current implementation (3d47465) it does not. I also found another feature in Plone that is broken because of this: Unlocking locked objects. That's almost as easy to test as enabling ical-upload to a folder and much more important. |
I've had a look a this today, following a request from @pbauer and I've got to say, I'm a bit confused. Firstly, it looks like the What's confusing me is why permissions are a problem at all. I'm sure I'm just misunderstanding, but the following appears to work for me:
(With an equivalent line that adds the whitelist in Products.Five, of course) That causes the ical view to work for me TTW (albeit with a CSRF error that I assume is unrelated) and causes @pbauer's test in plone.app.event to pass. It seems to me that if the I'm sure that there are other related approaches, like mutating Can someone tell me what I've missed? In the unlikely case that this is useful code, I've got some tests I can share too. |
Matthew Wilkes wrote at 2019-5-26 14:19 -0700:
...
What's confusing me is why permissions are a problem at all. I'm sure I'm just misunderstanding, but the following appears to work for me:
The `publishTravere` methods are relevant for traversal. Authentication
happens only after the traversal; therefore, during traversal,
the correct permissions are not yet set up.
The "normal" `ZPublisher` traversal works around this problem
by remembering which roles are required for the traversal
and delaying the check until after authentication has taken place.
Maybe, something like this is necessary also for `allowed_attributes`
and `allowed_interfaces`.
|
@MatthewWilkes There is a suggestion of @davisagli at the PR for this issue (#610) which I used as it seemed simpler to me. Could you please have a look at it? |
@d-maurer The correct permissions don't need to be set up for traversal, though. The |
Matthew Wilkes wrote at 2019-5-27 11:38 -0700:
@d-maurer The correct permissions don't need to be set up for traversal, though. The `allow_attributes` parameter to the metadirective ensures that the permissions are set appropriately for the attributes, it's not the job of the traverser to implement permission checks so it shouldn't matter that the user isn't set up yet.
The argument has been:
Currently, you cannot - during traversal - access attributes
not granted to "Anoynmous". This is because authentication happens
only after traversal.
I am not sure whether this is the real problem discussed in this issue.
If it is, then there are not many options:
* what the publisher currently does for "normal" attribute access:
grant the access tentatively and delay the permission check
until after authentication has happened
* move the authentication forward in the traversal process --
this will be difficult due to the semantics and flexibility
of Zope's authentication subframework
(where the object responsible for authentication can only be
determined late in the traversal process).
Of course, this applies only to attributes really accessed *during*
traversal - not to accesses that are only prepared by the traversal
but occur after the authentication.
|
#643 and zopefoundation/zope.browserpage#7 seem fix this issue if you are ok with the implementation. |
🎉 |
Thank you all! |
Branch: refs/heads/master Date: 2019-05-18T13:49:44+02:00 Author: Philip Bauer (pbauer) <bauer@starzel.de> Commit: plone/plone.app.event@3d466a9 Add regression-test for zopefoundation/Zope#397 Files changed: A news/306.bugfix A plone/app/event/tests/test_ical_import.py Repository: plone.app.event Branch: refs/heads/master Date: 2019-06-21T11:37:50+02:00 Author: Philip Bauer (pbauer) <bauer@starzel.de> Commit: plone/plone.app.event@727fb23 Merge pull request #306 from plone/add_regression_test_for_allowed_attributes Add regression-test for allowed_attributes Files changed: A news/306.bugfix A plone/app/event/tests/test_ical_import.py
Branch: refs/heads/master Date: 2019-05-18T13:49:44+02:00 Author: Philip Bauer (pbauer) <bauer@starzel.de> Commit: plone/plone.app.event@3d466a9 Add regression-test for zopefoundation/Zope#397 Files changed: A news/306.bugfix A plone/app/event/tests/test_ical_import.py Repository: plone.app.event Branch: refs/heads/master Date: 2019-06-21T11:37:50+02:00 Author: Philip Bauer (pbauer) <bauer@starzel.de> Commit: plone/plone.app.event@727fb23 Merge pull request #306 from plone/add_regression_test_for_allowed_attributes Add regression-test for allowed_attributes Files changed: A news/306.bugfix A plone/app/event/tests/test_ical_import.py
Pulls in fix for maintenance view not being traversable. See zopefoundation/Zope#397
In Zope 4 a
BrowserView
always implementsIPublishTraverse
which it did not in Zope 2.This breaks the way to make methods traveseable using
allowed_attributes
andallowed_interface
in zcml.Example:
dummy.py:
In Zope 2 (Plone 5.1) http://0.0.0.0:8080/Plone/foo/bar returned
foobar
. In Zope 4 (Plone 5.2) that throws a 404.The relavant code is in
BaseRequest.traverseName
:In Zope 4
IPublishTraverse.providedBy(ob)
is true for all BrowserViews because in https://github.com/zopefoundation/Zope/blob/master/src/Products/Five/browser/metaconfigure.py#L145 the classzope.browserpage.metaconfigure.simple
is injected in thebases
of eachBrowserView
. SinceFoo
has nopublishTraverse
of its own the one fromsimple
is called which then raisesNotFound
.The
mro
looks like this before the injection:And like this after it:
@jaroel and me were trying to figure out a solution but we require help.
This issue is a replacement for the original ticket plone/Products.CMFPlone#2624 which I moved to Zope since it is not directly related to Plone.
The text was updated successfully, but these errors were encountered: