Securing SimpleXMLRPCServer?
Brian Quinlan
brian at sweetapp.com
Mon Jul 8 12:39:28 EDT 2002
> OK, I apologise in advance for appearing dense. I've added the code
> that was supplied by Brian, and the server script appears to run OK.
> However, the client script displays the following error:
>
> Traceback (most recent call last):
[snipped]
> xmlrpclib.Fault: <Fault 1: 'UnknownIP:Client IP Is Not Authorised'>
OK, it looks like the server is rejecting the client's IP address.
> The server script:
>
> import sys, os, SimpleXMLRPCServer, string
>
> class AuthenticatingSimpleXMLRPCRequestHandler
> (SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
> def _dispatch(self,method,params):
> self.UnknownIP = "UnknownIP"
> if not (self.client_address == "144.178.234.189" or
> self.client_address == "localhost" ):
> raise self.UnknownIP, "Client IP Is Not Authorised"
> else:
1. The IP check would be more readable if you wrote it like:
if self.client_address not in ["144.178.234.189", "localhost"]:
....
2. For debugging purposes, try adding the following line:
def _dispatch(self, method, params):
+ print 'client_address: %r' % self.client_address
Then rerun your server and client to see why your server is rejecting
your client's address.
Cheers,
Brian
More information about the Python-list
mailing list