Skip to content

Commit

Permalink
adjust for multiple instances of oidc plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
erral committed Mar 12, 2024
1 parent 3c18ed8 commit cb9b19d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/pas/plugins/oidc/services/oidc/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def json_body(self) -> dict:
def plugin(self) -> OIDCPlugin:
if not self._plugin:
try:
self._plugin = utils.get_plugin()
for plugin in utils.get_plugins():
if plugin.getId() == self.provider_id:
self._plugin = plugin
except AttributeError:
# Plugin not installed yet
self._plugin = None
Expand Down Expand Up @@ -77,7 +79,8 @@ def reply(self) -> dict:
"""
provider = self.provider_id
plugin = self.plugin
if not (plugin and provider == "oidc"):

if not plugin:
return self._provider_not_found(provider)

session = utils.initialize_session(plugin, self.request)
Expand Down
12 changes: 9 additions & 3 deletions src/pas/plugins/oidc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pas.plugins.oidc import logger
from pas.plugins.oidc import PLUGIN_ID
from pas.plugins.oidc import plugins
from pas.plugins.oidc.plugins import OIDCPlugin
from pas.plugins.oidc.session import Session
from plone import api
from typing import Union
Expand Down Expand Up @@ -77,10 +78,15 @@ def url_cleanup(url: str) -> str:
return url


def get_plugin() -> plugins.OIDCPlugin:
"""Return the OIDC plugin for the current portal."""
def get_plugins() -> list:
""" Return all OIDC plugins for the current portal."""
pas = api.portal.get_tool("acl_users")
return getattr(pas, PLUGIN_ID)
plugins_to_return = []
for plugin in pas.objectValues():
if isinstance(plugin, OIDCPlugin):
plugins_to_return.append(plugin)

return plugins_to_return


# Flow: Start
Expand Down

0 comments on commit cb9b19d

Please sign in to comment.