-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat(setup): Zope root cookie login form profile #66
Conversation
Improve the Zope root ZMI login UX, avoid all the HTTP `Authorization: Basic ...` edge cases and hassles. Switch the default authentication challenge for the Zope root `/acl_users` from HTTP `Authorization: Basic ...` to the cookie auth plugins basic login form. This should be a much better UX overall and shouldn't cause any fundamental issues. One can still use HTTP `Authorization: Basic ...` manually by adding credentials to the URL: http://admin:secret@localhost:8080/manage_main But may cause issues where tests expect the HTTP `Authorization: Basic ...` challenge response or existing uses where new Zope instances are created as a part of normal use (SAAS?). We could also consider adding an upgrade step to make this change to existing installations but that would be disruptive to any existing installations that require HTTP `Authorization: Basic ...`. I can't imagine why that would be, but we should probably expect those use cases to come out of the woodwork once an upgrade step is released.
These are linters that my editor uses by default because they are common linters, so might as well fix what we can and ignore the rest. As much as possible, I placed ignores that should apply across the code base in the appropriate configuration file rather than inline comments.
@jenkins-plone-org please run jobs |
This didn't seem to work. I ran the same Jenkins jobs that were run for my last PR manually:
But they all failed with the same error that seems unrelated to any code changes:
So I'm guessing that there's something broken in the Plone CI world ATM and that's why the checks have been disabled. LMK if I've got that wrong or there's anything I can do to get this reviewed. |
Is Jenkins broken, @ericof ? |
@plone/ai-team, @fredvd: Do you know anything about it? |
Yes, Jenkins is broken since this weekend. :-( |
Thanks for reaching out with the update, @mauritsvanrees @ericof, I'm sure you're way too busy! |
@rpatterson Jenkins is up and running again. The plugin configuration of jenkins somehow got borked after a Jenkins update this weekend. We're still looking into how that could happen, but all tests/jobs are active again. |
@rpatterson thanks for creating this Pull Request and helping to improve Plone! TL;DR: Finish pushing changes, pass all other checks, then paste a comment:
To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically. Happy hacking! |
Sorry, shouldn't close the PR. :-$ Thought this was the other issue on jenkins.plone.org repo. |
@jenkins-plone-org please run jobs |
Also run the `Products.PlonePAS` tests while [that PR is in review](plone/Products.PlonePAS#66 (comment)) and other auth work depends on it.
Also run the `Products.PlonePAS` tests while [that PR is in review](plone/Products.PlonePAS#66 (comment)) and other auth work depends on it.
Also run the `Products.PlonePAS` tests while [that PR is in review](plone/Products.PlonePAS#66 (comment)) and other auth work depends on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and well thought.
Alright, all checks are passing, so I think this is ready for merge, @jensens or whoever. |
I tried it out on an existing Plone 6 database where several Plone Sites exist already. I added a new Plone Site. Then go to portal_setup and install the Products.PlonePAS:root-cookie profile. Then as anonymous user go to http://localhost:8080/manage_main. This raises an Unauhtorized, which kicks in the challenge plugin. But this fails with a traceback:
So a login form is missing. |
Move the change of the default Zope root configuration from HTTP Basic auth to the cookie login form [into a separate GenericSetup upgrade step to make the change optional](plone/plone.restapi#1304 (comment)). This reverts commit 132c2c390801ff16393f214c1501252b240cb62a.
[A previous PR fixed the broken Zope root cookie plugin for new installs](17deb97) but didn't include an upgrade step for existing Zope instances/ZODBs. The issue is only revealed when `IChallengePlugin` is activated for the broken plugins, such as when the `Products.PlonePAS:root-cookie` profile is installed, and [a `Manager` tries to login to](#66 (comment)) the [Zope root ZMI](http://localhost:8080/manage_main). Add an upgrade step that fixes the issue for existing instances/ZODBs.
[Per feedback](#66 (comment)), use the new (to me) `post_handler` feature provided by `GenericSetup` as it is much better than littering the import step registry with one-off, profile-specific import steps.
beeb79d
to
22ba99f
Compare
@jenkins-plone-org please run jobs |
I didn't have test coverage for this after all as this is an upgrade step issue. So I rigged up a semi-manual test bed for reproducing upgrade/migration issues, and used that to reproduce this issue and add a And with that I'm back to a place where I think we're ready to finish reviews and merge. LMK what else anyone needs from me! |
Also run the `Products.PlonePAS` tests while [that PR is in review](plone/Products.PlonePAS#66 (comment)) and other auth work depends on it.
Is anyone able to finish reviewing this or help me draw attention to this to help finish review? CC: @avoinea, @thet, @jensens, @fredvd, @mauritsvanrees |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. There is some code for Python 2.7 compat left, but that is probably inherited and not part of this PR. Anyway, it would be nice to have it cleaned up along the way. OTOH it should not be a blocker for a merge here.
[Per feedback](#66 (comment)), back out the changes that are related to Python 2 compatibility since we no longer support versions before Python 3.6. I briefly evaluated actually removing the Python 2 compatibility for these lines, but I note that `six` is still in `install_requires` for the package/dist dependency metadata so I think there's significant work to be done to cleanup no longer needed compatibility code and I don't want to hold up this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it on a completely fresh database:
- create a Plone Site
- via portal_setup install the root-cookie profile
- it works
Existing database:
- go to a Plone site
- run the PlonePAS upgrade
- apply the root-cookie profile
- it works
So this is merge-worthy.
The only thing I wonder is: why is there an upgrade step for the default profile? I would think it is the responsibility of the root-cookie profile to make it work both in a completely fresh database and in an existing database and existing site. The way you have it now works, but I don't completely see the logic.
Does my reservation make sense?
Minor point, since it works, but still.
Woot! Thanks for double checking the existing ZODB cases.
That particular upgrade step fixes broken Zope root |
@jenkins-plone-org please run jobs |
Ah, I see. I missed that the setup was already fixed in a previous PR. Fine to merge when green. |
K, everything is green. Should I merge? If not, who should? CC: @mauritsvanrees @jensens |
I will merge. |
Branch: refs/heads/master Date: 2022-02-13T16:01:07-08:00 Author: Ross Patterson (rpatterson) <me@rpatterson.net> Commit: plone/Products.PlonePAS@7e6d9d5 feat(setup): Zope root Basic -> cookie login form Improve the Zope root ZMI login UX, avoid all the HTTP `Authorization: Basic ...` edge cases and hassles. Switch the default authentication challenge for the Zope root `/acl_users` from HTTP `Authorization: Basic ...` to the cookie auth plugins basic login form. This should be a much better UX overall and shouldn't cause any fundamental issues. One can still use HTTP `Authorization: Basic ...` manually by adding credentials to the URL: http://admin:secret@localhost:8080/manage_main But may cause issues where tests expect the HTTP `Authorization: Basic ...` challenge response or existing uses where new Zope instances are created as a part of normal use (SAAS?). We could also consider adding an upgrade step to make this change to existing installations but that would be disruptive to any existing installations that require HTTP `Authorization: Basic ...`. I can't imagine why that would be, but we should probably expect those use cases to come out of the woodwork once an upgrade step is released. Files changed: M src/Products/PlonePAS/setuphandlers.py M src/Products/PlonePAS/tests/test_setup.py Repository: Products.PlonePAS Branch: refs/heads/master Date: 2022-02-13T16:01:07-08:00 Author: Ross Patterson (rpatterson) <me@rpatterson.net> Commit: plone/Products.PlonePAS@660343d style(lint): Cleanup/ignore common linter errors These are linters that my editor uses by default because they are common linters, so might as well fix what we can and ignore the rest. As much as possible, I placed ignores that should apply across the code base in the appropriate configuration file rather than inline comments. Files changed: A mypy.ini M pyproject.toml M setup.cfg M src/Products/PlonePAS/interfaces/memberdata.py M src/Products/PlonePAS/interfaces/membership.py M src/Products/PlonePAS/patch.py M src/Products/PlonePAS/plugins/ufactory.py M src/Products/PlonePAS/sheet.py M src/Products/PlonePAS/tests/test_setup.py M src/Products/PlonePAS/tools/membership.py Repository: Products.PlonePAS Branch: refs/heads/master Date: 2022-02-13T16:01:07-08:00 Author: Ross Patterson (rpatterson) <me@rpatterson.net> Commit: plone/Products.PlonePAS@955a276 refactor(setup): More sensible import step define Files changed: M src/Products/PlonePAS/configure.zcml M src/Products/PlonePAS/profiles.zcml Repository: Products.PlonePAS Branch: refs/heads/master Date: 2022-02-25T01:24:34-08:00 Author: Ross Patterson (rpatterson) <me@rpatterson.net> Commit: plone/Products.PlonePAS@13c1766 feat(setup): Zope root cookie login form profile Move the change of the default Zope root configuration from HTTP Basic auth to the cookie login form [into a separate GenericSetup upgrade step to make the change optional](plone/plone.restapi#1304 (comment)). This reverts commit 132c2c390801ff16393f214c1501252b240cb62a. Files changed: A news/zope-root-cookie.feature A src/Products/PlonePAS/profiles/root-cookie/metadata.xml A src/Products/PlonePAS/profiles/root-cookie/plone-pas-zope-root-cookie.txt M src/Products/PlonePAS/profiles.zcml M src/Products/PlonePAS/setuphandlers.py M src/Products/PlonePAS/tests/test_setup.py Repository: Products.PlonePAS Branch: refs/heads/master Date: 2022-02-25T01:24:34-08:00 Author: Ross Patterson (rpatterson) <me@rpatterson.net> Commit: plone/Products.PlonePAS@1e9cd05 fix(setup): Existing broken Zope root cookie [A previous PR fixed the broken Zope root cookie plugin for new installs](plone/Products.PlonePAS@17deb97) but didn't include an upgrade step for existing Zope instances/ZODBs. The issue is only revealed when `IChallengePlugin` is activated for the broken plugins, such as when the `Products.PlonePAS:root-cookie` profile is installed, and [a `Manager` tries to login to](plone/Products.PlonePAS#66 (comment)) the [Zope root ZMI](http://localhost:8080/manage_main). Add an upgrade step that fixes the issue for existing instances/ZODBs. Files changed: A src/Products/PlonePAS/upgrades.py M src/Products/PlonePAS/profiles.zcml M src/Products/PlonePAS/profiles/default/metadata.xml Repository: Products.PlonePAS Branch: refs/heads/master Date: 2022-02-25T01:57:21-08:00 Author: Ross Patterson (rpatterson) <me@rpatterson.net> Commit: plone/Products.PlonePAS@22ba99f fix(setup): Use new pre/post profile handlers [Per feedback](plone/Products.PlonePAS#66 (comment)), use the new (to me) `post_handler` feature provided by `GenericSetup` as it is much better than littering the import step registry with one-off, profile-specific import steps. Files changed: M src/Products/PlonePAS/profiles.zcml M src/Products/PlonePAS/setuphandlers.py Repository: Products.PlonePAS Branch: refs/heads/master Date: 2022-03-08T12:53:01-08:00 Author: Ross Patterson (rpatterson) <me@rpatterson.net> Commit: plone/Products.PlonePAS@9810cde style(lint): Backout Python 2 compat lint cleanup [Per feedback](plone/Products.PlonePAS#66 (comment)), back out the changes that are related to Python 2 compatibility since we no longer support versions before Python 3.6. I briefly evaluated actually removing the Python 2 compatibility for these lines, but I note that `six` is still in `install_requires` for the package/dist dependency metadata so I think there's significant work to be done to cleanup no longer needed compatibility code and I don't want to hold up this PR. Files changed: M src/Products/PlonePAS/plugins/ufactory.py M src/Products/PlonePAS/sheet.py Repository: Products.PlonePAS Branch: refs/heads/master Date: 2022-03-09T00:03:21+01:00 Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> Commit: plone/Products.PlonePAS@bd1bcf0 Merge pull request #66 from plone/feat-zope-root-cookie-challenge feat(setup): Zope root cookie login form profile Files changed: A mypy.ini A news/zope-root-cookie.feature A src/Products/PlonePAS/profiles/root-cookie/metadata.xml A src/Products/PlonePAS/profiles/root-cookie/plone-pas-zope-root-cookie.txt A src/Products/PlonePAS/upgrades.py M pyproject.toml M setup.cfg M src/Products/PlonePAS/configure.zcml M src/Products/PlonePAS/interfaces/memberdata.py M src/Products/PlonePAS/interfaces/membership.py M src/Products/PlonePAS/patch.py M src/Products/PlonePAS/profiles.zcml M src/Products/PlonePAS/profiles/default/metadata.xml M src/Products/PlonePAS/setuphandlers.py M src/Products/PlonePAS/sheet.py M src/Products/PlonePAS/tests/test_setup.py M src/Products/PlonePAS/tools/membership.py
Thanks for merging! May I ask what the process is for release, @mauritsvanrees. I have another PR in another repo that depends on this so I just want to know what to track so I can move that other PR forward once this is released. |
The process is:
Or indeed you ask, if you need it sooner. :-) |
Wait, I am making some mistakes here. Hold on. |
Ah no, it is fine. I did get an error at first on install:
Strange. But second time it works. It should not have been using the |
Hehe, awesome and thanks much!
Odd indeed. Did you have any inkling that this could be related to my changes? |
No. For a moment I thought the creation of the release had somehow failed, and for another moment I thought I had forgotten to pull your changes before creating a release. But all was well after all. |
@mauritsvanrees @rpatterson Should we add the upgrade step also to plone.app.upgrade? |
In the We should add the |
Add separate
GenericSetup
profile to switch the Zope root/acl_users
to use a simplecookie login form. Useful when Zope root login and logout need to synchronize
authentication state between multiple plugins, which is not possible with HTTP
Basic ...
authentication.The use case for which I built this is Volto, specifically in the JWT token plugin from
plone.restapi
,but I think I've generalized things correctly to be useful in other such situations.