Re: [Zope] LoginManager - how does it work?

2000-10-10 Thread ed colmar

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()),
)




___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] LoginManager - how does it work?

2000-10-08 Thread Aleksander Salwa


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 wasne rdo uytkownikw"""
 
 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.


[EMAIL PROTECTED]

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


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




[Zope] LoginManager - how does it work?

2000-10-07 Thread ed colmar



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