简体   繁体   中英

django: caching passwords for custom authentication

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.

You may cache authentication credentials in sessions. If you are afraid that they may "leak" to disk, ie 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM