在龙卷风的WebSocket应用程序的用户身份验证 [英] User authentication in tornado websocket application
问题描述
现在,我提高我的龙卷风技能,有一个关于用户验证的问题。
Now, i improve my tornado skills and have a question about user auth.
和我的解决方法是创建第一页上安全令牌和明年与其他数据发送,从JavaScript龙卷风服务器在哪里检查和auth用户。
And my solution is create secure token on first page and next send it with other data, from javascript to tornado server where do checking and auth user.
我想Cookie,但我不知道我怎么可以在 WebSocketHandler.on_message
i think about cookie but i don't know how i can read cookies in WebSocketHandler.on_message
你在想什么?并在我错了吗?谢谢
what you think ? and where i wrong ? Thanks
推荐答案
我建议你阅读概述部分的文件中。
I suggest you read the overview section in the documentation.
应该有一些相关的内容有:
There should be some relevant content there:
- Cookies and secure cookies
- User Authentication
- Third Party Authentication
修改
我才意识到你的问题是关于WebSockets的。我相信你可以使用你勾勒出的方法:
I just realized your question is about websockets. I believe you can use the approach you outline:
- 创建你的应用程序的非WebSocket的一部分,一个cookie
- 检查Cookie中的WebSocket处理器
您应该可以使用访问WebSocket的处理程序中请求头 self.request.headers
。
You should be able to access the request headers inside the websocket handler using self.request.headers
.
这篇关于在龙卷风的WebSocket应用程序的用户身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!