JWT for web sockets

blov · · 620 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I am building a chat app as a learning experience. I have the app built using websockets. I want to learn to use JWT for authentication. Is there a good resource to learn how to do that with websockets in go. I&#39;ve been looking around and I&#39;ve had trouble finding good instructions. Thank you!</p> <hr/>**评论:**<br/><br/>: <pre><p>[deleted]</p></pre>Ayman250: <pre><p>Is the web-socket secure. Is it possible for an existing websocket connection to be hijacked after it&#39;s been authenticated?</p></pre>: <pre><p>[deleted]</p></pre>Ayman250: <pre><p>Wow thank! This makes the whole thing much easier than!</p></pre>francoispqt: <pre><p>You can also set a cookie if you want to maintain the auth.</p></pre>sablefoxx: <pre><p>This leaves the connection potentially vulnerable to <a href="https://www.christian-schneider.net/CrossSiteWebSocketHijacking.html" rel="nofollow">cross-site connections</a>, it is imperative if you&#39;re authenticating using cookies to also validate the<code>origin</code> HTTP header, it&#39;s better to send the authentication data over the <code>wss://</code> connection and validate the <code>origin</code> HTTP header.</p></pre>tmornini: <pre><p>This is the right answer!</p></pre>dbud: <pre><p>Simplest thing is to just require that the first message on the socket is the JWT. Once we validate it, we enter the message loop like normal. If that first message isn&#39;t a valid JWT, close the websocket.</p></pre>lacion: <pre><p>i do exactly that with this test project.</p> <p><a href="https://github.com/lacion/iothub/blob/master/main.go" rel="nofollow">https://github.com/lacion/iothub/blob/master/main.go</a></p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

620 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传