From 653a987bdd1783e5956d10a42fd5183528f67819 Mon Sep 17 00:00:00 2001 From: "https://blog.iamtsm.cn" <1905333456@qq.com> Date: Sat, 28 Oct 2023 15:18:07 +0800 Subject: [PATCH] feat: token check env --- svr/conf/cfg.json | 8 ++++++-- svr/src/controller/login/login.js | 2 +- svr/src/socket/rtcToken/token.js | 2 +- tlrtcfile.env | 4 ++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/svr/conf/cfg.json b/svr/conf/cfg.json index 2d72c63..4cfff82 100644 --- a/svr/conf/cfg.json +++ b/svr/conf/cfg.json @@ -1,5 +1,5 @@ { - "version": "10.4.9", + "version": "10.5.0", "socket": { "port": "请到 tlrtcfile.env 中进行配置", "host": "请到 tlrtcfile.env 中进行配置" @@ -20,7 +20,11 @@ }, "login": { "appId" : "请到 tlrtcfile.env 中进行配置", - "appSecret" : "请到 tlrtcfile.env 中进行配置" + "appSecret" : "请到 tlrtcfile.env 中进行配置", + "token" : { + "url" : "请到 tlrtcfile.env 中进行配置", + "key" : "请到 tlrtcfile.env 中进行配置" + } }, "manage": { "room": "请到 tlrtcfile.env 中进行配置", diff --git a/svr/src/controller/login/login.js b/svr/src/controller/login/login.js index dbb4f6b..b2cb51d 100644 --- a/svr/src/controller/login/login.js +++ b/svr/src/controller/login/login.js @@ -269,7 +269,7 @@ async function getLoginInfo(req, res){ let token = req.query.token || ""; let key = req.query.key || ""; - if(!token || token.length < 16 || key !== 'iamtsm-socket'){ + if(!token || token.length < 16 || key !== conf.login.token.key){ res.json({ code: 403 }); return; } diff --git a/svr/src/socket/rtcToken/token.js b/svr/src/socket/rtcToken/token.js index 2db2017..34e8fb3 100644 --- a/svr/src/socket/rtcToken/token.js +++ b/svr/src/socket/rtcToken/token.js @@ -23,7 +23,7 @@ async function token(io, socket, tables, dbClient, data){ request({ method: "POST", - url: `https://im.iamtsm.cn/api/login/info`, + url: `${cfg.login.token.url}/api/login/info`, json: true, headers: { "content-type": "application/json", diff --git a/tlrtcfile.env b/tlrtcfile.env index 05dac9e..7aa5b4a 100644 --- a/tlrtcfile.env +++ b/tlrtcfile.env @@ -94,3 +94,7 @@ tl_rtc_file_notify_qiwei_error= tl_rtc_file_login_appId= ## appSecret tl_rtc_file_login_appSecret= +## token url +tl_rtc_file_login_token_url=http://127.0.0.1:9092 +## token api key +tl_rtc_file_login_token_key=tlrtcfile \ No newline at end of file