[ZIZope] Plugin per zope PAS
Ermanno Gnan <[email protected]> Thu, 13 Dec 2007 14:51:18 +0100
| Newsgroups | gmane.comp.web.zope.italian |
|---|---|
| Message-ID | <[email protected]> |
Salve, è il primo plugin che scrivo per zope. Premetto che è "quasi" funzionante nel senso che avviando zope con fg non da alcun errore, solo che non so se è sufficiente quello che ho fatto poiché non trovo il mio plugin nella cartella plugins di acl_users. Qualcuno potrebbe gentilmente darci un'occhiata al volo? il plugin è molto semplice e non fa quasi nulla però sono ancora alle prime fasi in cui devo vedere se zope me lo "mangia"! Allego il contenuto dei fles! = = = = = = = = = = = = = ======================================================================== FILE PYTHON:SSLAuth.py = = = = = = = = = = = = = ======================================================================== ############################################################################## # # Copyright (c) 2004 Zope Corporation and Contributors. All Rights # Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this # distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. ############################################################################## """ Class: SSLAuth $Id: SSLAuth,v 1.0 2007/12/13 12:40:20 Ermanno Gnan $ """ #Per funzionare come plugin PAS deve implementare le interfacce ed estendere un BasePlugin from Products.PluggableAuthService.plugins.BasePlugin import BasePlugin from Products.PluggableAuthService.interfaces.plugins import IAuthenticationPlugin #, IExtractionPlugin from Products.PluggableAuthService.utils import classImplements from App.class_init import default__class_init__ as InitializeClass #costruttore del plugin def manage_addSSLAuth( dispatcher, id='credentials_sslauth', title=None, REQUEST=None): """ Aggiunge il plugin a PAS """ #inizializza il plugin sp = SSLAuth( id, title ) dispatcher._setObject( sp.getId(), sp) if REQUEST is not None: REQUEST['RESPONSE'].redirect( '%s/manage_workspace' '?manage_tabs_message=' 'SSLAuth+added.' % dispatcher.absolute_url() ) #classe che implementa le interfacce class SSLAuth (BasePlugin): meta_type = 'SSLAuth' __implements__ = (getattr(BasePlugin,'__implements__',()),) #implementazione dell'interfaccia IAuthenticationPlugin def authenticateCredentials(self, credentials): if credentials["login"]=="ermanno" and credentials["password"] is null: login="admin" password="gavroche" return(login, password) else: return(credentials["login"], credentials["password"]) classImplements(SSLAuth, IAuthenticationPlugin) InitializeClass(SSLAuth) = = = = = = = = = = = = = ======================================================================== FILE PYTHON:__init__.py = = = = = = = = = = = = = ======================================================================== """ Installer del plugin """ #Carico la libreria per l'installer from Products.PluggableAuthService.PluggableAuthService import registerMultiPlugin from zLOG import LOG, INFO, ERROR, WARNING from AccessControl.Permissions import add_user_folders from SSLAuth import SSLAuth def initialize(context): try: registerMultiPlugin(SSLAuth.meta_type) except: pass context.registerClass( SSLAuth, permission=add_user_folders, constructors=(localrole.manage_addSSLAuth, localrole.manage_addSSLAuth), visibility=None )