[Twisted-Python] Why would getUser()/getPassword() return ""?

Hi all, Before I move onto learning about cred, guard and more sophisticated authentication schemes, I'm trying to get a simple example working with basic HTTP authentication. I have a resource subclass who's render() method checks the values of request.getUsername() and request.getPassword(): class request_create(twisted.web.resource.Resource): isLeaf = 1 addSlash = 0 def render(self, request): if (not request.getUser()) or (not request.getPassword()): request.setResponseCode(401, 'Authentication required') return twisted.web.error.ForbiddenResource().render(request) # do work and render HTML ... The problem is that no matter what I try getUser() and getPassword() both return the string "" and the web browser never prompts for a username/password. Is the above enough for the simplest possible HTTP authentication approach in Twisted web or should I be setting HTTP headers before the request.getUser()/request.getPassword() is performed? Any advice much appreciated, Cheers, Stu -- :: Stuart Hungerford (stuart.hungerford@anu.edu.au) :: ANU Internet Futures Group

On Tue, 25 Nov 2003 16:03:32 +1100 Stuart Hungerford <stuart.hungerford@anu.edu.au> wrote:
Before I move onto learning about cred, guard and more sophisticated authentication schemes, I'm trying to get a simple example working with basic HTTP authentication.
See http://twistedmatrix.com/users/roundup.twistd/twisted/issue393 But you should also read the appropriate RFC. You need to return an Unauthorized status code (401) and appropriate header if you got no credentials in order to request browser to send it on next request. -- Itamar Shtull-Trauring http://itamarst.org/ Available for Python & Twisted consulting

Stuart Hungerford [Tue, Nov 25, 2003 at 04:03:32PM +1100]:
Before I move onto learning about cred, guard and more sophisticated authentication schemes, I'm trying to get a simple example working with basic HTTP authentication.
Checkout Twisted CVS, then Twisted/sandbox/tv/simplyguarded/ -- Michal Pasternak :: http://pasternak.w.lub.pl
participants (3)
-
Itamar Shtull-Trauring
-
Michal Pasternak
-
Stuart Hungerford