|
Skora, Joseph
Joseph.Skora at jhuapl.edu
Wed Oct 27 19:12:16 EDT 2004
Please forgive me if this is covered somewhere, I have searched high and
low for a couple days.
I am expecting that using mod_python, sessions, and authentication, I
should be able to have a page that required login and re-requires the
login when the session expires. I may be mixing apples and potatos
though, so please correct me.
I am put together a page requiring authentication (passwd='ok' for any
user) and then have the login timeout when the session expires. My page
is
from mod_python import apache, Session
--------------------
def handler(req):
req.content_type = 'text/html'
user = req.session.has_key('user') and req.session['user'] or
'Unknown'
req.write("Hello World (%s)!<br>" % user)
return apache.OK
def authenhandler(req):
req.session = Session.Session(req, timeout=10.0)
passwd = req.get_basic_auth_pw()
user = req.user
if req.session.is_new():
req.session['passwd'] = passwd
req.session['user'] = user
req.session.save()
if passwd == 'ok':
return apache.OK
else:
return apache.HTTP_UNAUTHORIZED
------------------------
It all appears to be setup ok, but the session expires without requiring
a new login. How do I require a re-login when the session has expired?
Thanks,
Joe Skora
joseph.skora at jhuapl.edu
|