[Erp5-report] r38859 fx.algrain - /experimental/bt5/erp5_credential/ExtensionTemplateItem/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Oct 4 10:58:57 CEST 2010
Author: fx.algrain
Date: Mon Oct 4 10:58:52 2010
New Revision: 38859
URL: http://svn.erp5.org?rev=38859&view=rev
Log:
Add support of ZODBUsers
Replace hardcoding of id of the ERP5 Remove User Manager by search by interface and classes.
Refactor import :
PluggableAuthService products is always present
ERP5RemoveUserManager can be not present
Set short variable name to use interfaces and classes in methods (with a more readable typo)
Modified:
experimental/bt5/erp5_credential/ExtensionTemplateItem/Credential.py
Modified: experimental/bt5/erp5_credential/ExtensionTemplateItem/Credential.py
URL: http://svn.erp5.org/experimental/bt5/erp5_credential/ExtensionTemplateItem/Credential.py?rev=38859&r1=38858&r2=38859&view=diff
==============================================================================
--- experimental/bt5/erp5_credential/ExtensionTemplateItem/Credential.py [utf8] (original)
+++ experimental/bt5/erp5_credential/ExtensionTemplateItem/Credential.py [utf8] Mon Oct 4 10:58:52 2010
@@ -2,6 +2,7 @@
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Fabien MORIN <fabien at nexedi.com>
+# Francois-Xaiver Algrain <fxalgrain at tiolive.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@@ -27,50 +28,63 @@
##############################################################################
from Products.CMFCore.utils import getToolByName
+from Products import PluggableAuthService
+from Products.ERP5Security.ERP5UserManager import ERP5UserManager
try:
- from Products import PluggableAuthService
- from Products.ERP5Security.ERP5UserManager import ERP5UserManager
-except ImportError:
- PluggableAuthService = None
-
+ from Products.ERP5Wizard.PAS.ERP5RemoteUserManager import ERP5RemoteUserManager
+except ImportError:
+ #Wizard tool can not be present
+ ERP5RemoteUserManager = None
+
+PluggableAuthServiceTool = PluggableAuthService.PluggableAuthService.PluggableAuthService
+IUserEnumerationPlugin = PluggableAuthService.interfaces.plugins.IUserEnumerationPlugin
+IAuthenticationPlugin = PluggableAuthService.interfaces.plugins.IAuthenticationPlugin
+ZODBUserManager = PluggableAuthService.plugins.ZODBUserManager.ZODBUserManager
def isLocalLoginAvailable(self, login):
"""
- Check for login avaibility with ERP5UserManager, return False if the login is already used,
- True instead
+ Check for login avaibility.
+ Use activated user enumeration plugin which are ERP5 or ZODB user manager
+ Return :
+ True : any user with this login
+ False : a user have this login
+ None : No founded PluggableAuthServiceTool with id acl_users
"""
if not login:
return False
portal = self.getPortalObject()
acl_users = getToolByName(portal, 'acl_users')
- if PluggableAuthService is not None and isinstance(acl_users,
- PluggableAuthService.PluggableAuthService.PluggableAuthService):
- #ERP5UserManager implement IUserEnumerationPlugin
- plugin_list = acl_users.plugins.listPlugins(
- PluggableAuthService.interfaces.plugins.IUserEnumerationPlugin)
+ if isinstance(acl_users,PluggableAuthServiceTool):
+ #List plugin which make user enumeration user enumeration
+ plugin_list = acl_users.plugins.listPlugins(IUserEnumerationPlugin)
for plugin_name, plugin_value in plugin_list:
- if isinstance(plugin_value, ERP5UserManager):
+ #we check with instance of ERP5UserManager and ZODBUserManager
+ if isinstance(plugin_value, (ERP5UserManager,ZODBUserManager,)):
user_list = plugin_value.enumerateUsers(id=login,
exact_match=True)
if len(user_list) > 0:
return False
- break
- return True
+
+ return True
+ return None
def isSingleSignOnEnable(self):
"""
- Check that 'nexedi_authentication' is in the PluggableAuthService plugins
- list
+ Check that a ERP5 Remote User manager is present as authentication plugin
"""
+ if ERP5RemoteUserManager is None:
+ return False
+
portal = self.getPortalObject()
acl_users = getToolByName(portal, 'acl_users')
- if PluggableAuthService is not None and isinstance(acl_users,
- PluggableAuthService.PluggableAuthService.PluggableAuthService):
- #ERP5UserManager implement IUserEnumerationPlugin
- plugin_list = acl_users.plugins.listPlugins(
- PluggableAuthService.interfaces.plugins.IAuthenticationPlugin)
- if 'nexedi_authentication' in dict(plugin_list).keys():
- return True
+ if isinstance(acl_users,PluggableAuthServiceTool):
+ #List plugin which make authentication
+ plugin_list = acl_users.plugins.listPlugins(IAuthenticationPlugin)
+ for plugin_name, plugin_value in plugin_list:
+ #Try to find an ERP5RemoteUserManager
+ if isinstance(plugin_value,ERP5RemoteUserManager):
+ #SSO is enable
+ return True
return False
More information about the Erp5-report
mailing list