soajs.controller 4.2.12 → 4.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mw/gotoService/redirectToService.js +3 -1
- package/mw/mt/index.js +24 -23
- package/package.json +1 -1
|
@@ -172,7 +172,9 @@ module.exports = (configuration) => {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
if (!isStream) {
|
|
175
|
-
req.soajs.controller.redirectedRequest
|
|
175
|
+
if (req.soajs.controller.redirectedRequest) {
|
|
176
|
+
req.soajs.controller.redirectedRequest.end();
|
|
177
|
+
}
|
|
176
178
|
}
|
|
177
179
|
if (!isStream && allowedContentType) {
|
|
178
180
|
monitoObj.time.req_body_end = new Date().getTime();
|
package/mw/mt/index.js
CHANGED
|
@@ -24,9 +24,9 @@ module.exports = (configuration) => {
|
|
|
24
24
|
let core = configuration.core;
|
|
25
25
|
let provision = configuration.provision;
|
|
26
26
|
let gatewayServiceName = configuration.serviceName;
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
return (req, res, next) => {
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
//if there is a proxy no need to do any of the below, return next
|
|
31
31
|
let urlInfo = req.soajs.controller.serviceParams.serviceInfo;
|
|
32
32
|
//let proxy = (urlInfo[1] === 'proxy' && urlInfo[2] === 'redirect');
|
|
@@ -37,7 +37,7 @@ module.exports = (configuration) => {
|
|
|
37
37
|
proxy = true;
|
|
38
38
|
}
|
|
39
39
|
let url_keyACL = (urlInfo[1] === 'soajs' && urlInfo[2] === 'acl');
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
let serviceParam = {};
|
|
42
42
|
if (!proxy) {
|
|
43
43
|
let serviceInfo = req.soajs.controller.serviceParams.registry.versions[req.soajs.controller.serviceParams.version];
|
|
@@ -75,7 +75,7 @@ module.exports = (configuration) => {
|
|
|
75
75
|
"oauth": true
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
let oauthExec = () => {
|
|
80
80
|
if (serviceParam.oauth) {
|
|
81
81
|
soajs.oauth(req, res, next);
|
|
@@ -84,7 +84,7 @@ module.exports = (configuration) => {
|
|
|
84
84
|
return next();
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
|
|
87
|
+
|
|
88
88
|
req.soajs.awareness.getHost(gatewayServiceName, (controllerHostInThisEnvironment) => {
|
|
89
89
|
if (serviceParam.extKeyRequired) {
|
|
90
90
|
req.soajs.controller.serviceParams.isAPIPublic = false;
|
|
@@ -96,7 +96,7 @@ module.exports = (configuration) => {
|
|
|
96
96
|
"iKey": keyObj.key,
|
|
97
97
|
"eKey": keyObj.extKey
|
|
98
98
|
};
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
provision.getTenantOauth(req.soajs.tenant.id, (err, tenantOauth) => {
|
|
101
101
|
if (tenantOauth) {
|
|
102
102
|
req.soajs.tenantOauth = tenantOauth;
|
|
@@ -104,18 +104,18 @@ module.exports = (configuration) => {
|
|
|
104
104
|
req.soajs.tenantOauth = null;
|
|
105
105
|
}
|
|
106
106
|
req.soajs.tenant.application = keyObj.application;
|
|
107
|
-
|
|
107
|
+
|
|
108
108
|
let packObj = req.soajs.controller.serviceParams.packObj;
|
|
109
109
|
if (packObj) {
|
|
110
110
|
req.soajs.tenant.application.package_acl = packObj.acl;
|
|
111
111
|
req.soajs.tenant.application.package_acl_all_env = packObj.acl_all_env;
|
|
112
112
|
req.soajs.servicesConfig = keyObj.config;
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
if (proxy) {
|
|
115
115
|
req.soajs.log.debug("Detected proxy request, bypassing MT ACL checks...");
|
|
116
116
|
return oauthExec();
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
|
|
119
119
|
let serviceCheckArray = [(cb) => {
|
|
120
120
|
cb(null, {
|
|
121
121
|
"gatewayServiceName": gatewayServiceName,
|
|
@@ -130,27 +130,27 @@ module.exports = (configuration) => {
|
|
|
130
130
|
"packObj": packObj
|
|
131
131
|
});
|
|
132
132
|
}];
|
|
133
|
-
|
|
133
|
+
|
|
134
134
|
serviceCheckArray.push(utils.ipWhitelist);
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
serviceCheckArray.push(utils.securityGeoCheck);
|
|
137
137
|
serviceCheckArray.push(utils.securityDeviceCheck);
|
|
138
|
-
|
|
138
|
+
|
|
139
139
|
serviceCheckArray.push(utils.aclCheck);
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
if (serviceParam.oauth) {
|
|
142
142
|
serviceCheckArray.push(utils.oauthCheck);
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
|
|
145
145
|
serviceCheckArray.push(utils.uracCheck);
|
|
146
146
|
if (!url_keyACL) {
|
|
147
147
|
serviceCheckArray.push(utils.aclUrackCheck);
|
|
148
|
-
|
|
148
|
+
|
|
149
149
|
serviceCheckArray.push(utils.serviceCheck);
|
|
150
150
|
serviceCheckArray.push(utils.apiCheck);
|
|
151
151
|
}
|
|
152
152
|
async.waterfall(serviceCheckArray, (err, data) => {
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
//if this is controller route: /key/permission/get, ignore async waterfall response
|
|
155
155
|
if (url_keyACL) {
|
|
156
156
|
if (!req.soajs.uracDriver) {
|
|
@@ -172,7 +172,7 @@ module.exports = (configuration) => {
|
|
|
172
172
|
return next();
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
if (err) {
|
|
177
177
|
req.soajs.log.error("Problem accessing service [" + req.soajs.controller.serviceParams.name + "], API [" + req.soajs.controller.serviceParams.path + "] & version [" + req.soajs.controller.serviceParams.version + "]");
|
|
178
178
|
return next(err);
|
|
@@ -180,7 +180,7 @@ module.exports = (configuration) => {
|
|
|
180
180
|
let serviceName = data.req.soajs.controller.serviceParams.name;
|
|
181
181
|
let dataServiceConfig = data.servicesConfig || keyObj.config;
|
|
182
182
|
let serviceConfig = {};
|
|
183
|
-
|
|
183
|
+
|
|
184
184
|
if (dataServiceConfig.commonFields) {
|
|
185
185
|
for (let i in dataServiceConfig.commonFields) {
|
|
186
186
|
if (Object.hasOwnProperty.call(dataServiceConfig.commonFields, i)) {
|
|
@@ -230,7 +230,7 @@ module.exports = (configuration) => {
|
|
|
230
230
|
"device": data.device,
|
|
231
231
|
"geo": data.geo
|
|
232
232
|
};
|
|
233
|
-
|
|
233
|
+
|
|
234
234
|
if (keyObj.tenant.main) {
|
|
235
235
|
injectObj.tenant.main = keyObj.tenant.main;
|
|
236
236
|
}
|
|
@@ -254,11 +254,11 @@ module.exports = (configuration) => {
|
|
|
254
254
|
"code": uracObj.tenant.code
|
|
255
255
|
}
|
|
256
256
|
};
|
|
257
|
-
|
|
257
|
+
|
|
258
258
|
injectObj.param = injectObj.param || {};
|
|
259
259
|
injectObj.param.urac_Profile = serviceParam.urac_Profile;
|
|
260
260
|
injectObj.param.urac_ACL = serviceParam.urac_ACL;
|
|
261
|
-
|
|
261
|
+
|
|
262
262
|
if (serviceParam.urac_Profile) {
|
|
263
263
|
injectObj.urac.profile = uracObj.profile;
|
|
264
264
|
}
|
|
@@ -289,7 +289,7 @@ module.exports = (configuration) => {
|
|
|
289
289
|
"port": req.soajs.registry.serviceConfig.ports.controller
|
|
290
290
|
};
|
|
291
291
|
}
|
|
292
|
-
|
|
292
|
+
|
|
293
293
|
if (serviceParam.interConnect && Array.isArray(serviceParam.interConnect) && serviceParam.interConnect.length > 0) {
|
|
294
294
|
if (!injectObj.awareness.interConnect) {
|
|
295
295
|
injectObj.awareness.interConnect = [];
|
|
@@ -332,7 +332,8 @@ module.exports = (configuration) => {
|
|
|
332
332
|
if (err) {
|
|
333
333
|
req.soajs.log.error(err.message);
|
|
334
334
|
}
|
|
335
|
-
|
|
335
|
+
let _h = JSON.stringify(injectObj);
|
|
336
|
+
req.headers.soajsinjectobj = Buffer.from(_h, 'ascii').toString('utf-8');
|
|
336
337
|
return next();
|
|
337
338
|
});
|
|
338
339
|
} else {
|