Commit 71973adc71d0ec2d01e1f43d24b6c1f46ceaebb1

Authored by zhangdaiscott
1 parent cef39724

websocket 服务端,存在性能和安全问题。 #3278

ant-design-vue-jeecg/src/components/jeecg/JVxeTable/mixins/vxe.web.socket.mixins.js
1 1 import store from '@/store/'
2 2 import { randomUUID } from '@/utils/util'
  3 +import Vue from 'vue'
  4 +import { ACCESS_TOKEN } from '@/store/mutation-types'
  5 +
3 6 // vxe socket
4 7 const vs = {
5 8 // 页面唯一 id,用于标识同一用户,不同页面的websocket
... ... @@ -52,7 +55,10 @@ const vs = {
52 55 const domain = window._CONFIG['domianURL'].replace('https://', 'wss://').replace('http://', 'ws://')
53 56 const url = `${domain}/vxeSocket/${userId}/${this.pageId}`
54 57  
55   - this.ws = new WebSocket(url)
  58 + //update-begin-author:taoyan date:2022-4-22 for: v2.4.6 的 websocket 服务端,存在性能和安全问题。 #3278
  59 + let token = Vue.ls.get(ACCESS_TOKEN)
  60 + this.ws = new WebSocket(url, [token])
  61 + //update-end-author:taoyan date:2022-4-22 for: v2.4.6 的 websocket 服务端,存在性能和安全问题。 #3278
56 62 this.ws.onopen = this.on.open.bind(this)
57 63 this.ws.onerror = this.on.error.bind(this)
58 64 this.ws.onmessage = this.on.message.bind(this)
... ...
ant-design-vue-jeecg/src/mixins/WebsocketMixin.js
... ... @@ -23,7 +23,9 @@ export const WebsocketMixin = {
23 23 this.socketUrl = this.socketUrl + '/'
24 24 }
25 25 var url = window._CONFIG['domianURL'].replace("https://","wss://").replace("http://","ws://") + this.socketUrl + userId + "/" + token;
26   - this.websock = new WebSocket(url);
  26 + //update-begin-author:taoyan date:2022-4-22 for: v2.4.6 的 websocket 服务端,存在性能和安全问题。 #3278
  27 + this.websock = new WebSocket(url, [token]);
  28 + //update-end-author:taoyan date:2022-4-22 for: v2.4.6 的 websocket 服务端,存在性能和安全问题。 #3278
27 29 this.websock.onopen = this.websocketOnopen;
28 30 this.websock.onerror = this.websocketOnerror;
29 31 this.websock.onmessage = this.websocketOnmessage;
... ...