Authentification

Thomas Guettler st-newsgroups at thomas-guettler.de
Fri Feb 1 07:19:46 EST 2002


Michel Van den Bergh wrote:

> I need to add username/password authentification to my application
> (a la apache or samba). So I need an encrypted password file to
> authentificate against, together with some utilities to add/delete users
> etc..
> 
> Is there a standard (proven) python framework I can use?
> 


Zope has a usermanagement. But I think it is overkill to use it just for
authentication.


You can encrypt the password and store it a file.
zpasswd.py of zope does it like this:

def generate_passwd(password, encoding):
     encoding=string.upper(encoding)
     if encoding == 'SHA':
         pw = '{SHA}' + binascii.b2a_base64(sha.new(password).digest())[:-1]
     elif encoding == 'CRYPT':
         pw = '{CRYPT}' + crypt(password, generate_salt())
     elif encoding == 'CLEARTEXT':
         pw = password

     return pw

HTH,

thomas




More information about the Python-list mailing list