[Twisted-web] HTTP basic auth
Drew Perttula
drewp at bigasterisk.com
Wed Jan 9 00:19:19 EST 2008
Colin Alston wrote:
> class Page(object):
> def authenticateUser(self, request, passinfo):
> user, password = request.getUser(),
> md5.md5(request.getPassword()).digest()
FWIW, the nevow version is about the same:
class MyPage(athena.LivePage or rend.Page):
def renderHTTP(self, ctx):
request = inevow.IRequest(ctx)
username, password = request.getUser(), request.getPassword()
if self.useAuth and (username, password) == (x, y):
secure.info("rendering page because http auth is set")
return rend.Page.renderHTTP(self, ctx)
else:
request.setHeader('WWW-Authenticate', 'Basic
realm="topsecret"')
request.setResponseCode(http.UNAUTHORIZED)
return "Authentication required."
More information about the Twisted-web
mailing list