Hi, I'm writing my first PAS plugin for Plone. I'm a little bit in trouble because I don't find a very simple tutorial from A to Z which explains me how to create it. I understood only that I've to create 2 py files: one ontaining initialize informations and another one with py class which contains the implementations of interfaces.

Can somebody explain me better what PAS needs to run my implementation? I would like that it would be displayed on /acl_users/ plugins on the section Authentication Plugins.

Next I'll attach my sources which are my "bad" iplementation of PAS plugin. Is it some near my implementation or have I missed all? = = = = = = = = ========================================================================
                                                        My first file: 
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"]=='':
                        login="admin"
                        password="gavroche"
                        return(login, password)
                else:
                        return(credentials["login"], credentials["password"])
classImplements(SSLAuth, IAuthenticationPlugin)
InitializeClass(SSLAuth)

= = = = = = = = ========================================================================
                                                __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, manage_addSSLAuth

def initialize(context):
        registerMultiPlugin(SSLAuth.meta_type)
        context.registerClass( SSLAuth,
                                        permission=add_user_folders,
                                        constructors=(manage_addSSLAuth,
                                                manage_addSSLAuth),
                                        visibility=None)



= = = = = = = = ========================================================================

= = = = = = = = ========================================================================

My Interface has an inplementation which is not coherent with my purposes.. it's Just a training one... :-)

_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to