-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Include protect.js for Plone 4? And Plone 5? #42
Comments
In plone/buildout.coredev#176 (comment) @idgserpro asks a similar question, but slight broader. Basically: should we include the |
We vote for adding protect.js to Plone 5 as well. All add-ons that need to be both compatible to Plone 4 and 5 will benefit from this. Somewhat related: https://community.plone.org/t/the-incredible-and-sad-tale-of-innocent-plone-5-and-its-heartless-add-ons/1437 @hvelarde FYI |
I'm indifferent to adding it to plone 5. I personally think people should know what they are doing about CSRF and get ugly errors when they write unsafe things; however, it will make things easier... If added to plone 5, some of the plone 4 specific bits should be removed. |
We already have some "magic" happening in plone.protect transforms, automatically adding tokens to our forms. The idea is to have this same ease of use but now in AJAX calls. Imagine you have a Plone 4 addon, using plone4.csrffixes. You have 50 ajax calls. You want to make it compatible with Plone 5. You have two options:
Our opinion is: if you don't need to explicitly add tokens to forms, you shouldn't need this in AJAX calls either. This is consistent with plone.protect README as well:
|
Alright, as I said, I'm indifferent. |
In essence, this is needed for Plone 5 only. Plone 4 installations that have plone4.csrffixes and plone.protect >= 3.0.x don't need it. Check plone/plone.protect#42 for mode details.
@mauritsvanrees Could you please add protect.js in plone.protect? |
This adds an `X-CSRF-TOKEN` header to ajax requests. Fixes #42
See pull request #49 which finally passes the tests. |
@mauritsvanrees fantastic! You are thinking pin plone.protect 3 in Plone 4.3? Or will we still depend of plone4.csrffixes? |
No, plone.protect will stay at 2.x. Moving to 3.x causes too many test failures. See also pull request #48. |
Branch: refs/heads/master Date: 2016-06-08T02:35:56+02:00 Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> Commit: plone/plone.protect@d6c2207 Added protect.js from plone4.csrffixes. This adds an `X-CSRF-TOKEN` header to ajax requests. Fixes plone/plone.protect#42 Files changed: A plone/protect/protect.js M CHANGES.rst M plone/protect/auto.py M plone/protect/configure.zcml Repository: plone.protect Branch: refs/heads/master Date: 2016-06-10T09:13:01+02:00 Author: Jens W. Klein (jensens) <jk@kleinundpartner.at> Commit: plone/plone.protect@b8c9557 Merge pull request #49 from plone/maurits-add-protect-js Added protect.js from plone4.csrffixes. Files changed: A plone/protect/protect.js M CHANGES.rst M plone/protect/auto.py M plone/protect/configure.zcml
Branch: refs/heads/master Date: 2016-06-08T02:35:56+02:00 Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> Commit: plone/plone.protect@d6c2207 Added protect.js from plone4.csrffixes. This adds an `X-CSRF-TOKEN` header to ajax requests. Fixes plone/plone.protect#42 Files changed: A plone/protect/protect.js M CHANGES.rst M plone/protect/auto.py M plone/protect/configure.zcml Repository: plone.protect Branch: refs/heads/master Date: 2016-06-10T09:13:01+02:00 Author: Jens W. Klein (jensens) <jk@kleinundpartner.at> Commit: plone/plone.protect@b8c9557 Merge pull request #49 from plone/maurits-add-protect-js Added protect.js from plone4.csrffixes. Files changed: A plone/protect/protect.js M CHANGES.rst M plone/protect/auto.py M plone/protect/configure.zcml
@mauritsvanrees this change breaks plone sites that follow the instructions on https://plone.org/security/hotfix/20151006 as both packages register protect.js
until today i thought i'd need to add plone4.csrffixes to my instance eggs if i want to activate the hotfix https://plone.org/security/hotfix/20151006 what's the official way to get around the above error? |
This adds `protect.js`, so we do not have to do this anymore. See issue plone/plone.protect#42
True, this gives a problem. This pull request should fix it: plone/plone4.csrffixes#22 plone.protect 3.x is still missing a few fixes, see #48 |
Basically, see plone/plone4.csrffixes#19
And possibly related thread on community.plone.org: https://community.plone.org/t/plone-protect-and-ajax-post-requests/2010
In short:
Plone 4.3.9 has all fixes from plone4.csrffixes included, except the plone.protect pin and the transform which adds
protect.js
and blesses a few read-on-writes. These read-on-writes are presumably already blessed by plone.protect 3.x or have been fixed in their respective packages. But the javascript still seems needed for best experience.Should we add this script on plone.protect master and perhaps include it only when the Plone version is 4.x? My guess is that adding it to the auto transform would work and is not too invasive.
Or is this something we should do in for example CMFPlone?
The text was updated successfully, but these errors were encountered: