soajs.controller 4.3.3 → 4.3.4

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/mt/lib.js CHANGED
@@ -13,7 +13,7 @@ let _ = require("lodash");
13
13
 
14
14
  module.exports = {
15
15
  "mergeACLArray": function (arrayACL, cb) {
16
-
16
+
17
17
  //if only one return it
18
18
  if (arrayACL.length === 1) {
19
19
  return cb(null, arrayACL[0]);
@@ -30,30 +30,30 @@ module.exports = {
30
30
  function () {
31
31
  return cb(null, acl);
32
32
  });
33
-
33
+
34
34
  function mergePackageAcl(oneAcl, cb) {
35
35
  //first object
36
36
  if (!acl.acl) {
37
- acl.acl = oneAcl.acl;
37
+ acl.acl = _.cloneDeep(oneAcl.acl);
38
38
  return cb();
39
39
  }
40
40
  async.eachOfSeries(oneAcl.acl, function (service, serviceName, serviceCall) {
41
41
  if (!acl.acl[serviceName]) {
42
- acl.acl[serviceName] = service;
42
+ acl.acl[serviceName] = _.cloneDeep(service);
43
43
  return serviceCall();
44
44
  }
45
45
  async.eachOfSeries(service, function (version, versionValue, versionCall) {
46
46
  if (!acl.acl[serviceName][versionValue]) {
47
- acl.acl[serviceName][versionValue] = version;
47
+ acl.acl[serviceName][versionValue] = _.cloneDeep(version);
48
48
  return serviceCall();
49
49
  }
50
50
  if (version.apisPermission === "restricted") {
51
51
  if (acl.acl[serviceName] && acl.acl[serviceName][versionValue] && acl.acl[serviceName][versionValue].apisPermission && acl.acl[serviceName][versionValue].apisPermission === "restricted") {
52
52
  //only restricted allowed to merge
53
- acl.acl[serviceName][versionValue] = _.merge(acl.acl[serviceName][versionValue], version);
53
+ acl.acl[serviceName][versionValue] = _.merge(acl.acl[serviceName][versionValue], _.cloneDeep(version));
54
54
  return versionCall();
55
55
  } else {
56
- acl.acl[serviceName][versionValue] = version;
56
+ acl.acl[serviceName][versionValue] = _.cloneDeep(version);
57
57
  return versionCall();
58
58
  }
59
59
  } else {
@@ -62,42 +62,42 @@ module.exports = {
62
62
  return versionCall();
63
63
  } else {
64
64
  //only non restricted allowed to merge
65
- acl.acl[serviceName][versionValue] = _.merge(acl.acl[serviceName][versionValue], version);
65
+ acl.acl[serviceName][versionValue] = _.merge(acl.acl[serviceName][versionValue], _.cloneDeep(version));
66
66
  return versionCall();
67
67
  }
68
68
  }
69
69
  }, serviceCall);
70
70
  }, cb);
71
71
  }
72
-
72
+
73
73
  function mergePackageAclAllEnv(oneAcl, cb) {
74
74
  //first object
75
75
  if (!acl.acl_all_env) {
76
- acl.acl_all_env = oneAcl.acl_all_env;
76
+ acl.acl_all_env = _.cloneDeep(oneAcl.acl_all_env);
77
77
  return cb();
78
78
  }
79
79
  async.eachOf(oneAcl.acl_all_env, function (environment, envName, envCall) {
80
80
  if (!acl.acl_all_env[envName]) {
81
- acl.acl_all_env[envName] = environment;
81
+ acl.acl_all_env[envName] = _.cloneDeep(environment);
82
82
  return envCall();
83
83
  }
84
84
  async.eachOf(environment, function (service, serviceName, serviceCall) {
85
85
  if (!acl.acl_all_env[envName][serviceName]) {
86
- acl.acl_all_env[envName][serviceName] = service;
86
+ acl.acl_all_env[envName][serviceName] = _.cloneDeep(service);
87
87
  return serviceCall();
88
88
  }
89
89
  async.eachOf(service, function (version, versionValue, versionCall) {
90
90
  if (!acl.acl_all_env[envName][serviceName][versionValue]) {
91
- acl.acl_all_env[envName][serviceName][versionValue] = version;
91
+ acl.acl_all_env[envName][serviceName][versionValue] = _.cloneDeep(version);
92
92
  return serviceCall();
93
93
  }
94
94
  if (version.apisPermission === "restricted") {
95
95
  if (acl.acl_all_env[envName][serviceName][versionValue].apisPermission && acl.acl_all_env[envName][serviceName][versionValue].apisPermission === "restricted") {
96
96
  //only restricted allowed to merge
97
- acl.acl_all_env[envName][serviceName][versionValue] = _.merge(acl.acl_all_env[envName][serviceName][versionValue], version);
97
+ acl.acl_all_env[envName][serviceName][versionValue] = _.merge(acl.acl_all_env[envName][serviceName][versionValue], _.cloneDeep(version));
98
98
  return versionCall();
99
99
  } else {
100
- acl.acl_all_env[envName][serviceName][versionValue] = version;
100
+ acl.acl_all_env[envName][serviceName][versionValue] = _.cloneDeep(version);
101
101
  return versionCall();
102
102
  }
103
103
  } else {
@@ -106,7 +106,7 @@ module.exports = {
106
106
  return versionCall();
107
107
  } else {
108
108
  //only non restricted allowed to merge
109
- acl.acl_all_env[envName][serviceName][versionValue] = _.merge(acl.acl_all_env[envName][serviceName][versionValue], version);
109
+ acl.acl_all_env[envName][serviceName][versionValue] = _.merge(acl.acl_all_env[envName][serviceName][versionValue], _.cloneDeep(version));
110
110
  return versionCall();
111
111
  }
112
112
  }
@@ -115,4 +115,4 @@ module.exports = {
115
115
  }, cb);
116
116
  }
117
117
  }
118
- };
118
+ };
@@ -31,7 +31,7 @@ module.exports = (configuration) => {
31
31
  }
32
32
  if (!ACL && req.soajs.controller.serviceParams.packObj.acl) {
33
33
  req.soajs.log.debug("soajsRoute keyACL: Found Default ACL at Package level, setting default ACL configuration.");
34
- ACL = req.soajs.controller.serviceParams.packObj.acl;
34
+ ACL = coreLibs.utils.cloneObj(req.soajs.controller.serviceParams.packObj.acl);
35
35
  }
36
36
  let finalACL = null;
37
37
  if (ACL) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "soajs.controller",
3
3
  "description": "soajs multi tenant API gateway",
4
- "version": "4.3.3",
4
+ "version": "4.3.4",
5
5
  "author": {
6
6
  "name": "soajs team",
7
7
  "email": "team@soajs.org"
@@ -27,9 +27,9 @@
27
27
  "merge": "2.1.1",
28
28
  "netmask": "2.0.2",
29
29
  "oauth2-server": "2.4.1",
30
- "path-to-regexp": "8.3.0",
30
+ "path-to-regexp": "8.4.0",
31
31
  "soajs.core.libs": "1.2.2",
32
- "soajs.core.modules": "5.2.18",
32
+ "soajs.core.modules": "5.2.19",
33
33
  "soajs.urac.driver": "3.2.15",
34
34
  "useragent": "2.3.0"
35
35
  },
@@ -0,0 +1,11 @@
1
+ - i have 2 users with access to the same tenant
2
+ - under this tenant i have 2 groups as follow:
3
+ - owner with the following packages [GRPCH_DEFAU, GRPCH_OWNER]
4
+ - member with the following packages [GRPCH_DEFAU, GRPCH_AMMBR, GRPCH_EGDTL, GRPCH_SMDIA, GRPCH_SMSSG, GRPCH_VMMBR]
5
+ - i have microservice connectonboarding with an api DELETE /group/chats/users/:userId and this api is only under package GRPCH_OWNER
6
+
7
+ i have the following usecase:
8
+ - load the provision by hitting the maintenance route /loadProvision
9
+ - user1 with member group login first and hit the acl api /soajs/acl, then we check the response and we see that he has the right packages and api DELETE /group/chats/users/:userId is not part of finalACL which is correct
10
+ - user2 with owner group login and hit the acl api /soajs/acl, then we check the response and we see that he has the right packages and api DELETE /group/chats/users/:userId is part of finalACL which is correct
11
+ - user1 with member group hit the acl api /soajs/acl again, then we check the response and we see that he has the right packages but api DELETE /group/chats/users/:userId is now part of finalACL which is not correct