XMLRPC Authentication

Justin Johnson justinjohnson at fastmail.fm
Fri Jun 6 22:33:08 CEST 2003


I got it to work.  The BasicAuthTransport code I got from a Zope posting
had some variables missing.  Had to add verbose as an option to the
request method, as well as set a self.verbose variable in
BasicAuthTransport.  On top of that, I made some changes to the way
BasicAuthXMLRPCRequestHandler decoded the autorization string.  I'm gonna
make this more robust, but it is working now.

Attached is all of the working code, for anyone who has the same problems
I did.

Thanks everyone for all your help.
-Justin


On Fri, 06 Jun 2003 14:13:33 -0600, "Justin Johnson"
<justinjohnson at fastmail.fm> said:
> I'm getting closer.  Now I'm getting the following error when trying to
> connect via the client.
> 
> [snip]
> Traceback (most recent call last):
>   File "C:\share\python\uhg\uht\tsd\ClearCase\xmlrpc_client.py", line 7,
>   in ?
>     print server.runCmd("dir")
>   File "C:\Python23\lib\xmlrpclib.py", line 1021, in __call__
>     return self.__send(self.__name, args)
>   File "C:\Python23\lib\xmlrpclib.py", line 1308, in __request
>     verbose=self.__verbose
> TypeError: request() got an unexpected keyword argument 'verbose'
> [/snip]
> 
> I've my code.  Any ideas.
> 
> On Fri, 06 Jun 2003 13:34:28 -0600, "Justin Johnson"
> <justinjohnson at fastmail.fm> said:
> > Ahhh,  okay....
> > 
> > So I would put code the do_POST to basically read the MD5 hashed
> > userid:password, decrypt it, and verify that it is a valid user id and
> > password?
> > 
> > On Fri, 6 Jun 2003 14:00:15 -0700 (PDT), dave at pythonapocrypha.com said:
> > > On Fri, 6 Jun 2003, Justin Johnson wrote:
> > > 
> > > > How do you specify the login id and password required on the server side?
> > > >  The code I'm using is similar to the following.  I'm obviously missing
> > > > something here... :-(  Thanks for your help.
> > > >
> > > > # Server code
> > > >
> > > > import SimpleXMLRPCServer
> > > > from ccservice import CCService # A class providing methods for remote
> > > > use
> > > >
> > > > server = SimpleXMLRPCServer.SimpleXMLRPCServer(("somehost", 8000))
> > > > server.register_instance(CCService())
> > > > server.serve_forever()
> > > 
> > > Sorry for not more of a detailed answer, but subclass
> > > SimpleXMLRPCRequestHandler and override the do_POST method sorta like
> > > this psuedo-code
> > > 
> > > def do_POST(self):
> > >   Look at self.headers['authorization']
> > >   if missing or wrong:
> > >     self.send_response(401)
> > >     self.end_headers()
> > >     return
> > >   # Otherwise call original
> > >   return SimpleXMLRPCRequestHandler.do_POST(self)
> > > 
> > > (where "missing or wrong" = do the inverse of what the client side does
> > > to
> > > create the Authorization header)
> > > 
> > > -Dave
> > > 
> > > -- 
> > > http://mail.python.org/mailman/listinfo/python-list
> > > 
> > 
> > -- 
> > http://mail.python.org/mailman/listinfo/python-list
> > 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BasicAuthTransport.py
Type: application/unknown
Size: 1149 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030606/46010294/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: myxmlrpc.py
Type: application/unknown
Size: 583 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030606/46010294/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xmlrpc_client.py
Type: application/unknown
Size: 205 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030606/46010294/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xmlrpc_server.py
Type: application/unknown
Size: 284 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030606/46010294/attachment-0003.bin>


More information about the Python-list mailing list