-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from plone/feat-zope-root-cookie-challenge
feat(setup): Zope root cookie login form profile
- Loading branch information
Showing
17 changed files
with
212 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Couldn't get `foo.*` module wildcards to work in `./pyproject.toml` | ||
[mypy-ordereddict] | ||
ignore_missing_imports = True | ||
[mypy-transaction] | ||
ignore_missing_imports = True | ||
[mypy-zope.*] | ||
ignore_missing_imports = True | ||
[mypy-ZODB.*] | ||
ignore_missing_imports = True | ||
[mypy-BTrees.*] | ||
ignore_missing_imports = True | ||
[mypy-zExceptions.*] | ||
ignore_missing_imports = True | ||
[mypy-AccessControl.*] | ||
ignore_missing_imports = True | ||
[mypy-Acquisition.*] | ||
ignore_missing_imports = True | ||
[mypy-OFS.*] | ||
ignore_missing_imports = TRUE | ||
[mypy-ZPublisher.*] | ||
ignore_missing_imports = True | ||
[mypy-App.*] | ||
ignore_missing_imports = True | ||
[mypy-AuthEncoding.*] | ||
ignore_missing_imports = True | ||
[mypy-DateTime.*] | ||
ignore_missing_imports = True | ||
[mypy-Products.*] | ||
ignore_missing_imports = True | ||
[mypy-plone.*] | ||
ignore_missing_imports = True | ||
|
||
# For some reason installing `types-*` didn't work | ||
[mypy-six.*] | ||
ignore_missing_imports = True | ||
[mypy-past.*] | ||
ignore_missing_imports = True | ||
[mypy-PIL.*] | ||
ignore_missing_imports = True | ||
|
||
# Zope interfaces break MyPy expectations and unfortunately I couldn't find a way to | ||
# ignore only the specific error MyPy reports: | ||
# `./src/Products/PlonePAS/interfaces/capabilities.py:57: error: Method must have at least one argument` | ||
[mypy-*.interfaces.*] | ||
ignore_errors = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Add separate `GenericSetup` profile to switch the Zope root `/acl_users` to use a simple | ||
cookie 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. [rpatterson] (#65) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ def getMemberInfo(memberId=None): | |
location, etc | ||
""" | ||
|
||
__all__ = (IMembershipTool, ) | ||
__all__ = ("IMembershipTool", ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0"?> | ||
<metadata> | ||
<version>4</version> | ||
<version>5</version> | ||
</metadata> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0"?> | ||
<metadata> | ||
<version>1</version> | ||
</metadata> |
2 changes: 2 additions & 0 deletions
2
src/Products/PlonePAS/profiles/root-cookie/plone-pas-zope-root-cookie.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Change the Zope root `/acl_users` to use a simple cookie login form instead of HTTP | ||
`Basic ...` for authentication. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
""" | ||
Upgrade steps specific to Plone's use of PAS. | ||
""" | ||
|
||
from Products.PlonePAS.plugins import cookie_handler | ||
from Products.PluggableAuthService.plugins import CookieAuthHelper | ||
|
||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def from4to5_fix_zope_root(context): | ||
""" | ||
Fix broken Zope root `/acl_users/` plugins. | ||
""" | ||
root = context.getPhysicalRoot() | ||
pas = root.acl_users.manage_addProduct['PluggableAuthService'] | ||
# Identify which interfaces should be considered PAS plugin interfaces | ||
plugin_ifaces = [ | ||
plugin_type_info["interface"] | ||
for plugin_type_info in root.acl_users.plugins.listPluginTypeInfo() | ||
] | ||
broken_meta_type = cookie_handler.ExtendedCookieAuthHelper.meta_type | ||
broken_plugins = root.acl_users.objectValues(broken_meta_type) | ||
for broken_plugin in broken_plugins: | ||
# Collect properties from old/broken plugin | ||
kwargs = dict( | ||
id=broken_plugin.id, | ||
title=broken_plugin.title, | ||
cookie_name=broken_plugin.cookie_name, | ||
) | ||
# Which PAS plugin interfaces has this plugin been activated for | ||
active_ifaces = [ | ||
plugin_iface | ||
for plugin_iface in plugin_ifaces | ||
if plugin_iface.providedBy(broken_plugin) | ||
and broken_plugin.id in root.acl_users.plugins.listPluginIds(plugin_iface) | ||
] | ||
# Delete the old/broken plugin | ||
logger.info( | ||
"Deleting broken %r plugin: %r", | ||
broken_meta_type, | ||
"/".join(broken_plugin.getPhysicalPath()), | ||
) | ||
root.acl_users.manage_delObjects([broken_plugin.id]) | ||
# Add the correct plugin | ||
logger.info( | ||
"Adding working %r plugin: %r", | ||
CookieAuthHelper.CookieAuthHelper.meta_type, | ||
"/".join(broken_plugin.getPhysicalPath()), | ||
) | ||
pas.addCookieAuthHelper(**kwargs) | ||
# Restore activated plugin interfaces | ||
for plugin_iface in active_ifaces: | ||
root.acl_users.plugins.activatePlugin( | ||
plugin_iface, | ||
kwargs["id"], | ||
) |