一个类似于JSONRPC的客户端和服务器,添加了认证请求的功能
项目描述
此软件包提供了一种基于JSONRPC的服务,通过添加一些标准功能以启用认证请求。使用WSGI规范进行数据通信。该软件包分为两部分 - 客户端和服务器。出于安全考虑,服务器最好通过HTTPS运行,尽管这不是强制性的。
此软件包依赖于WebOb 1.2(或更高版本)。如果您有互联网连接并使用pip,则此软件包将自动安装,否则请从http://pypi.python.org/pypi/WebOb下载并安装。
示例用法(服务器)
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()
示例用法(客户端)
from AuthRPC.client import ServerProxy, BatchCall
client = ServerProxy('https://: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()
变更日志
0.3.2a
移除对distribute的依赖
整理pypi软件包内容
0.3.1a
使用__getfile__生成器(使用更少的内存)
修复了__getfile__的安全问题 - 不允许访问整个磁盘!
处理认证函数中的异常
修复了无密码加密
更改了README代码示例
0.3.0a
更改/重命名生成的异常(客户端)
0.2.0a
添加了__getfile__机制
0.1.0a
添加了批量请求
为服务器添加了Python 3支持
0.0.1a
第一个版本
项目详情
关闭
AuthRPC-0.3.2a.tar.gz的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | d7a3b31d37fd7d229af69e664ee643200ba12b9df51ca132391ada896c7b0225 |
|
| MD5 | d9b309963f1706fdbafca032b9235e26 |
|
| BLAKE2b-256 | e2683e53f2bc83f48fa6d81d95568a8269bfd7bd109b54c4d11ae4d6d9923fc5 |