views:

46

answers:

2

I am authenticating users in ldap, but this happens only once, when user is logging in. Afterwards I need to keep username and password, because before every ldap operation I need to make bind on ldap server before every operation. What is the safe way to cache this password (I can't store in the database or cookies) for as long as session persists.

+1  A: 

solution 1: maybe the most elegant solution would be to write your own auth-backend and share it with the community :-)

solution 2: make use of the very good caching-api which django has build-in

renton
I have written my own auth-backend for ldap, but inside database I store unusable password. Where should I store the real one, so it would work as long as session is active?
gruszczy
why not dead simple in the session?
renton
renton: Because it is not safe. You cannot encrypt it since you will need it for further ldap operations.
Uszy Wieloryba
It the session is in the memory only it is pretty safe.
pajton
+2  A: 

You may cache authentication credentials in sessions. If you are afraid that they may "leak" to disk, i.e. be cached in database, you may use memory based sessions.

With cache session engine (Using cached sessions) and memory based sessions this should be accomplished easily.

pajton
that is exactly what i mean :-)
renton
Maybe, but you didn't say anything about sessions though.
pajton