yes*_*ssi 9 python authentication tornado
现在,我提高了我的龙卷风技能,并对用户身份验证有疑问.
我的解决方案是在第一页上创建安全令牌,然后将其与其他数据一起发送,从javascript到龙卷风服务器,在那里进行检查和验证用户.
我想到cookie但我不知道我怎么能读取cookie WebSocketHandler.on_message
你认为呢 ?我哪里错了?谢谢
客户端可能会使用假用户创建请求标头:'user ="ImFkbWxxxx == | xxxxxxxxxx | 9d847f58a6897df8912f011f0a784xxxxxxxxxx"'
我认为以下方法更好.如果用户不存在或者cookie id不正确或伪造,则函数get_secure_cookie将不会返回用户
class WebSocketHandler(tornado.websocket.WebSocketHandler):
def open(self):
user_id = self.get_secure_cookie("user")
if not user_id: return None
...
Run Code Online (Sandbox Code Playgroud)