Commit d37df664 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud&master: Replace Custom Autenticator Plugin to use a Generic One.

   Drop SlapOSMachineAuthenticationPlugin to use ERP5ExternalAuthenticationPluging instead
parent 3dfc7f2e
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<global name="SlapOSMachineAuthenticationPlugin" module="Products.SlapOS.SlapOSMachineAuthenticationPlugin"/> <global name="ERP5ExternalAuthenticationPlugin" module="Products.ERP5Security.ERP5ExternalAuthenticationPlugin"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
...@@ -10,10 +10,18 @@ ...@@ -10,10 +10,18 @@
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>slapos_machine</string> </value> <value> <string>slapos_machine</string> </value>
</item> </item>
<item>
<key> <string>login_portal_type_list</string> </key>
<value> <string>ERP5 Login,Certificate Login</string> </value>
</item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>user_id_key</string> </key>
<value> <string>Remote-User</string> </value>
</item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
......
...@@ -3,7 +3,7 @@ slapos_plugin_dict = { ...@@ -3,7 +3,7 @@ slapos_plugin_dict = {
'IExtractionPlugin': [ 'IExtractionPlugin': [
'ERP5 Dumb HTTP Extraction Plugin', 'ERP5 Dumb HTTP Extraction Plugin',
'ERP5 Facebook Extraction Plugin', 'ERP5 Facebook Extraction Plugin',
'SlapOS Machine Authentication Plugin', 'ERP5 Extenal Authentication Plugin',
'ERP5 Access Token Extraction Plugin', 'ERP5 Access Token Extraction Plugin',
'ERP5 Google Extraction Plugin', 'ERP5 Google Extraction Plugin',
'ERP5 Facebook Extraction Plugin' 'ERP5 Facebook Extraction Plugin'
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from Products.ERP5Type.Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.PluggableAuthService.interfaces import plugins
from Products.PluggableAuthService.utils import classImplements
from Products.PluggableAuthService.plugins.BasePlugin import BasePlugin
from Products.PluggableAuthService.PluggableAuthService import DumbHTTPExtractor
#Form for new plugin in ZMI
manage_addSlapOSMachineAuthenticationPluginForm = PageTemplateFile(
'www/SlapOS_addSlapOSMachineAuthenticationPlugin', globals(),
__name__='manage_addSlapOSMachineAuthenticationPluginForm')
def addSlapOSMachineAuthenticationPlugin(dispatcher, id, title=None, REQUEST=None):
""" Add a SlapOSMachineAuthenticationPlugin to a Pluggable Auth Service. """
plugin = SlapOSMachineAuthenticationPlugin(id, title)
dispatcher._setObject(plugin.getId(), plugin)
if REQUEST is not None:
REQUEST['RESPONSE'].redirect(
'%s/manage_workspace'
'?manage_tabs_message='
'SlapOSMachineAuthenticationPlugin+added.'
% dispatcher.absolute_url())
class SlapOSMachineAuthenticationPlugin(BasePlugin):
"""
Plugin to authenicate as machines.
"""
meta_type = "SlapOS Machine Authentication Plugin"
security = ClassSecurityInfo()
def __init__(self, id, title=None):
#Register value
self._id = self.id = id
self.title = title
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['external_login'] = user_id
creds['remote_host'] = request.get('REMOTE_HOST', '')
creds['login_portal_type'] = "ERP5 Login"
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)
classImplements( SlapOSMachineAuthenticationPlugin,
plugins.ILoginPasswordHostExtractionPlugin)
InitializeClass(SlapOSMachineAuthenticationPlugin)
...@@ -38,7 +38,6 @@ content_constructors = () ...@@ -38,7 +38,6 @@ content_constructors = ()
portal_tools = () portal_tools = ()
from Products.PluggableAuthService.PluggableAuthService import registerMultiPlugin from Products.PluggableAuthService.PluggableAuthService import registerMultiPlugin
import SlapOSMachineAuthenticationPlugin
import SlapOSShadowAuthenticationPlugin import SlapOSShadowAuthenticationPlugin
def initialize(context): def initialize(context):
...@@ -48,14 +47,6 @@ def initialize(context): ...@@ -48,14 +47,6 @@ def initialize(context):
portal_tools=portal_tools, content_constructors=content_constructors, portal_tools=portal_tools, content_constructors=content_constructors,
content_classes=content_classes) content_classes=content_classes)
context.registerClass( SlapOSMachineAuthenticationPlugin.SlapOSMachineAuthenticationPlugin
, permission=ManageUsers
, constructors=(
SlapOSMachineAuthenticationPlugin.manage_addSlapOSMachineAuthenticationPluginForm,
SlapOSMachineAuthenticationPlugin.addSlapOSMachineAuthenticationPlugin, )
, visibility=None
, icon='www/portal.gif'
)
context.registerClass( SlapOSShadowAuthenticationPlugin.SlapOSShadowAuthenticationPlugin context.registerClass( SlapOSShadowAuthenticationPlugin.SlapOSShadowAuthenticationPlugin
, permission=ManageUsers , permission=ManageUsers
, constructors=( , constructors=(
...@@ -66,5 +57,4 @@ def initialize(context): ...@@ -66,5 +57,4 @@ def initialize(context):
) )
registerMultiPlugin(SlapOSMachineAuthenticationPlugin.SlapOSMachineAuthenticationPlugin.meta_type)
registerMultiPlugin(SlapOSShadowAuthenticationPlugin.SlapOSShadowAuthenticationPlugin.meta_type) registerMultiPlugin(SlapOSShadowAuthenticationPlugin.SlapOSShadowAuthenticationPlugin.meta_type)
<h1 tal:replace="structure here/manage_page_header">Header</h1>
<h2 tal:define="form_title string:Add SlapOS Machine Authentication Plugin"
tal:replace="structure here/manage_form_title">Form Title</h2>
<p class="form-help">
SlapOS Machine Authentication Plugin allows to login machines (Computers and
Software Instances)
</p>
<form action="addSlapOSMachineAuthenticationPlugin" method="post">
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="left" valign="top">
<div class="form-label">
Id
</div>
</td>
<td align="left" valign="top">
<input type="text" name="id" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-optional">
Title
</div>
</td>
<td align="left" valign="top">
<input type="text" name="title" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<div class="form-element">
<input class="form-element" type="submit" name="submit"
value=" Add " />
</div>
</td>
</tr>
</table>
</form>
<h1 tal:replace="structure here/manage_page_footer">Footer</h1>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment