[Zope3-Users] Creating PluggableAuthentication problem.

Florian Lindner mailinglists at xgm.de
Wed Apr 19 07:32:06 EDT 2006


Am Mittwoch, 19. April 2006 09:54 schrieb Tobias Weber:
> > > I try to add a PluggableAuthentication and a PrincipalFolder
> > > automatically. When I add a principal to the PrincipalFolder it works
> > > fine, but the authentification of the User fails. When I add one more
> > > PluggableAuthentication manually and choose the automatically generated
> > > PrincipalFolder as authenticator plugin, it works.
> >
> > Did you have a look at this thread:
> > http://www.opensubscriber.com/message/zope3-users@zope.org/3786410.html
> >
> > There I pasted an example how I did it.
>
> Thank you,
> I  have tried this example:
>
> ensureUtility(bare, IAuthentication, '', PluggableAuthentication,
> name='pau', copy_to_zlog=False)
> pau = zapi.getUtility(IAuthentication, name='pau', context=self.context)
> pf = PrincipalFolder()
> pau['PrincipalFolder'] = pf
> pf_reg = UtilityRegistration(u'users', IAuthenticatorPlugin, pf)
> pau.registrationManager.addRegistration(pf_reg)
> pf_reg.status = ActiveStatus
> pau.authenticatorPlugins = (u'users',)
> pau.credentialsPlugins = (u'Zope Realm Basic-Auth',)
>
> But I have the same problem descriped above.
> Its frustating. There must be a trick to get it work.

I don't know what exactly did you do wrong but here is my code and it worked 
so far for me:


def onObjectAdded(event):
    """ Initializes the centershock object: adds und configures some utilities 
when being added. """
    
    if ICentershock.providedBy(event.object):
        if not ISite.providedBy(event.object):
            # Make it a site
            cs = event.object
            site_manager = LocalSiteManager(cs)
            cs.setSiteManager(site_manager)
            
                     
            # Add PAU
            pau = ensureUtility(cs, 
zope.app.security.interfaces.IAuthentication, '', 
zope.app.authentication.authentication.PluggableAuthentication , asObject = 
True)
            pau.credentialsPlugins = (u'Session Credentials',)
            
            principal_folder = 
zope.app.authentication.principalfolder.PrincipalFolder(prefix = "cs")
            pau["centershock users"] = principal_folder
            registration = UtilityRegistration("centershock users", 
zope.app.authentication.interfaces.IAuthenticatorPlugin, principal_folder)
            registration_manager = pau.registrationManager
            registration_manager.addRegistration(registration)
            registration.status = u'Active'
            pau.authenticatorPlugins = (u"centershock users",)

Hope that helps you,

Florian


More information about the Zope3-users mailing list