[mod_python] Authorization cache?

Graham Dumpleton graham.dumpleton at gmail.com
Fri May 23 23:41:32 EDT 2008


Please use reply-all and keep discussion on the list.

2008/5/24 SebK <seb_k at arcor.de>:
> Am Freitag, 23. Mai 2008 23:04:03 schrieben Sie:
>> 2008/5/24 SebK <seb_k at arcor.de>:
>> > Hello,
>> > i'm new at this list.
>> > I'am programming Python for two years.
>> >
>> > I am using mod_python PythonAuthHandler for an internal site.
>> > The authentication is done via an pickled dict objec on the filesystem.
>> > I've build in an password changing programm/script witch saves the
>> > changed dict to the file.
>> > Problem: After changing the password the new password dosn't work but the
>> > old one remains working.
>> >
>> > What could be wrong? Or what is missing?
>>
>> Do you cache the password database in memory after reading it for the
>> first time, or do you ensure you reread the database on every request?
>>
>> The processes in mod_python persist across requests, so if you are
>> relying on cached database in memory this will be the behaviour you
>> see.
>>
>> Graham
>
> My code is
>
> f = open(file, "r")
> db = load(f)
> f.close()
>
>>r_read = users.rights["read"]
>>
>>def authenhandler(req):
>>    pw = req.get_basic_auth_pw()
>>    user = req.user
>>    if user in db:
>>      pw = md5(pw).hexdigest()
>>      user = db[user]
>>      if pw == user.pw and user.hasRight(r_read):
>>        return apache.OK
>>    return apache.HTTP_UNAUTHORIZED
>
> so i guess it's saved in memory right?

Because you do it at global scope in the code file, yes.

Graham


More information about the Mod_python mailing list