Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ZMS PAS plugins work with Py2/Zope2 #6

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Products/zmsPluggableAuthService/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from Products.PluggableAuthService.PluggableAuthService import registerMultiPlugin

from .plugins import ZMSPASCookieAuthHelper, ZMSPASSsoPlugin, ZMSPASRolePlugin, ZMSPASUserPlugin
from Products.zmsPluggableAuthService.plugins import ZMSPASCookieAuthHelper, ZMSPASSsoPlugin, ZMSPASRolePlugin, ZMSPASUserPlugin

registerMultiPlugin(ZMSPASCookieAuthHelper.ZMSPASCookieAuthHelper.meta_type)
registerMultiPlugin(ZMSPASSsoPlugin.ZMSPASSsoPlugin.meta_type)
Expand All @@ -36,7 +36,7 @@ def initialize(context):
ZMSPASSsoPlugin.manage_addZMSPASSsoPluginForm,
ZMSPASSsoPlugin.addZMSPASSsoPlugin, )
, visibility=None
, icon='plugins/www/CookieAuthHelper.gif'
, icon='plugins/www/plug.svg'
)

context.registerClass( ZMSPASCookieAuthHelper.ZMSPASCookieAuthHelper
Expand All @@ -45,7 +45,7 @@ def initialize(context):
ZMSPASCookieAuthHelper.manage_addZMSPASCookieAuthHelperForm,
ZMSPASCookieAuthHelper.addZMSPASCookieAuthHelper, )
, visibility=None
, icon='plugins/www/CookieAuthHelper.gif'
, icon='plugins/www/plug.svg'
)

context.registerClass( ZMSPASRolePlugin.ZMSPASRolePlugin
Expand All @@ -54,7 +54,7 @@ def initialize(context):
ZMSPASRolePlugin.manage_addZMSPASRolePluginForm,
ZMSPASRolePlugin.addZMSPASRolePlugin, )
, visibility=None
, icon='plugins/www/ZODBRoleManager.gif'
, icon='plugins/www/plug.svg'
)

context.registerClass( ZMSPASUserPlugin.ZMSPASUserPlugin
Expand All @@ -63,5 +63,5 @@ def initialize(context):
ZMSPASUserPlugin.manage_addZMSPASUserPluginForm,
ZMSPASUserPlugin.addZMSPASUserPlugin, )
, visibility=None
, icon='plugins/www/ZODBUserManager.gif'
, icon='plugins/www/plug.svg'
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@

from __future__ import absolute_import
from __future__ import print_function
from base64 import encodebytes, decodebytes
try:
from base64 import encodebytes, decodebytes
except ImportError:
# Py2
from base64 import encodestring as encodebytes
from base64 import decodestring as decodebytes
import binascii
from binascii import Error
from six.moves.urllib.parse import quote, unquote
Expand Down
9 changes: 7 additions & 2 deletions Products/zmsPluggableAuthService/plugins/ZMSPASSsoPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@
import logging
import re

from urllib.parse import quote
try:
from urllib.parse import quote
except ImportError:
# Py2
from urllib import quote


from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl.class_init import InitializeClass
Expand Down Expand Up @@ -191,7 +196,7 @@ def decryptToken(self, token, debug=False):
coder = TimedSerializer(secret_key=self.getSecretKey(),salt=self.SALT)
if token:
if isinstance(token,str):
token = bytes(token,'utf-8')
token = token.decode('utf-8')
d = coder.loads(token)
except:
logger.exception("can't decrypt token")
Expand Down
4 changes: 4 additions & 0 deletions Products/zmsPluggableAuthService/plugins/www/plug.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Login Path | `http://zms.hosting/auth/login` | the path for redirection fro
Login Pattern | `https?:\/\/(.*)\/manage` | the pattern of original url for redirection from challenge to SSO login.
Came From | `came_from` | the name of the request-parameter containing the original url the request came from
User ID Attributes | `user_id,sub` | the name(s) of the http header payload fields representing the user id.
*Optional\*:* Roles Name Attribute | `roles_attr` | the name of the http header payload field representing a list of roles.
*Optional\*:* `roles_attr` | `roles_attr` | the name of the http header payload field representing a list of roles.

\* *The ZMS PluggableAuthService SSO Plugin is able to extract the user roles; for this an attribute "roles_attr" (string type) must be added manually to the perperty list*
\* *The ZMS PluggableAuthService SSO Plugin is able to extract the user roles; for this a new attribute named "roles_attr" (string type) must be added manually to the property list*

## License
Copyright (c) 2000-2023 SNTL Publishing <https://www.sntl-publishing.com>, Berlin.
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',
install_requires=[
'six',
'Products.PluggableAuthService',
'Zope',
'Products.PluggableAuthService==1.11.0',
'Zope2==2.13.24',
'cryptography',
# 'AccessControl',
# 'Products.PageTemplates'
Expand Down