Mercurial > hg > AuthRPC
annotate README.txt @ 25:d86e7357a91b
Added tag 0.1.0a for changeset d0b8c9edf4f5
author | Ben Croston <ben@croston.org> |
---|---|
date | Sun, 01 Jan 2012 15:59:39 +0000 |
parents | d0b8c9edf4f5 |
children | 346114023528 |
rev | line source |
---|---|
15 | 1 This package provides a service based on JSONRPC with some small additions to the standard in order to enable authenticated requests. The WSGI specification is used for data communication. The package is broken down into two halves - a client and a server. For security, the server is best run over HTTPS, although this is not enforced. |
4 | 2 |
22
9459d63c1558
Added full support for Python 3
Ben Croston <ben@croston.org>
parents:
20
diff
changeset
|
3 This package depends on WebOb 1.2 (or above). This is automatically installed if you have an internet connection, otherwise download and install from http://pypi.python.org/pypi/WebOb |
15 | 4 |
5 Example Usage (Server): | |
6 | |
7 :: | |
8 | |
9 import hashlib | |
10 from wsgiref import simple_server | |
17 | 11 from AuthRPC.server import AuthRPCApp |
15 | 12 |
13 def myauth(username, password, useragent): | |
14 return username == 'myuser' and \ | |
24 | 15 password == hashlib.md5('secret'.encode()).hexdigest() and \ |
15 | 16 useragent == 'myprogram' |
17 | |
18 class api(object): | |
19 def do_something(self, myvar): | |
20 """Your code placed here""" | |
21 return 'Something', myvar | |
22 | |
23 application = AuthRPCApp(api(), auth=myauth) | |
16 | 24 simple_server.make_server('localhost', 1234, application) |
15 | 25 |
26 Example Usage (Client): | |
27 | |
28 :: | |
29 | |
20 | 30 from AuthRPC.client import ServerProxy, BatchCall |
15 | 31 client = ServerProxy('http://localhost:1234/', |
32 username='myuser', | |
33 password='secret', | |
34 user_agent='myprogram') | |
35 retval = client.do_something('test') | |
20 | 36 batch = BatchCall(client) |
37 batch.do_something('call 1') | |
38 batch.do_something('call 2') | |
39 batch() | |
15 | 40 |