Skip to content

Commit

Permalink
Call getProperty only once when getting redirect_uris or scope.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauritsvanrees committed Jan 12, 2023
1 parent aa9f42c commit 14d2508
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog
1.0a4 (unreleased)
------------------

- Call getProperty only once when getting redirect_uris or scope.
[maurits]

- use getProperty accessor
[mamico]

Expand All @@ -16,7 +19,7 @@ Changelog
[alecghica]
- Fixed Python compatibility with version >= 3.6
[alecghica]
- check if url is in portal before redirect #2
- check if url is in portal before redirect #2
[erral]
- manage came_from
[mamico]
Expand Down
27 changes: 16 additions & 11 deletions src/pas/plugins/oidc/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from oic.utils.authn.client import CLIENT_AUTHN_METHOD
from plone.protect.utils import safeWrite
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import safe_unicode

# from Products.PluggableAuthService.interfaces.plugins import IChallengePlugin
# from Products.PluggableAuthService.interfaces.plugins import IExtractionPlugin
Expand All @@ -27,6 +26,12 @@
import logging
import string

try:
# Plone 6.0+
from plone.base.utils import safe_text
except ImportError:
# Plone 5.2
from Products.CMFPlone.utils import safe_unicode as safe_text

logger = logging.getLogger(__name__)
# _MARKER = object()
Expand Down Expand Up @@ -241,18 +246,18 @@ def get_oauth2_client(self):
return client

def get_redirect_uris(self):
if self.getProperty("redirect_uris"):
return [safe_unicode(u) for u in self.getProperty("redirect_uris")]
else:
return [
"{}/callback".format(self.absolute_url()),
]
redirect_uris = self.getProperty("redirect_uris")
if redirect_uris:
return [safe_text(uri) for uri in redirect_uris if uri]
return [
"{}/callback".format(self.absolute_url()),
]

def get_scopes(self):
if self.getProperty("scope"):
return [safe_unicode(u) for u in self.getProperty("scope")]
else:
return []
scopes = self.getProperty("scope")
if scopes:
return [safe_text(scope) for scope in scopes if scope]
return []


InitializeClass(OIDCPlugin)
Expand Down

0 comments on commit 14d2508

Please sign in to comment.