soajs.controller 4.2.17 → 4.2.19

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/.travis.yml CHANGED
@@ -58,6 +58,12 @@ jobs:
58
58
  - docker push soajsorg/gateway
59
59
  - docker push soajsorg/gateway:${PACKAGE_VERSION}
60
60
  - docker push soajsorg/gateway:${MAJOR_VERSION}.x
61
+ before_deploy:
62
+ - yes | gem update --system --force
63
+ - gem install bundler
64
+ - gem install faraday-net_http -v '3.3.0'
65
+ - gem install uri
66
+ - gem install logger
61
67
  deploy:
62
68
  on:
63
69
  all_branches: true
@@ -33,7 +33,9 @@ module.exports = () => {
33
33
  let userId = null;
34
34
  if (req.soajs.uracDriver) {
35
35
  let uracObj = req.soajs.uracDriver.getProfile();
36
- userId = uracObj._id;
36
+ if (uracObj) {
37
+ userId = uracObj._id;
38
+ }
37
39
  }
38
40
 
39
41
  if (userId) {
@@ -12,7 +12,7 @@ const coreLibs = require("soajs.core.libs");
12
12
 
13
13
  module.exports = (configuration) => {
14
14
  let core = configuration.core;
15
-
15
+
16
16
  let return_SOAJS_keyACL = (req) => {
17
17
  let ACL = null;
18
18
  let ALLOWED_PACKAGES = null;
@@ -73,21 +73,47 @@ module.exports = (configuration) => {
73
73
  }
74
74
  }
75
75
  }
76
+
77
+ let urac = null;
78
+ if (req.soajs.uracDriver) {
79
+ let uracObj = req.soajs.uracDriver.getProfile();
80
+ if (uracObj) {
81
+ urac = {
82
+ "_id": uracObj._id
83
+ };
84
+ }
85
+ }
86
+
87
+ let tenant = null;
88
+ let keyObj = req.soajs.controller.serviceParams.keyObj;
89
+ if (keyObj && keyObj.application && keyObj.application.package) {
90
+ tenant = {
91
+ "id": keyObj.tenant.id,
92
+ "name": keyObj.tenant.name,
93
+ "code": keyObj.tenant.code,
94
+ // "locked": keyObj.tenant.locked,
95
+ // "roaming": data.req.soajs.tenant.roaming,
96
+ "type": keyObj.tenant.type
97
+ };
98
+ }
99
+
76
100
  let response = {
77
101
  "acl": ACL,
78
102
  "finalACL": finalACL,
79
- "packages": ALLOWED_PACKAGES
103
+ "packages": ALLOWED_PACKAGES,
104
+ "urac": urac,
105
+ "tenant": tenant
80
106
  };
81
107
  return req.soajs.controllerResponse(response);
82
108
  };
83
-
109
+
84
110
  return (req, res, next) => {
85
-
111
+
86
112
  //doesn't work without a key in the headers
87
113
  if (!req.headers || !req.headers.key) {
88
114
  return req.soajs.controllerResponse(core.error.getError(132));
89
115
  }
90
-
116
+
91
117
  //mimic a service named controller with route /key/permission/get
92
118
  let serviceName = configuration.serviceName;
93
119
  req.soajs.controller.serviceParams.registry = req.soajs.registry.services[serviceName];
@@ -112,10 +138,10 @@ module.exports = (configuration) => {
112
138
  ]
113
139
  }
114
140
  };
115
-
141
+
116
142
  //assign the correct method to gotoservice in controller
117
143
  req.soajs.controller.gotoservice = return_SOAJS_keyACL;
118
144
  return next();
119
-
145
+
120
146
  };
121
147
  };
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.2.17",
4
+ "version": "4.2.19",
5
5
  "author": {
6
6
  "name": "soajs team",
7
7
  "email": "team@soajs.org"
@@ -84,6 +84,7 @@ describe("Integration for Usecase 1", function () {
84
84
  }
85
85
  };
86
86
  requester('get', options, (error, body) => {
87
+ assert.ok(body.finalACL);
87
88
  assert.ok(body.acl);
88
89
  done();
89
90
  });