Skip to content

Commit

Permalink
generalize uninstall for any OIDC plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
erral committed Mar 15, 2024
1 parent 5af56ff commit 4ea25ed
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/pas/plugins/oidc/setuphandlers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pas.plugins.oidc import logger
from pas.plugins.oidc import PLUGIN_ID
from pas.plugins.oidc.plugins import OIDCPlugin
from plone import api
from Products.CMFPlone.interfaces import INonInstallable
from zope.interface import implementer
from pas.plugins.oidc import utils


@implementer(INonInstallable)
Expand Down Expand Up @@ -90,18 +90,9 @@ def activate_challenge_plugin(context):

def uninstall(context):
"""Uninstall script"""
from pas.plugins.oidc.utils import PLUGIN_ID

pas = api.portal.get_tool("acl_users")

# Remove plugin if it exists.
if PLUGIN_ID not in pas.objectIds():
return
from pas.plugins.oidc.plugins import OIDCPlugin
for plugin in utils.get_plugins():
pas._delObject(plugin.getId())
logger.info(f"Removed OIDCPlugin {plugin.getId()} from acl_users.")

plugin = getattr(pas, PLUGIN_ID)
if not isinstance(plugin, OIDCPlugin):
logger.warning(f"PAS plugin {PLUGIN_ID} not removed: it is not a OIDCPlugin.")
return
pas._delObject(PLUGIN_ID)
logger.info(f"Removed OIDCPlugin {PLUGIN_ID} from acl_users.")

0 comments on commit 4ea25ed

Please sign in to comment.