跳转到主要内容

一个类似于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('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()

变更日志

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 (9.0 kB 查看哈希值)

上传时间:

由以下支持