Welcome to the 14th installment of "Twisted Web in 60 seconds". In many of the previous installments, I've demonstrated how to serve content by using existing resource classes or implementing new ones. In this installment, I'll demonstrate how you can use Twisted Web's basic or digest HTTP authentication to control access to these resources.
(
Read more... )
Comments 4
root = Resource()
application = service.Application('auth-demo')
demo_server = strports.service('tcp:8088', server.Site(root))
demo_server.setServiceParent(application)
and I'd need to add the HTTPAuthSessionWrapper resource as a child to the root?
Trying to use HPPTAuthSesseionWrapper instance as the root resource in server.Site didn't seem to get me anywhere either.
Reply
root = Resource()
wrapper = HTTPAuthSessionWrapper(...)
root.putChild("foo", wrapper)
demo_server = strports.service('tcp:8088', server.Site(root))
...
As of Twisted 9.0, you can also use the HTTPAuthSessionWrapper as the root resource itself (there are problems with this in 8.2, though):
root = HTTPAuthSessionWrapper(...)
demo_server = strports.service('tcp:8088', server.Site(root))
Reply
'Since' dates on the twisted api docs would be a great thing
http://twistedmatrix.com/documents/8.2.0/api/twisted.web.guard.html
Thanks
Brad
Reply
We have recently started marking up new APIs with "since" information, too.
Reply
Leave a comment