|
Nick
nick at dd.revealed.net
Wed Jan 19 13:44:57 EST 2005
You can ignore the user name if you choose; but prefilling the
authentication dialog, that's a browser thing.
Nick
Robert Thomas Davis wrote:
> Hey all
>
> My site requires a password to be accessed...I do not
> really care what the user name is. Thus, I would like
> to populate the login prompt with a default name, like
> user or admin, etc. Is this possible or is it
> possible to just prompt for a password and nothing
> else? I have included the code I am using (this code
> was clipped from an earlier post and modified).
>
> Thanks
>
> Rob
>
> def __auth__(req, user, passwd):
>
> # removed check for user=USER
>
> if passwd == PASS:
> # user has successfully authenticated
> sess = Session(req)
>
> if sess.has_key('max_inactive'):
> # this is an existing session
>
> # check length of inactivity
> elapsed = time.time() -
> sess['last']
>
> # reset timer for next request
> sess['last'] = time.time()
> sess.save()
>
> # compare elapsed inactivity to
> maximum allowed
> if elapsed >
> sess['max_inactive']:
> # it's been too long
>
> # uncomment to delete
> session (optional)
> sess.delete()
>
> # force user to
> reauthenticate
> return 0
> else:
> # still within time limit
> #
> req.write("Authorized.\n\n")
>
> # allow user to continue
> return 1
> else:
> # this must be a new session, so
> set session variables
>
> # set maximum inactivity allowed,
> in seconds
> sess['max_inactive'] = 500
>
> # initialize timer
> sess['last'] = time.time()
>
> sess.save()
>
> # do new session stuff here
> # req.write("Session
> started.\n\n")
>
> # allow user to continue
> return 1
> else:
> # wrong user or password, force user to
> reauthenticate
> return 0
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
|