Skip to content

Commit f9097a0

Browse files
committed
fix(auth): Fix broken PAS plugin config at root
Outside of the context of a Plone site, there usually isn't a `plone.keyring.interfaces.IKeyManager` but the GenericSetup "various" import step that adds the JWT token plugin to the Zope root `/acl_users` leaves the default keyring plugin setting which results in the following when authenticating to the Zope root: 2021-12-27 11:25:39,451 ERROR [Zope.SiteErrorLog:22][waitress-3] ComponentLookupError: http://localhost:49080/api/acl_users/credentials_cookie_auth/login Traceback (innermost last): Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents Module ZPublisher.WSGIPublisher, line 372, in publish_module Module ZPublisher.WSGIPublisher, line 266, in publish Module ZPublisher.mapply, line 85, in mapply Module ZPublisher.WSGIPublisher, line 63, in call_object Module Products.PluggableAuthService.plugins.CookieAuthHelper, line 279, in login Module Products.PluggableAuthService.PluggableAuthService, line 1153, in updateCredentials Module plone.restapi.pas.plugin, line 165, in updateCredentials Module plone.restapi.pas.plugin, line 260, in create_payload_token Module plone.restapi.pas.plugin, line 230, in _signing_secret Module zope.component._api, line 165, in getUtility zope.interface.interfaces.ComponentLookupError: (<InterfaceClass plone.keyring.interfaces.IKeyManager>, '') Fix this by doing an interface for the Plone portal and changing that configuration setting if not being installed into a Plone portal.
1 parent 8ef0667 commit f9097a0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/plone/restapi/setuphandlers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def install_pas_plugin(context):
4646
"ICredentialsResetPlugin",
4747
],
4848
)
49+
if not is_plone_site:
50+
plugin.use_keyring = False
4951

5052

5153
def post_install_default(context):

src/plone/restapi/upgrades/to0007.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ def enable_new_pas_plugin_interfaces(context):
2222
portal = getToolByName(context, "portal_url").getPortalObject()
2323
for uf, is_plone_site in pas.iter_ancestor_pas(portal):
2424
for jwt_plugin in uf.objectValues(plugin.JWTAuthenticationPlugin.meta_type):
25+
if not is_plone_site and jwt_plugin.use_keyring:
26+
logger.info(
27+
"Disabling keyring for plugin outside of Plone: %s",
28+
"/".join(jwt_plugin.getPhysicalPath()),
29+
)
30+
jwt_plugin.use_keyring = False
2531
for new_iface in (
2632
plugins_ifaces.ICredentialsUpdatePlugin,
2733
plugins_ifaces.ICredentialsResetPlugin,

0 commit comments

Comments
 (0)