Commit 71973adc71d0ec2d01e1f43d24b6c1f46ceaebb1
1 parent
cef39724
websocket 服务端,存在性能和安全问题。 #3278
Showing
2 changed files
with
10 additions
and
2 deletions
ant-design-vue-jeecg/src/components/jeecg/JVxeTable/mixins/vxe.web.socket.mixins.js
1 | import store from '@/store/' | 1 | import store from '@/store/' |
2 | import { randomUUID } from '@/utils/util' | 2 | import { randomUUID } from '@/utils/util' |
3 | +import Vue from 'vue' | ||
4 | +import { ACCESS_TOKEN } from '@/store/mutation-types' | ||
5 | + | ||
3 | // vxe socket | 6 | // vxe socket |
4 | const vs = { | 7 | const vs = { |
5 | // 页面唯一 id,用于标识同一用户,不同页面的websocket | 8 | // 页面唯一 id,用于标识同一用户,不同页面的websocket |
@@ -52,7 +55,10 @@ const vs = { | @@ -52,7 +55,10 @@ const vs = { | ||
52 | const domain = window._CONFIG['domianURL'].replace('https://', 'wss://').replace('http://', 'ws://') | 55 | const domain = window._CONFIG['domianURL'].replace('https://', 'wss://').replace('http://', 'ws://') |
53 | const url = `${domain}/vxeSocket/${userId}/${this.pageId}` | 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 | this.ws.onopen = this.on.open.bind(this) | 62 | this.ws.onopen = this.on.open.bind(this) |
57 | this.ws.onerror = this.on.error.bind(this) | 63 | this.ws.onerror = this.on.error.bind(this) |
58 | this.ws.onmessage = this.on.message.bind(this) | 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,7 +23,9 @@ export const WebsocketMixin = { | ||
23 | this.socketUrl = this.socketUrl + '/' | 23 | this.socketUrl = this.socketUrl + '/' |
24 | } | 24 | } |
25 | var url = window._CONFIG['domianURL'].replace("https://","wss://").replace("http://","ws://") + this.socketUrl + userId + "/" + token; | 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 | this.websock.onopen = this.websocketOnopen; | 29 | this.websock.onopen = this.websocketOnopen; |
28 | this.websock.onerror = this.websocketOnerror; | 30 | this.websock.onerror = this.websocketOnerror; |
29 | this.websock.onmessage = this.websocketOnmessage; | 31 | this.websock.onmessage = this.websocketOnmessage; |