tcalmant / jsonrpclib

A Python (2 & 3) JSON-RPC over HTTP that mirrors the syntax of xmlrpclib (aka jsonrpclib-pelix)
https://jsonrpclib-pelix.readthedocs.io/
Apache License 2.0
53 stars 24 forks source link

Authentication doesn't work #28

Closed ghost closed 8 years ago

ghost commented 8 years ago

It seems in forked version using basic authentication isn't possible, I used tcpdump to capture packets and jsonrpclib-plex didn't send Authorization header

tcalmant commented 8 years ago

Hi, Basic authentication isn't handled by the library, but you can use the custom headers context to add the missing headers:

with client._additional_headers({'Authorization' : 'Foo'}) as new_client:
   new_client.method()
ghost commented 8 years ago

Yes I digged through code, even python xmlrpclib but I couldn't find the reason why it doesn't work in this fork, finally I falled back to original jsonrpclib because I'm not looking for trouble right now :)

Python xmlrpc lib at some point adds Authorization header to request, you sure you don't overwrite request headers with custom headers?

tcalmant commented 8 years ago

OK, I'll give it a look ASAP. Do you have a snippet that I could test ?

ghost commented 8 years ago

Great, not a snippet exactly but for creating a authenticated jsonrpc server you might find this useful https://gist.github.com/k1-hedayati/bbd4e15f4c5b34a2628ea9e79ae08bff

tcalmant commented 8 years ago

Please try the master version of the repository, as the required headers are no longer ignored.

ghost commented 8 years ago

Sorry I can't test it because I'm no longer using this fork and based my code from original repo, https://github.com/k1-hedayati/jsonrpclib

BTW thanks for fixing issue :)

tcalmant commented 8 years ago

OK. Tests are now fully passing on Travis, considering the issue fixed. Thanks for reporting it :)