Commit 82ef9e02 by 庄冰

baidu

parent c7b40412
...@@ -49,7 +49,7 @@ class APIBase { ...@@ -49,7 +49,7 @@ class APIBase {
//保存缓存 //保存缓存
await this.redisClient.setWithEx(shaStr, JSON.stringify(result), 3600); await this.redisClient.setWithEx(shaStr, JSON.stringify(result), 3600);
} }
result.requestId = pobj.RequestId ? pobj.RequestId : pobj.requestId || this.getUUID(); result.requestId = pobj.RequestId ? pobj.RequestId : pobj.requestId || req.requestId;
var tmpResult = pobj.actionType && pobj.actionType.indexOf("List") < 0 ? result : { status: result.status, message: result.message, requestId: result.requestId }; var tmpResult = pobj.actionType && pobj.actionType.indexOf("List") < 0 ? result : { status: result.status, message: result.message, requestId: result.requestId };
this.execClientNew.execLogs("reqPath:" + req.path, pobj, "center-channel-doexecMethod", tmpResult, null); this.execClientNew.execLogs("reqPath:" + req.path, pobj, "center-channel-doexecMethod", tmpResult, null);
return result; return result;
......
...@@ -552,6 +552,31 @@ module.exports = function (app) { ...@@ -552,6 +552,31 @@ module.exports = function (app) {
res.end(JSON.stringify(result)); res.end(JSON.stringify(result));
return; return;
} }
// var token = req.headers["token"] || "";
// if (!token) {
// var resfail = {
// "success": false,
// "errorMsg": "req headers token can not be empty",
// "errorCode": "ok"
// };
// res.end(JSON.stringify(resfail));
// return;
// }
// var cacheManager = system.getObject("db.common.cacheManager");
// var result = await cacheManager["AppTokenByHostsCache"].getCache(token, system.exTime);
// if (result.status != 0) {
// var resfail = {
// "success": false,
// "errorMsg": result.msg || "token error",
// "errorCode": "ok"
// };
// res.end(JSON.stringify(resfail));
// // res.end(JSON.stringify(result));
// return;
// }
// req.appInfo = result.data;
// req.body.appInfo = result.data;
// req.actionProcess = result.data.app_code;
var token = req.headers["token"] || ""; var token = req.headers["token"] || "";
if (!token) { if (!token) {
var resfail = { var resfail = {
...@@ -562,21 +587,24 @@ module.exports = function (app) { ...@@ -562,21 +587,24 @@ module.exports = function (app) {
res.end(JSON.stringify(resfail)); res.end(JSON.stringify(resfail));
return; return;
} }
var cacheManager = system.getObject("db.common.cacheManager"); //校验jwt产生的token
var result = await cacheManager["AppTokenByHostsCache"].getCache(token, system.exTime); const tokenSecret = settings.env == "localhost" || settings.env == "dev" ? PDICT.token_secret_dev : PDICT.token_secret_prod;
if (result.status != 0) { let token_secret_str = null;
var resfail = { jwt.verify(token, tokenSecret, function (err, decoded) { // decoded:指的是token解码后用户信息
"success": false, if (err) { //如果token过期则会执行err的代码块
"errorMsg": result.msg || "token error", return res.send(system.getResultFail(-88, "Failed to authenticate token,error:" + err));
"errorCode": "ok" } else {
}; token_secret_str = decoded.token_secret;
res.end(JSON.stringify(resfail)); }
// res.end(JSON.stringify(result)); });
return; let decryptResult = await utilsAuthSve.decryptInfo(token_secret_str);
if (decryptResult.status != 0) {
return res.send(system.getResultFail(-88, "Failed to authenticate token,fail:" + decryptResult.msg));
} }
req.appInfo = result.data; let tmpAppInfo = JSON.parse(decryptResult.data);
req.body.appInfo = result.data; req.body.appInfo = tmpAppInfo;
req.actionProcess = result.data.app_code; req.appInfo = tmpAppInfo;
req.actionProcess = tmpAppInfo.app_code;
next(); next();
}); });
//icp需求推送 //icp需求推送
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment