[Twisted-Python] XMLRPC Authentication

Justin Johnson justinjohnson at fastmail.fm
Fri Jun 6 07:13:19 MDT 2003


Resend with different subject, since the last post seemed to slip off
into the Abyss....

-------
I currently have a really simple xmlrpc service defined.  I'd like to add
some authorization to the service so users must enter a user id and
password to use the service.  Can this be done with creds?  Anybody have
any code snippets that would fit the service defined below (most code is
snipped out).  I read the HOWTO, but wasn't sure how to make things work
with what I'm doing.

-----------------------------------------------------
from vob import VOB
import config
import os
from twisted.web import xmlrpc, server

class CCService(xmlrpc.XMLRPC):
        """Service for handling remote VOB creation, removal, and general
           ClearCase maintenance.
        """

        def xmlrpc_mkvob(self, vobs, group):
                """Create VOBs and apply standard triggers.
                """
                results = ""
                for tag in vobs:
                        log("Start mkvob for VOB '%s'" % tag)
                        vob = VOB(tag, group)
                        results += vob.make()
                        results += vob.applyTriggers()
                        log("End mkvob for VOB '%s'" % tag)
                return results

[...snip...]

def main():
        from twisted.internet.app import Application
        app = Application("ccservice")
        resource = CCService()
        app.listenTCP(config.portNumber, server.Site(resource))
        return app

application = main()

if __name__ == '__main__':
        application.run(save=0)
-----------------------------------------------------

Thanks much.
-Justin




More information about the Twisted-Python mailing list