[Erp5-report] r42407 luke - /erp5/trunk/products/Vifib/VifibMachineAuthenticationPlugin.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Jan 18 11:37:00 CET 2011
Author: luke
Date: Tue Jan 18 11:37:00 2011
New Revision: 42407
URL: http://svn.erp5.org?rev=42407&view=rev
Log:
- add extraction plugin implemlentation which uses REMOTE_USER and sets
machine_login, but fallback to default DumbHTTPExtractor in case if
no REMOTE_USER is set
- use machine_login instead of login, to be synchronised with value
from extraction plugin
Modified:
erp5/trunk/products/Vifib/VifibMachineAuthenticationPlugin.py
Modified: erp5/trunk/products/Vifib/VifibMachineAuthenticationPlugin.py
URL: http://svn.erp5.org/erp5/trunk/products/Vifib/VifibMachineAuthenticationPlugin.py?rev=42407&r1=42406&r2=42407&view=diff
==============================================================================
--- erp5/trunk/products/Vifib/VifibMachineAuthenticationPlugin.py [utf8] (original)
+++ erp5/trunk/products/Vifib/VifibMachineAuthenticationPlugin.py [utf8] Tue Jan 18 11:37:00 2011
@@ -40,6 +40,7 @@ from Products.PluggableAuthService.plugi
from Products.ERP5Type.Cache import transactional_cached
from Products.ERP5Security.ERP5UserManager import SUPER_USER
from ZODB.POSException import ConflictError
+from Products.PluggableAuthService.PluggableAuthService import DumbHTTPExtractor
#Form for new plugin in ZMI
manage_addVifibMachineAuthenticationPluginForm = PageTemplateFile(
@@ -93,24 +94,42 @@ class VifibMachineAuthenticationPlugin(B
meta_type = "Vifib Machine Authentication Plugin"
security = ClassSecurityInfo()
- manage_options = (({'label': 'Edit',
- 'action': 'manage_editVifibMAchineAuthenticationPluginForm',},
- )
- + BasePlugin.manage_options[:]
- )
-
def __init__(self, id, title=None):
#Register value
self._setId(id)
self.title = title
+ ####################################
+ #ILoginPasswordHostExtractionPlugin#
+ ####################################
+ security.declarePrivate('extractCredentials')
+ def extractCredentials(self, request):
+ """ Extract credentials from the request header. """
+ creds = {}
+ getHeader = getattr(request, 'getHeader', None)
+ if getHeader is None:
+ # use get_header instead for Zope-2.8
+ getHeader = request.get_header
+ user_id = getHeader('REMOTE_USER')
+ if user_id is not None:
+ creds['machine_login'] = user_id
+ creds['remote_host'] = request.get('REMOTE_HOST', '')
+ try:
+ creds['remote_address'] = request.getClientAddr()
+ except AttributeError:
+ creds['remote_address'] = request.get('REMOTE_ADDR', '')
+ return creds
+ else:
+ # fallback to default way
+ return DumbHTTPExtractor().extractCredentials(request)
+
################################
# IAuthenticationPlugin #
################################
security.declarePrivate('authenticateCredentials')
def authenticateCredentials(self, credentials):
"""Authentificate with credentials"""
- login = credentials.get('login', None)
+ login = credentials.get('machine_login', None)
# Forbidden the usage of the super user.
if login == SUPER_USER:
return None
@@ -149,5 +168,9 @@ class VifibMachineAuthenticationPlugin(B
#List implementation of class
classImplements(VifibMachineAuthenticationPlugin,
plugins.IAuthenticationPlugin)
+classImplements( VifibMachineAuthenticationPlugin,
+ plugins.ILoginPasswordHostExtractionPlugin
+ )
+
InitializeClass(VifibMachineAuthenticationPlugin)
More information about the Erp5-report
mailing list