XMLRPC Authentication

dave at pythonapocrypha.com dave at pythonapocrypha.com
Fri Jun 6 17:00:15 EDT 2003


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





More information about the Python-list mailing list