LoginManager - how does it work?
I've managed to get loginManager to install, but I am very confused as to what to do with it. I've read the how-tos on zope.org, and the documentation of LoginManager itself... But I still don't understand what is supposed to happen. A User Source is a location to find users, Say, my SQL database, right? How do I tell it to use the SQL methods I have for retrieveing passwords? The how-tos say to create dtml-methods called "userAuthenticate" "userExists" and "userRoles". Where do these go? Can anyone help me see the light on this? Thank you
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 | \--------------------------------------/
Thanks for the help! Still looking for that HOWTO.txt So, now I have a UserSource Installed into my LoginManager. It is called "pgcrypt" and is supposed to authenticate to a SQL database. The password stored in the DB is encryputed using the same scheme. Any ideas why it doesn't let me in? Is there any way to troubleshoot this? It seems like there should be a way to tell if it's going to work or not form the management interface. Here's what I added to UserSources.py: class PGCryptUserSource(BasicUserSource): """ A sql based encrypted user source """ meta_type="PG Crypt User Source" __plugin_kind__="User Source" def retrieveItem(self, name): self.getcustbyusername(username=name) def rolesForUser(self, user): name = user.getUserName() res = self.getcustbyusername(username=name) fields2index={} fieldnames=res._schema.items() for i in range(len(fieldnames)): fields2index[fieldnames[i][0]]=fieldnames[i][1] roles=res[0][fields2index['roles']] return roles def domainsForUser(self, user): name = user.getUserName() res = self.getcustbyusername(username=name) fields2index={} fieldnames=res._schema.items() for i in range(len(fieldnames)): fields2index[fieldnames[i][0]]=fieldnames[i][1] domains=res[0][fields2index['domains']] return domains def authenticateUser(self, user, password, request): name = user.getUserName() res = self.getcustbyusername(username=name) fields2index={} fieldnames=res._schema.items() for i in range(len(fieldnames)): fields2index[fieldnames[i][0]]=fieldnames[i][1] passwd=res[0][fields2index['password']] if crypt.crypt(password,'ab')==passwd: return 1 else: return 0 +++++ context.registerPlugInClass( PGCryptUserSource, permission = 'Add PGCrypt UserSource', constructors = defaultConstructors(PGCryptUserSource,globals()), )
On Tue, 10 Oct 2000, ed colmar wrote:
So, now I have a UserSource Installed into my LoginManager. It is called
I remember I had some troubles trying to put methods rolesForUser, domainsForUser, authenticateUser in UserSource class. They can be moved to user class. I did so. But your case is harder then mine, cause you don't have objects representing users in ZODB. Maybe there are problems with retrieveItem method ? Maybe you should build wrapper class around your database data - something like "pluggable brains" ? I have no more ideas :( ololo@zeus.polsl.gliwice.pl /--------------------------------------\ | `long long long' is too long for GCC | \--------------------------------------/
Has anyone been able to use LoginManager with a SQL db? with or without encryption? I'm still baffled by this how-to: http://www.zope.org/Members/jok/SQL_based_LoginManager In this example, there are dtml-methods that do the work of the UserSource, but there is no retrieveItem? I would really love to get this working instead of having to revert back to older depreciated products. Thanks for any help! -e- From: "Aleksander Salwa" <ololo@zeus.polsl.gliwice.pl>
I remember I had some troubles trying to put methods rolesForUser, domainsForUser, authenticateUser in UserSource class. They can be moved to user class. I did so. But your case is harder then mine, cause you don't have objects representing users in ZODB. Maybe there are problems with retrieveItem method ? Maybe you should build wrapper class around your database data - something like "pluggable brains" ? I have no more ideas :(
Well we use the UserDbFolder Product after havin the same/similar problems with the LoginManager :-) - Holger Am Fri, 13 Oct 2000 schrieben Sie:
Has anyone been able to use LoginManager with a SQL db? with or without encryption?
I'm still baffled by this how-to: http://www.zope.org/Members/jok/SQL_based_LoginManager
In this example, there are dtml-methods that do the work of the UserSource, but there is no retrieveItem?
I would really love to get this working instead of having to revert back to older depreciated products.
Thanks for any help!
-e-
From: "Aleksander Salwa" <ololo@zeus.polsl.gliwice.pl>
I remember I had some troubles trying to put methods rolesForUser, domainsForUser, authenticateUser in UserSource class. They can be moved to user class. I did so. But your case is harder then mine, cause you don't have objects representing users in ZODB. Maybe there are problems with retrieveItem method ? Maybe you should build wrapper class around your database data - something like "pluggable brains" ? I have no more ideas :(
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- ----------------------------------- catWorkX GmbH Hamburg Dipl.-Ing. Holger Lehmann Stresemannstr. 364 22761 Hamburg Tel: +49 40 890 646-0 Fax: +49 40 890 646-66 mailto:lehmann@catworkx.de http://www.catworkx.de http://www.catbridge.de
participants (3)
-
Aleksander Salwa -
ed colmar -
Holger Lehmann