[spyne] Generating wsdl by IP address and another criteria
burak.arslan at arskom.com.tr
Tue Sep 2 13:44:01 UTC 2014
Hi there :)
On 09/02/14 09:32, Михаил Начаров wrote:
> Hello Burak!
> 1. I'm wondering is there a way to generate wsdl at runtime depending
> on client IP-address? I have checked this by myself in source code of
> this powerful library, but haven't find a way to do that.
> 2. If there is no way to do that, can we generate wsdl once per client
> Main purpose of this generation thing is to have all our web-services
> for all consumers in one project, but give them wsdl with only
> necessary services.
I assume you're already aware of this but still: I'd do the IP-based
access check in the methods themselves instead of giving them a partial
WSDL document, because if the client manages to guess or gets hold of
the wsdl document generated for a peer with access to other methods,
Spyne won't remember which ip has which wsdl and will answer its query
Having said that, here's how I think you should implement this:
First, you need a way to tag the methods (e.g. which ip gets which
method). You can use set @rpc's _udp argument to any object. You can
store this information there.
I have just committed a hook for you to override. You need to
subclass Interface and override check_method with something along the
if not (self.ip_address in method.descriptor.udp.ip_addresses):
where ip_address comes as an argument to your Interface subclass' ctor.
Assuming you're using WsgiApplication, you need to subclass it and
>From inside your new WsgiApplication, you must do something along the
interface = Interface(app, ip_address=ip_address)
I can't remember how all this was tied together off the top of my head,
but you get the idea.
I hope this helps.
More information about the people