[Zope] LoginManager - how does it work?

Aleksander Salwa ololo@zeus.polsl.gliwice.pl
Sun, 8 Oct 2000 20:02:17 +0200 (CEST)


On Sat, 7 Oct 2000, ed colmar wrote:

> I've managed to get loginManager to install, but I am very confused as to
> what to do with it.

I was confused too :)

Now I have working instalation of LoginManager-0-8-7a1. It retrieves
users' data from ZODB, but it may be helpfull to understand how to
implement any other source, i.e. MySQL.
Probably I did it very dirty way, but it works ;)

First, I created my own UserSource class, adding it to source file
lib/python/Products/LoginManager/UserSources.py. Here comes the diff:


7c7
< from Products.ZPatterns.PlugIns import defaultConstructors
---
> from Products.ZPatterns.PlugIns import defaultConstructors, PlugIn
478a479,496
> 
> 
> 
> class OloloUserSource(BasicUserSource):
> 
>     """Moje własne źródło użytkowników"""
> 
>     meta_type = "Ololo User Source"
>     __plugin_kind__ = "User Source"
> 
> 
>     def retrieveItem(self,name):
>         Uzytkownicy=getattr(self.aq_parent, 'Uzytkownicy', None)
>         return getattr(Uzytkownicy, name, None)
> 
> 
> 
> 
489a508,514
>                        
>     )
> 
>     context.registerPlugInClass(
>         OloloUserSource,
>         permission = 'Add Ololo User Source',
>         constructors = defaultConstructors(OloloUserSource, globals()),


Method retrieveItem have to return user object with given name. I have
users inside folder Uzytkownicy beside acl_users.

Next thing to do is to create class representing users. It must have
LoginManager:LoginUser as a base class. So I made such ZClass. This class
has methods authenticateUser, domainsForUser, rolesForUser, which do real
work. (Users in folder Uzytkownicy are instances of that ZClass.)
This class contains some properties of user - login (it's just object's
id), name, other data. (Currently I store passwords externally, because I
need them to do POP3 authentication.)

Then, on management tab "User Sources" of your LoginManager instance, add
instance of your UserSource class. Check also for proper settings on
LoginMethods tab.


ololo@zeus.polsl.gliwice.pl

/--------------------------------------\
| `long long long' is too long for GCC |
\--------------------------------------/