fmenabe/python-dokuwiki

CookiesTransport only supports HTTP, not HTTPS

RaphaelWimmer opened this issue · 2 comments

CookiesTransport is a subclass of Transport (HTTP), not of SafeTransport (HTTPS).
Therefore, even if the wiki URL contains "https://", only an unsecured HTTP connection is created for XMLRPC calls if the user chooses cookie authentication.
On a server that redirects all HTTP traffic to HTTPS, the XMLRPC call receives a 301 (permanent redirect) response that it does not know how to handle.
This results in an exception: xmlrpc.client.ProtocolError: <ProtocolError for example.com/lib/exe/xmlrpc.php: 301 Moved Permanently>.

I guess the best option would be to add a SafeCookiesTransport(SafeTransport) class that is used as transport if the url starts with "https://".

I can't reproduce the problem. I access a wiki which redirects HTTP to HTTPS and tested a connection with cookieAuth enabled without problem.

What version do you use? It seems similar to #14 and the code should already return a class inheriting from the valid xmlrpc transport class based on URL scheme (58d051a).

You are right - the problem has long been fixed.
There were two issues in my case:

a) I used an old local version of dokuwiki.py that had worked perfectly fine without cookie-based authentication
b) when looking for the cause of the error, I - of course - read the documentation and clicked on the [source] link which led to an outdated version of the file on GitHub: https://github.com/fmenabe/python-dokuwiki/blob/1.1.0/dokuwiki.py#L119-L247 - where the problem still existed. I did not realize that the version I was viewing on GitHub was two years old.
Sorry for the confusion!

(maybe it would be a good idea to regenerate the docs so they point at the current version?)