[Twisted-web] Authentication not working

Viatcheslav Gachkaylo vgachkaylo at gmail.com
Mon Jul 18 08:43:58 EDT 2011


Hello.

I ask you to help me finding the source of problems with the following code.
The result of opening page at
https://serveraddr:serverport/services/admin is 403 Forbidden.
It needs to show the output from UpdateManager.render_GET().
In server.tac

...

root = resource.ForbiddenResource()
err = resource.ForbiddenResource()
root.putChild("service", err)
upd = UpdateXMLProcessor()
err.putChild("update2", upd)

portal = Portal(PublicHTMLRealm(), [FilePasswordDB('httpd.password')])
credentialFactory = DigestCredentialFactory("md5", "House of Life Updates")
admin = HTTPAuthSessionWrapper(portal, [credentialFactory])
err.putChild('admin', admin)

...

In auth.py:

class PublicHTMLRealm(object):
    implements(IRealm)

    def requestAvatar(self, avatarId, mind, *interfaces):
        if IResource in interfaces:
            resc = UpdateManager()
            resc.realm = self
            return (IResource, resc, lambda: None)
        raise NotImplementedError()

in admin.py:

class UpdateManager(resource.Resource):
    isLeaf = False
    pathFromRoot = '/service/admin'

    def __init__(self):
        resource.Resource.__init__(self)
        self.newFull = NewFullResource()
        self.putChild('new_full', self.newFull)
        self.newDelta = NewDeltaResource()
        self.putChild('new_delta', self.newDelta)
        self.switch = SwitchResource()
        self.putChild('switch', self.switch)
        self.putChild('', self)

    def render_GET(self, request):
        ...

Is anything wrong here in these code parts?
I have no errors shown in the console running with

twistd -ny server.tac

Thank you for your assistance,
Viatcheslav Gachkaylo
Crystalnix



More information about the Twisted-web mailing list