首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Cyclone和Redis进行身份验证

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

Stack Overflow用户
提问于 2012-05-14 18:37:15
回答 2查看 921关注 0票数 2

我使用的是redis客户端的cyclone。

没有密码就可以连接到服务器,这很棒,但是我怎么用密码连接到redis呢?如何修改以下代码进行身份验证?

代码语言:javascript
复制
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)

谢谢

EN

回答 2

Stack Overflow用户

发布于 2012-05-14 18:52:04

cyclone redis客户端有一个在redis.conf中设置了密码后可以向其发送密码的auth方法

代码语言:javascript
复制
def auth(self, password):
    """
    Simple password authentication if enabled
    """
    return self.execute_command("AUTH", password)

但是在使用redis auth之前要非常小心。它并不真正被认为是安全的(根据设计),主要应该用来保护实例,防止配置错误导致客户端连接到错误的数据库,而不是作为一种安全方法。

在redis配置文档中:

代码语言:javascript
复制
# 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.
票数 1
EN

Stack Overflow用户

发布于 2012-06-11 14:13:48

cyclone中的redis驱动程序是txredisapi,它确实支持身份验证(以及其他许多功能)。这里提到:https://github.com/fiorix/txredisapi/blob/master/README.md#authentication

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

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10581725

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档