@restorecommerce/acs-client 0.6.9 → 0.6.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/CHANGELOG.md +32 -0
- package/LICENSE +1 -1
- package/lib/acs/authz.js +188 -183
- package/lib/acs/authz.js.map +1 -1
- package/lib/acs/cache.d.ts +1 -1
- package/lib/acs/cache.js +105 -128
- package/lib/acs/cache.js.map +1 -1
- package/lib/acs/middleware.js +3 -12
- package/lib/acs/middleware.js.map +1 -1
- package/lib/acs/resolver.js +42 -29
- package/lib/acs/resolver.js.map +1 -1
- package/lib/utils.js +41 -30
- package/lib/utils.js.map +1 -1
- package/package.json +10 -13
- package/tsconfig.json +10 -2
package/lib/acs/cache.js
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
23
|
};
|
|
11
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
25
|
exports.setCacheStatus = exports.flushCache = exports.get = exports.getOrFill = exports.initializeCache = void 0;
|
|
13
26
|
const config_1 = require("../config");
|
|
14
|
-
const logger_1 = require("../logger");
|
|
15
|
-
const crypto = require("crypto");
|
|
16
|
-
const
|
|
17
|
-
const _ = require("lodash");
|
|
27
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
28
|
+
const crypto = __importStar(require("crypto"));
|
|
29
|
+
const redis_1 = require("redis");
|
|
30
|
+
const _ = __importStar(require("lodash"));
|
|
18
31
|
let attempted = false;
|
|
19
32
|
let redisInstance;
|
|
20
33
|
let ttl;
|
|
@@ -23,14 +36,14 @@ let redisSubjectInstance;
|
|
|
23
36
|
/**
|
|
24
37
|
* Initialize ACS Cache
|
|
25
38
|
*/
|
|
26
|
-
const initializeCache = () =>
|
|
39
|
+
const initializeCache = async () => {
|
|
27
40
|
if (attempted || !cacheEnabled) {
|
|
28
41
|
return;
|
|
29
42
|
}
|
|
30
43
|
attempted = true;
|
|
31
44
|
let redis;
|
|
32
45
|
try {
|
|
33
|
-
redis =
|
|
46
|
+
redis = await Promise.resolve().then(() => __importStar(require('redis')));
|
|
34
47
|
}
|
|
35
48
|
catch (e) {
|
|
36
49
|
}
|
|
@@ -38,17 +51,21 @@ const initializeCache = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
38
51
|
const redisConfig = config_1.cfg.get('authorization:cache');
|
|
39
52
|
const redisSubConfig = config_1.cfg.get('redis');
|
|
40
53
|
if (redisConfig) {
|
|
41
|
-
redisConfig.
|
|
42
|
-
redisInstance =
|
|
54
|
+
redisConfig.database = config_1.cfg.get('authorization:cache:db-index');
|
|
55
|
+
redisInstance = (0, redis_1.createClient)(redisConfig);
|
|
56
|
+
redisInstance.on('error', (err) => logger_1.default.error('Redis Client Error in ACS cache', err));
|
|
57
|
+
await redisInstance.connect();
|
|
43
58
|
ttl = config_1.cfg.get('authorization:cache:ttl');
|
|
44
59
|
}
|
|
45
60
|
if (redisSubConfig) {
|
|
46
61
|
// init redis subject instance
|
|
47
|
-
redisSubConfig.
|
|
48
|
-
redisSubjectInstance =
|
|
62
|
+
redisSubConfig.database = redisSubConfig['db-indexes']['db-subject'];
|
|
63
|
+
redisSubjectInstance = (0, redis_1.createClient)(redisSubConfig);
|
|
64
|
+
redisSubjectInstance.on('error', (err) => logger_1.default.error('Redis Client Error in ACS cache', err));
|
|
65
|
+
await redisSubjectInstance.connect();
|
|
49
66
|
}
|
|
50
67
|
}
|
|
51
|
-
}
|
|
68
|
+
};
|
|
52
69
|
exports.initializeCache = initializeCache;
|
|
53
70
|
/**
|
|
54
71
|
* Find the object in cache. If not found, compute it using the filler function
|
|
@@ -57,7 +74,7 @@ exports.initializeCache = initializeCache;
|
|
|
57
74
|
* @param filler The function to execute if key is not found in cache
|
|
58
75
|
* @param prefix The prefix to apply to the object key in the cache
|
|
59
76
|
*/
|
|
60
|
-
const getOrFill = (keyData, filler, useCache, prefix) =>
|
|
77
|
+
const getOrFill = async (keyData, filler, useCache, prefix) => {
|
|
61
78
|
if (!redisInstance || !cacheEnabled) {
|
|
62
79
|
return filler(keyData);
|
|
63
80
|
}
|
|
@@ -66,57 +83,47 @@ const getOrFill = (keyData, filler, useCache, prefix) => __awaiter(void 0, void
|
|
|
66
83
|
if (prefix) {
|
|
67
84
|
redisKey = `${prefix}:` + redisKey;
|
|
68
85
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
evaluation_cacheable = rule.evaluation_cacheable;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
else if (rule.evaluation_cacheable) {
|
|
88
|
-
evaluation_cacheable = rule.evaluation_cacheable;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
86
|
+
let redisKeyResponse = await redisInstance.get(redisKey);
|
|
87
|
+
if (redisKeyResponse && useCache) {
|
|
88
|
+
const response = JSON.parse(redisKeyResponse);
|
|
89
|
+
let evaluation_cacheable = response.evaluation_cacheable;
|
|
90
|
+
if (response && !_.isEmpty(response.policy_sets)) {
|
|
91
|
+
const policies = response.policy_sets[0].policies;
|
|
92
|
+
if (policies && policies.length > 0) {
|
|
93
|
+
for (let policy of policies) {
|
|
94
|
+
for (let rule of policy.rules) {
|
|
95
|
+
if (!rule.evaluation_cacheable || (rule.evaluation_cacheable === false)) {
|
|
96
|
+
evaluation_cacheable = rule.evaluation_cacheable;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
else if (rule.evaluation_cacheable) {
|
|
100
|
+
evaluation_cacheable = rule.evaluation_cacheable;
|
|
91
101
|
}
|
|
92
102
|
}
|
|
93
103
|
}
|
|
94
|
-
if (evaluation_cacheable) {
|
|
95
|
-
logger_1.default.debug('Found key in cache: ' + redisKey);
|
|
96
|
-
return resolve(response);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (!useCache) {
|
|
100
|
-
return filler(keyData).then((data) => {
|
|
101
|
-
// when useCache is false, dont store in cache
|
|
102
|
-
resolve(data);
|
|
103
|
-
}).catch(reject);
|
|
104
104
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
105
|
+
}
|
|
106
|
+
if (evaluation_cacheable) {
|
|
107
|
+
logger_1.default.debug('Found key in cache: ' + redisKey);
|
|
108
|
+
return response;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (!useCache) {
|
|
112
|
+
// when useCache is false, dont store in cache
|
|
113
|
+
return await filler(keyData);
|
|
114
|
+
}
|
|
115
|
+
logger_1.default.debug('Filling cache key: ' + redisKey);
|
|
116
|
+
const acsResponse = await filler(keyData);
|
|
117
|
+
if (acsResponse) {
|
|
118
|
+
if (ttl) {
|
|
119
|
+
await redisInstance.setEx(redisKey, ttl, JSON.stringify(acsResponse));
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
await redisInstance.set(redisKey, JSON.stringify(acsResponse));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return acsResponse;
|
|
126
|
+
};
|
|
120
127
|
exports.getOrFill = getOrFill;
|
|
121
128
|
/**
|
|
122
129
|
* Find the object in cache.
|
|
@@ -125,84 +132,54 @@ exports.getOrFill = getOrFill;
|
|
|
125
132
|
* @param filler The function to execute if key is not found in cache
|
|
126
133
|
* @param prefix The prefix to apply to the object key in the cache
|
|
127
134
|
*/
|
|
128
|
-
const get = (key) =>
|
|
135
|
+
const get = async (key) => {
|
|
129
136
|
if (!redisSubjectInstance) {
|
|
130
137
|
return;
|
|
131
138
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
if (!err && !reply) {
|
|
144
|
-
logger_1.default.info('Key does not exist', { key });
|
|
145
|
-
resolve(0);
|
|
146
|
-
}
|
|
147
|
-
}));
|
|
148
|
-
});
|
|
149
|
-
});
|
|
139
|
+
const redisResponse = await redisSubjectInstance.get(key);
|
|
140
|
+
if (!redisResponse) {
|
|
141
|
+
logger_1.default.info('Key does not exist', { key });
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (redisResponse) {
|
|
145
|
+
logger_1.default.debug('Found key in cache: ' + key);
|
|
146
|
+
return JSON.parse(redisResponse);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
150
149
|
exports.get = get;
|
|
151
150
|
/**
|
|
152
151
|
* Flush the ACS cache
|
|
153
152
|
*
|
|
154
153
|
* @param prefix An optional prefix to flush instead of entire cache
|
|
155
154
|
*/
|
|
156
|
-
const flushCache = (prefix) =>
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (redisConfig) {
|
|
160
|
-
redisConfig.db = config_1.cfg.get('authorization:cache:db-index');
|
|
161
|
-
ioredisInstance = new Redis(redisConfig);
|
|
162
|
-
}
|
|
163
|
-
if (!ioredisInstance || !cacheEnabled) {
|
|
155
|
+
const flushCache = async (prefix) => {
|
|
156
|
+
if (!redisInstance || !cacheEnabled) {
|
|
157
|
+
logger_1.default.info('Redis client not initialized in acs-client');
|
|
164
158
|
return;
|
|
165
159
|
}
|
|
166
160
|
if (prefix != undefined) {
|
|
167
|
-
let
|
|
168
|
-
|
|
169
|
-
let
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
for (
|
|
173
|
-
|
|
174
|
-
pipeline.del(resultKeys[i]);
|
|
161
|
+
let flushPattern = `acs:${prefix}:*`;
|
|
162
|
+
logger_1.default.debug(`Flushing cache with pattern ${flushPattern}`);
|
|
163
|
+
let scanIterator;
|
|
164
|
+
try {
|
|
165
|
+
scanIterator = redisInstance.scanIterator({ MATCH: flushPattern, COUNT: 100 });
|
|
166
|
+
for await (const key of scanIterator) {
|
|
167
|
+
await redisInstance.del(key);
|
|
175
168
|
}
|
|
176
|
-
|
|
177
|
-
pipeline.exec(() => { logger_1.default.info('one batch delete complete'); });
|
|
178
|
-
localKeys = [];
|
|
179
|
-
pipeline = ioredisInstance.pipeline();
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
stream.on('end', () => {
|
|
183
|
-
pipeline.exec(() => { logger_1.default.info('final batch delete complete'); });
|
|
169
|
+
logger_1.default.debug(`Successfully flushed cache pattern ${flushPattern}`);
|
|
184
170
|
return;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
logger_1.default.error('
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
logger_1.default.error('Error flushing ACS cache', { message: err.message });
|
|
188
174
|
return;
|
|
189
|
-
}
|
|
190
|
-
return;
|
|
175
|
+
}
|
|
191
176
|
}
|
|
192
177
|
logger_1.default.debug('Flushing ACS cache');
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
if (reply) {
|
|
200
|
-
logger_1.default.debug('Flushed ACS cache');
|
|
201
|
-
return resolve(0);
|
|
202
|
-
}
|
|
203
|
-
}));
|
|
204
|
-
});
|
|
205
|
-
});
|
|
178
|
+
const reply = await redisInstance.flushDb();
|
|
179
|
+
if (reply) {
|
|
180
|
+
logger_1.default.debug('Flushed ACS cache');
|
|
181
|
+
}
|
|
182
|
+
};
|
|
206
183
|
exports.flushCache = flushCache;
|
|
207
184
|
/**
|
|
208
185
|
* Enable / Disable ACS Caching
|
package/lib/acs/cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/acs/cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/acs/cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAgC;AAChC,uDAA+B;AAC/B,+CAAiC;AACjC,iCAAsD;AACtD,0CAA4B;AAE5B,IAAI,SAAS,GAAG,KAAK,CAAC;AACtB,IAAI,aAAwC,CAAC;AAC7C,IAAI,GAAuB,CAAC;AAC5B,IAAI,YAAY,GAAG,IAAI,CAAC;AACxB,IAAI,oBAA+C,CAAC;AAEpD;;GAEG;AACI,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE;IACxC,IAAI,SAAS,IAAI,CAAC,YAAY,EA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BAAmB,CAAC,CAAC;QAClC,IAAA,uBAAe,GAAE,CAAC;KACnB;SAAM;QACL,gBAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACpC;AACH,CAAC,CAAC;AATW,QAAA,cAAc,kBASzB"}
|
package/lib/acs/middleware.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.acsClientMiddleware = void 0;
|
|
13
4
|
const authz_1 = require("./authz");
|
|
@@ -16,10 +7,10 @@ const authz_1 = require("./authz");
|
|
|
16
7
|
*/
|
|
17
8
|
const acsClientMiddleware = (config) => {
|
|
18
9
|
(0, authz_1.initAuthZ)(config);
|
|
19
|
-
return (ctx, next) =>
|
|
10
|
+
return async (ctx, next) => {
|
|
20
11
|
ctx.authZ = authz_1.authZ;
|
|
21
|
-
|
|
22
|
-
}
|
|
12
|
+
await next();
|
|
13
|
+
};
|
|
23
14
|
};
|
|
24
15
|
exports.acsClientMiddleware = acsClientMiddleware;
|
|
25
16
|
//# sourceMappingURL=middleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/acs/middleware.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/acs/middleware.ts"],"names":[],"mappings":";;;AAAA,mCAA2C;AAE3C;;GAEG;AACI,MAAM,mBAAmB,GAAG,CAAC,MAAY,EAAE,EAAE;IAClD,IAAA,iBAAS,EAAC,MAAM,CAAC,CAAC;IAElB,OAAO,KAAK,EAAE,GAAQ,EAAE,IAAI,EAAE,EAAE;QAC9B,GAAG,CAAC,KAAK,GAAG,aAAK,CAAC;QAClB,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,mBAAmB,uBAO9B"}
|
package/lib/acs/resolver.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
23
|
};
|
|
11
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
25
|
exports.whatIsAllowed = exports.isAllowed = exports.accessRequest = exports.isAllowedRequest = void 0;
|
|
13
|
-
const _ = require("lodash");
|
|
26
|
+
const _ = __importStar(require("lodash"));
|
|
14
27
|
const interfaces_1 = require("./interfaces");
|
|
15
|
-
const logger_1 = require("../logger");
|
|
28
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
16
29
|
const config_1 = require("../config");
|
|
17
30
|
const utils_1 = require("../utils");
|
|
18
31
|
const grpc_client_1 = require("@restorecommerce/grpc-client");
|
|
@@ -21,12 +34,12 @@ const subjectIsUnauthenticated = (subject) => {
|
|
|
21
34
|
return !!subject
|
|
22
35
|
&& 'unauthenticated' in subject && subject['unauthenticated'];
|
|
23
36
|
};
|
|
24
|
-
const whatIsAllowedRequest = (subject, resource, action, ctx, useCache) =>
|
|
37
|
+
const whatIsAllowedRequest = async (subject, resource, action, ctx, useCache) => {
|
|
25
38
|
if (subjectIsUnauthenticated(subject)) {
|
|
26
39
|
const grpcConfig = config_1.cfg.get('client:acs-srv');
|
|
27
40
|
const acsClient = new grpc_client_1.GrpcClient(grpcConfig, logger_1.default);
|
|
28
41
|
const acs = acsClient['acs-srv'];
|
|
29
|
-
return
|
|
42
|
+
return await new authz_1.UnAuthZ(acs).whatIsAllowed({
|
|
30
43
|
target: {
|
|
31
44
|
subject: subject, resource, action
|
|
32
45
|
},
|
|
@@ -36,7 +49,7 @@ const whatIsAllowedRequest = (subject, resource, action, ctx, useCache) => __awa
|
|
|
36
49
|
}, ctx, useCache);
|
|
37
50
|
}
|
|
38
51
|
else {
|
|
39
|
-
return
|
|
52
|
+
return await authz_1.authZ.whatIsAllowed({
|
|
40
53
|
context: {
|
|
41
54
|
security: {}
|
|
42
55
|
},
|
|
@@ -47,13 +60,13 @@ const whatIsAllowedRequest = (subject, resource, action, ctx, useCache) => __awa
|
|
|
47
60
|
}
|
|
48
61
|
}, ctx, useCache);
|
|
49
62
|
}
|
|
50
|
-
}
|
|
51
|
-
const isAllowedRequest = (subject, resource, action, ctx, useCache) =>
|
|
63
|
+
};
|
|
64
|
+
const isAllowedRequest = async (subject, resource, action, ctx, useCache) => {
|
|
52
65
|
if (subjectIsUnauthenticated(subject)) {
|
|
53
66
|
const grpcConfig = config_1.cfg.get('client:acs-srv');
|
|
54
67
|
const acsClient = new grpc_client_1.GrpcClient(grpcConfig, logger_1.default);
|
|
55
68
|
const acs = acsClient['acs-srv'];
|
|
56
|
-
return
|
|
69
|
+
return await new authz_1.UnAuthZ(acs).isAllowed({
|
|
57
70
|
target: {
|
|
58
71
|
subject: subject, resource, action
|
|
59
72
|
},
|
|
@@ -63,7 +76,7 @@ const isAllowedRequest = (subject, resource, action, ctx, useCache) => __awaiter
|
|
|
63
76
|
}, ctx, useCache);
|
|
64
77
|
}
|
|
65
78
|
else {
|
|
66
|
-
return
|
|
79
|
+
return await authz_1.authZ.isAllowed({
|
|
67
80
|
context: {
|
|
68
81
|
security: {}
|
|
69
82
|
},
|
|
@@ -74,7 +87,7 @@ const isAllowedRequest = (subject, resource, action, ctx, useCache) => __awaiter
|
|
|
74
87
|
}
|
|
75
88
|
}, ctx, useCache);
|
|
76
89
|
}
|
|
77
|
-
}
|
|
90
|
+
};
|
|
78
91
|
exports.isAllowedRequest = isAllowedRequest;
|
|
79
92
|
/**
|
|
80
93
|
* It turns an API request as can be found in typical Web frameworks like express, koa etc.
|
|
@@ -94,7 +107,7 @@ exports.isAllowedRequest = isAllowedRequest;
|
|
|
94
107
|
* is not used and ACS request is made to `access-control-srv`
|
|
95
108
|
* @returns {DecisionResponse | PolicySetRQResponse}
|
|
96
109
|
*/
|
|
97
|
-
const accessRequest = (subject, resource, action, ctx, operation, database, useCache = true) =>
|
|
110
|
+
const accessRequest = async (subject, resource, action, ctx, operation, database, useCache = true) => {
|
|
98
111
|
// when subject is not passed (if auth header is not set)
|
|
99
112
|
if (_.isEmpty(subject)) {
|
|
100
113
|
subject = { unauthenticated: true };
|
|
@@ -164,7 +177,7 @@ const accessRequest = (subject, resource, action, ctx, operation, database, useC
|
|
|
164
177
|
try {
|
|
165
178
|
// retrieving set of applicable policies/rules from ACS
|
|
166
179
|
// Note: it is assumed that there is only one policy set
|
|
167
|
-
policySetResponse =
|
|
180
|
+
policySetResponse = await whatIsAllowedRequest(subClone, resource, action, ctx, useCache);
|
|
168
181
|
}
|
|
169
182
|
catch (err) {
|
|
170
183
|
logger_1.default.error('Error calling whatIsAllowed operation', { message: err.message });
|
|
@@ -187,7 +200,7 @@ const accessRequest = (subject, resource, action, ctx, operation, database, useC
|
|
|
187
200
|
`config is disabled overriding the ACS result`);
|
|
188
201
|
}
|
|
189
202
|
// create filters to enforce applicable policies and custom query / args if applicable
|
|
190
|
-
const resourceFilters =
|
|
203
|
+
const resourceFilters = await (0, utils_1.createResourceFilterMap)(resource, policySetResponse, ctx.resources, action, subClone, subjectID, authzEnforced, targetScope, database);
|
|
191
204
|
if (resourceFilters.decision) {
|
|
192
205
|
return resourceFilters;
|
|
193
206
|
}
|
|
@@ -214,7 +227,7 @@ const accessRequest = (subject, resource, action, ctx, operation, database, useC
|
|
|
214
227
|
if (operation === interfaces_1.Operation.isAllowed) {
|
|
215
228
|
// authorization
|
|
216
229
|
try {
|
|
217
|
-
decisionResponse =
|
|
230
|
+
decisionResponse = await (0, exports.isAllowedRequest)(subClone, resource, action, ctx, useCache);
|
|
218
231
|
}
|
|
219
232
|
catch (err) {
|
|
220
233
|
logger_1.default.error('Error calling isAllowed operation', { message: err.message });
|
|
@@ -250,7 +263,7 @@ const accessRequest = (subject, resource, action, ctx, operation, database, useC
|
|
|
250
263
|
decisionResponse.decision = interfaces_1.Decision.PERMIT;
|
|
251
264
|
}
|
|
252
265
|
return decisionResponse;
|
|
253
|
-
}
|
|
266
|
+
};
|
|
254
267
|
exports.accessRequest = accessRequest;
|
|
255
268
|
/**
|
|
256
269
|
* Exposes the isAllowed() api of `access-control-srv` and retruns the response
|
|
@@ -259,10 +272,10 @@ exports.accessRequest = accessRequest;
|
|
|
259
272
|
* @param {ACSContext} ctx Context Object containing requester's subject information
|
|
260
273
|
* @return {Decision} PERMIT or DENY or INDETERMINATE
|
|
261
274
|
*/
|
|
262
|
-
const isAllowed = (request, authZ) =>
|
|
275
|
+
const isAllowed = async (request, authZ) => {
|
|
263
276
|
let isAllowedResponse;
|
|
264
277
|
try {
|
|
265
|
-
isAllowedResponse =
|
|
278
|
+
isAllowedResponse = await authZ.acs.isAllowed(request);
|
|
266
279
|
if (isAllowedResponse && isAllowedResponse.obligation && isAllowedResponse.obligation.length > 0) {
|
|
267
280
|
isAllowedResponse.obligation = (0, utils_1.mapResourceURNObligationProperties)(isAllowedResponse.obligation);
|
|
268
281
|
}
|
|
@@ -273,7 +286,7 @@ const isAllowed = (request, authZ) => __awaiter(void 0, void 0, void 0, function
|
|
|
273
286
|
return { decision: interfaces_1.Decision.DENY, operation_status: (0, utils_1.generateOperationStatus)(err.code, err.message) };
|
|
274
287
|
}
|
|
275
288
|
return isAllowedResponse;
|
|
276
|
-
}
|
|
289
|
+
};
|
|
277
290
|
exports.isAllowed = isAllowed;
|
|
278
291
|
/**
|
|
279
292
|
* Exposes the whatIsAllowed() api of `access-control-srv` and retruns the response
|
|
@@ -282,10 +295,10 @@ exports.isAllowed = isAllowed;
|
|
|
282
295
|
* @param {ACSContext} ctx Context Object containing requester's subject information
|
|
283
296
|
* @return {PolicySetRQ} set of applicalbe policies and rules for the input request
|
|
284
297
|
*/
|
|
285
|
-
const whatIsAllowed = (request, authZ) =>
|
|
298
|
+
const whatIsAllowed = async (request, authZ) => {
|
|
286
299
|
let whatIsAllowedResponse;
|
|
287
300
|
try {
|
|
288
|
-
whatIsAllowedResponse =
|
|
301
|
+
whatIsAllowedResponse = await authZ.acs.whatIsAllowed(request);
|
|
289
302
|
if (whatIsAllowedResponse && whatIsAllowedResponse.obligation && whatIsAllowedResponse.obligation.length > 0) {
|
|
290
303
|
whatIsAllowedResponse.obligation = (0, utils_1.mapResourceURNObligationProperties)(whatIsAllowedResponse.obligation);
|
|
291
304
|
}
|
|
@@ -296,6 +309,6 @@ const whatIsAllowed = (request, authZ) => __awaiter(void 0, void 0, void 0, func
|
|
|
296
309
|
return { decision: interfaces_1.Decision.DENY, policy_sets: [], operation_status: (0, utils_1.generateOperationStatus)(err.code, err.message) };
|
|
297
310
|
}
|
|
298
311
|
return whatIsAllowedResponse;
|
|
299
|
-
}
|
|
312
|
+
};
|
|
300
313
|
exports.whatIsAllowed = whatIsAllowed;
|
|
301
314
|
//# sourceMappingURL=resolver.js.map
|
package/lib/acs/resolver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../src/acs/resolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../src/acs/resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4B;AAC5B,6CAGsB;AAEtB,uDAA+B;AAC/B,sCAAwC;AACxC,oCAAmI;AACnI,8DAA0D;AAC1D,mCAAmD;AAGnD,MAAM,wBAAwB,GAAG,CAAC,OAAY,EAAqC,EAAE;IACnF,OAAO,CAAC,CAAC,OAAO;WACX,iBAAiB,IAAI,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAClE,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,KAAK,EAAE,OAAgB,EAAE,QAAoB,EACxE,MAAmB,EAAE,GAAqB,EAAE,QAAiB,EAAE,EAAE;IACjE,IAAI,wBAAwB,CAAC,OAAO,CAAC,EAAE;QACrC,MAAM,UAAU,GAAG,YAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC7C,MAAM,SAAS,GAAG,IAAI,wBAAU,CAAC,UAAU,EAAE,gBAAM,CAAC,CA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