Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用Cyclone和Redis进行身份验证_Python_Redis_Twisted_Cyclone - Fatal编程技术网

Python 如何使用Cyclone和Redis进行身份验证

Python 如何使用Cyclone和Redis进行身份验证,python,redis,twisted,cyclone,Python,Redis,Twisted,Cyclone,我正在为cyclone使用redis客户端 很好,您可以不用密码连接到服务器,但我如何用密码连接到redis?如何修改以下代码以进行身份验证 t = cyclone.redis.lazyConnectionPool(host,port,db) @cyclone.web.asynchronous def on_finish(self): t = yield tt.multi() yield t.set('key', 'value') r = yield t.commit

我正在为cyclone使用redis客户端

很好,您可以不用密码连接到服务器,但我如何用密码连接到redis?如何修改以下代码以进行身份验证

t = cyclone.redis.lazyConnectionPool(host,port,db)

@cyclone.web.asynchronous
def on_finish(self):

    t = yield tt.multi()
    yield t.set('key', 'value')
    r = yield t.commit()
    print "commit=", repr(r)

感谢

redis.conf

def auth(self, password):
    """
    Simple password authentication if enabled
    """
    return self.execute_command("AUTH", password)
但是在使用redis auth之前要非常小心。它实际上并不被认为是安全的(从设计上讲),主要用于保护实例,防止配置错误导致客户端连接到错误的数据库,而不是作为一种安全方法

从redis配置文档:

# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.

cyclone中的redis驱动程序是,它确实支持身份验证(以及其他许多功能)。这里提到:

但是,它不能很好地处理自动重新连接,因为身份验证没有在
连接
方法中实现。这意味着它不会在重新连接后自动重新验证


它可以实现,但人们似乎没有使用它

我不太了解那个特定的客户端,但从docuemntation来看,它应该是类似于
t=cyclone.redis.lazyConnectionPool(主机、端口、数据库);authResult=yield t.auth(myPass)