A JSONRPC-like client and server with additions to enable authenticated requests
Project description
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.
This package depends on WebOb 1.2 (or above). This is automatically installed if you have an internet connection and use pip, otherwise download and install from http://pypi.python.org/pypi/WebOb
Example Usage (Server):
import hashlib from wsgiref import simple_server from AuthRPC.server import AuthRPCApp def myauth(username, password, useragent): return username == 'myuser' and \ password == hashlib.md5('secret'.encode()).hexdigest() and \ useragent == 'myprogram' class api(object): def do_something(self, myvar): """Your code placed here""" return 'Something', myvar application = AuthRPCApp(api(), auth=myauth, filepath='/home/myapp/datadir') server = simple_server.make_server('localhost', 1234, application) server.serve_forever()
Example Usage (Client):
from AuthRPC.client import ServerProxy, BatchCall client = ServerProxy('http://localhost:1234/', username='myuser', password='secret', user_agent='myprogram') retval = client.do_something('test') # get a file and save local copy file_contents_generator = client.__getfile__('myfile.pdf') with open('myfile_downloaded.pdf', 'wb') as f: for data in file_contents_generator: f.write(data) batch = BatchCall(client) batch.do_something('call 1') batch.do_something('call 2') batch()
Change Log
0.3.2a
Remove dependency on distribute
Tidy up pypi package contents
0.3.1a
Use generator with __getfile__ (uses much less memory)
Fixed security issue with __getfile__ - do not allow access to whole disk!
Handle exceptions in auth function
Fixed encrypting of no password
Changed README code examples
0.3.0a
Changed/renamed exceptions that are generated (client)
0.2.0a
Added __getfile__ mechanism
0.1.0a
Added batch requests
Added Python 3 support for server
0.0.1a
First version
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file AuthRPC-0.3.2a.tar.gz
.
File metadata
- Download URL: AuthRPC-0.3.2a.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7a3b31d37fd7d229af69e664ee643200ba12b9df51ca132391ada896c7b0225 |
|
MD5 | d9b309963f1706fdbafca032b9235e26 |
|
BLAKE2b-256 | e2683e53f2bc83f48fa6d81d95568a8269bfd7bd109b54c4d11ae4d6d9923fc5 |