mettienne / pysimplesoap

Automatically exported from code.google.com/p/pysimplesoap
0 stars 0 forks source link

WSDL not reachable behind a Basic Authentication #148

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set your WSDL only reachable behind Basic Authentication
2. Create your SOAPClient using Basic Authentication system (whatever you're 
using combo username/password or the "Authorization" header)
3. You always get an error (401 or 403) while trying to get the WSDL because of 
the needed authentication

What is the expected output? What do you see instead?
Authorization headers should be sent as soon as the first request is being sent 
but due it is not. Combo username/password is ignored because httplib2 is not 
sending these crendentials in the first request (well explained here: 
https://josephscott.org/archives/2011/06/http-basic-auth-with-httplib2/).
By forcing the headers to be sent with the initial request, you can reach the 
WSDL thanks to the header "Authorization".

What version of the product are you using? On what operating system?
Any version from 1.11 to 1.13

Please attach the related WSDL (if any), a small code fragment to reproduce and 
provide any additional information below.
Here are the command lines used to connect to a WSDL hidden behind a Basic 
Authentication:
    import base64
    from pysimplesoap.client import *
    encoded = base64.b64encode('user:password')
    client = SoapClient(wsdl="https://mydomain.com/app/webservices/call/soap?WSDL", http_headers={'Authorization': 'Basic %s'%encoded}, sessions=True, cacert='/path/to/the/certificate.crt')

Here are the changes to perform so the headers can be correctly sent as soon as 
the WSDL is requested. Changes have to be done in two files (helpers.py and 
client.py):
 helpers.py
  + Line 41: def fetch(url, http, cache=False, force_download=False, wsdl_basedir='', headers={}):
  + Line 55: return fetch(tmp_url, http, cache, force_download, wsdl_basedir, headers)
  + Line 76: response, xml = http.request(url, 'GET', None, headers)

 client.py
  + Line 520: xml = fetch(url, self.http, cache, force_download, self.wsdl_basedir, self.http_headers)
  + Line 543: xml = fetch(wsdl_location, self.http, cache, force_download, self.wsdl_basedir, self.http_headers)

Original issue reported on code.google.com by baptiste...@gmail.com on 24 Jun 2014 at 9:28

GoogleCodeExporter commented 9 years ago
Thanks for your contribution.

Could you send a patch against the latest version in the repository?
(using mercurial or github pull request)

Original comment by reingart@gmail.com on 24 Jun 2014 at 6:31

GoogleCodeExporter commented 9 years ago
Hi,

I've just sent a pull request on Github with the files changes.

Thanks !

Original comment by baptiste...@gmail.com on 24 Jun 2014 at 7:35