[Fedora-suds-list] HttpAuthenticated for WSDL open

Jeff Ortel jortel at redhat.com
Tue Dec 22 14:56:40 UTC 2009



On 12/21/2009 08:11 PM, Matt C wrote:
> Ryan: my setup is similar, and the normal c = Client(url, username =
> 'foo', password = 'bar') has always worked - could you send a sample
> of your code?

As Matt has pointed out, this is the proper way to get the wsdl using http basic 
authentication.  The default transport already is HttpAuthenticated so you simply need to 
pass the username and password in the Client constructor.

If this does not work then maybe your server does not implement RFC-2617 (as described 
here: http://en.wikipedia.org/wiki/Basic_access_authentication) properly in which case I 
can describe the workaround.

>
> -Matt
>
> On Mon, Dec 21, 2009 at 6:03 PM, Ryan Schroeder<ryanitus at gmail.com>  wrote:
>> Here's the open function for HttpAuthenticated.
>>
>> class HttpAuthenticated(HttpTransport):
>>      """
>>      Provides basic http authentication for servers that don't follow
>>      the specified challenge / response model.  This implementation
>>      appends the I{Authorization} http header with base64 encoded
>>      credentials on every http request.
>>      """
>>      def open(self, request):
>>          credentials = self.credentials()
>>          theurl = request.url
>>          username = credentials[0]
>>          password = credentials[1]
>>          passman = u2.HTTPPasswordMgrWithDefaultRealm()
>>          passman.add_password(None, theurl, username, password)
>>          authhandler = u2.HTTPBasicAuthHandler(passman)
>>          opener = u2.build_opener(authhandler)
>>          u2.install_opener(opener)
>>          return HttpTransport.open(self, request)
>>
>>
>>
>> On Mon, Dec 21, 2009 at 2:16 PM, Ryan Schroeder<ryanitus at gmail.com>  wrote:
>>>
>>> Hello,
>>>
>>> I have a server that requires basic HTTP authentication to download the
>>> WSDL file.  I tried setting the transport to HTTPAuthenticated, but it looks
>>> like the Client doesn't apply the options.transport when opening the url.
>>>
>>> Here's the snippet I'm referring to from client.py:
>>>
>>>      def __init__(self, url, **kwargs):
>>>          """
>>>          @param url: The URL for the WSDL.
>>>          @type url: str
>>>          @param kwargs: keyword arguments.
>>>          @see: L{Options}
>>>          """
>>>          options = Options()
>>>          options.transport = HttpAuthenticated()
>>>          self.options = options
>>>          options.cache = FileCache(days=1)
>>>          self.set_options(**kwargs)
>>>          self.wsdl = Definitions(url, options)<--------------
>>> shouldn't this be self.options?
>>>
>>>
>>> I tried making this change, but also ran into the fact that the
>>> HttpAuthenticated class does not override the open method using a provided
>>> username and password.  The basic HttpTransport open method is called
>>> instead.
>>>
>>> Regards,
>>>
>>> Ryan
>>>
>>
>> _______________________________________________
>> fedora-suds-list mailing list
>> fedora-suds-list at redhat.com
>> https://www.redhat.com/mailman/listinfo/fedora-suds-list
>>
>
> _______________________________________________
> fedora-suds-list mailing list
> fedora-suds-list at redhat.com
> https://www.redhat.com/mailman/listinfo/fedora-suds-list

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5126 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.fedoraproject.org/pipermail/suds/attachments/20091222/58903174/attachment.bin 


More information about the suds mailing list