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 #23

Open kyrias opened 9 years ago

kyrias commented 9 years ago

I haven’t had time to go through the library yet, but how hard would you estimate that it would be to add HTTP basic auth support?

tcalmant commented 9 years ago

I haven't tested it, but as it is based on the xmlrpclib transport classes, it should support basic auth as is, using the http://user:pass@host:port/path URL format. (again: not tested).

Else, it would be necessary to work on the Transport and SafeTransport classes to override the creation of the HTTP(S) connection.

kyrias commented 9 years ago

I meant something like giving SimpleJSONRPCServer a list of dicts containing combinations of usernames and passwords, so you could have different passwords for different users. I’ll see about looking into it later though.

tcalmant commented 9 years ago

In this case, you have to handle the basic authentication in the request handler. You can take a look at this blog post to see how it could be implemented (jsonrpclib inherits from xmlrpclib classes, so it should be easy to port). Maybe this could become a Mixin in jsonrpclib...

kyrias commented 9 years ago

(Also, just tested regular basic auth URL syntax, and the header isn’t sent properly, so I will have to look into seeing about that first)