@izara_project/izara-core-generate-service-code 1.0.86 → 1.0.87
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/package.json +1 -1
- package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +1 -1
- package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +22 -15
- package/src/emit/crud/crudActionPlan.js +1 -1
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +6 -4
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +12 -3
- package/src/emit/crud/templates/CreateLogicalLib.ejs +85 -20
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +12 -3
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +12 -3
- package/src/emit/function/functionYamlArtifact.js +4 -2
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +0 -3
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +1 -116
- package/src/emit/rbac/templates/CancelUsage_Main.ejs +14 -10
- package/src/emit/rbac/templates/ConfirmUsage_Main.ejs +14 -10
- package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +22 -12
- package/src/emit/rbac/templates/GetMyPermissions_Main.ejs +14 -10
- package/src/emit/rbac/templates/ReservedDynamicUsage_Main.ejs +76 -34
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +12 -9
- package/src/emit/resource/emitResourceArtifacts.js +32 -6
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +14 -18
- package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +4 -2
- package/test/createTargetRoleHandler.test.js +1 -15
- package/test/crudApplicationArtifacts.test.js +9 -3
- package/test/customFlowApplicationArtifacts.test.js +3 -5
- package/test/dynamicCrudFlowSchemas.test.js +5 -17
- package/test/dynamicRbacFlowSchemas.test.js +0 -3
- package/test/functionYamlArtifact.test.js +4 -2
- package/test/resourceArtifacts.test.js +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-generate-service-code",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.87",
|
|
4
4
|
"description": "Code for locally generating per service files",
|
|
5
5
|
"homepage": "https://bitbucket.org/izara-core-support-services/izara-core-support-services-generate-service-code#readme",
|
|
6
6
|
"repository": {
|
|
@@ -95,12 +95,12 @@ function _extractDynamoTableNames({
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
if (rbac) {
|
|
98
|
+
dynamoTableNames.add('Roles');
|
|
98
99
|
dynamoTableNames.add('TargetRoles');
|
|
99
100
|
dynamoTableNames.add('RolePermissions');
|
|
100
101
|
dynamoTableNames.add('RoleUsers');
|
|
101
102
|
dynamoTableNames.add('UserRoles');
|
|
102
103
|
dynamoTableNames.add('RbacPermissionCaches');
|
|
103
|
-
dynamoTableNames.add('RoleLimit');
|
|
104
104
|
dynamoTableNames.add('RunningTotalUsage');
|
|
105
105
|
dynamoTableNames.add('RunningTotalReservedUsage');
|
|
106
106
|
}
|
|
@@ -66,12 +66,12 @@ const externalServices = {
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
if (typeof rbac !== 'undefined' && rbac) {
|
|
69
|
+
dynamoTableNames.add('Roles');
|
|
69
70
|
dynamoTableNames.add('TargetRoles');
|
|
70
71
|
dynamoTableNames.add('RolePermissions');
|
|
71
72
|
dynamoTableNames.add('RoleUsers');
|
|
72
73
|
dynamoTableNames.add('UserRoles');
|
|
73
74
|
dynamoTableNames.add('RbacPermissionCaches');
|
|
74
|
-
dynamoTableNames.add('RoleLimit');
|
|
75
75
|
dynamoTableNames.add('RunningTotalUsage');
|
|
76
76
|
dynamoTableNames.add('RunningTotalReservedUsage');
|
|
77
77
|
}
|
|
@@ -182,20 +182,6 @@ const tableConfigs = {
|
|
|
182
182
|
const currentServiceTag = (typeof serviceTag !== 'undefined' && serviceTag) ? serviceTag : ((typeof project !== 'undefined' && project?.serviceTag) ? project.serviceTag : '');
|
|
183
183
|
const rbacSubs = [];
|
|
184
184
|
if (crud && rbac) {
|
|
185
|
-
const allRbacTags = Array.from(new Set([
|
|
186
|
-
'Rbac',
|
|
187
|
-
currentServiceTag,
|
|
188
|
-
...(typeof rbacValidatorServiceTags !== 'undefined' && rbacValidatorServiceTags ? rbacValidatorServiceTags : [])
|
|
189
|
-
])).filter(Boolean);
|
|
190
|
-
const hasGraph = typeof objectGraphServiceTags !== 'undefined' && objectGraphServiceTags && objectGraphServiceTags.length > 0;
|
|
191
|
-
const createEndpoint = hasGraph ? 'CreateRbacCallbackHdrSqs' : 'CreateCompleteHdrSqs';
|
|
192
|
-
const updateEndpoint = hasGraph ? 'UpdateRbacCallbackHdrSqs' : 'UpdateCompleteHdrSqs';
|
|
193
|
-
const deleteEndpoint = hasGraph ? 'DeleteRbacCallbackHdrSqs' : 'DeleteCompleteHdrSqs';
|
|
194
|
-
allRbacTags.forEach(function(tag) {
|
|
195
|
-
rbacSubs.push({ serviceTag: tag, topicName: 'ValidatorRbac_Out', sqsEndpoint: createEndpoint });
|
|
196
|
-
rbacSubs.push({ serviceTag: tag, topicName: 'ValidatorRbac_Out', sqsEndpoint: updateEndpoint });
|
|
197
|
-
rbacSubs.push({ serviceTag: tag, topicName: 'ValidatorRbac_Out', sqsEndpoint: deleteEndpoint });
|
|
198
|
-
});
|
|
199
185
|
if (typeof hasQuotaReservation !== 'undefined' && hasQuotaReservation) {
|
|
200
186
|
rbacSubs.push({ serviceTag: 'Rbac', topicName: 'ConfirmUsage_Out', sqsEndpoint: 'CreateCompleteHdrSqs' });
|
|
201
187
|
rbacSubs.push({ serviceTag: 'Rbac', topicName: 'CancelUsage_Out', sqsEndpoint: 'CreateCompleteHdrSqs' });
|
|
@@ -318,6 +304,17 @@ function roleConfigs() {
|
|
|
318
304
|
<% }); -%>
|
|
319
305
|
<% } -%>
|
|
320
306
|
<% if (rbac || (rbacValidatorServiceTags && rbacValidatorServiceTags.length > 0)) { -%>
|
|
307
|
+
{
|
|
308
|
+
Sid: 'FlowObjectsInvokeValidatorRbac',
|
|
309
|
+
Effect: 'Allow',
|
|
310
|
+
Action: ['lambda:InvokeFunction'],
|
|
311
|
+
Resource: [
|
|
312
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'ValidatorRbacHdrInv', 'Rbac')}`<% if (rbac) { %>,
|
|
313
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'ValidatorRbacHdrInv')}`<% } %><% (rbacValidatorServiceTags || []).forEach(function(tag) { %>,
|
|
314
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'ValidatorRbacHdrInv', '<%= tag %>')}`<% }); %>
|
|
315
|
+
]
|
|
316
|
+
},
|
|
317
|
+
|
|
321
318
|
{
|
|
322
319
|
Sid: 'FlowObjectsPublishValidatorRbacTopics',
|
|
323
320
|
Effect: 'Allow',
|
|
@@ -340,6 +337,16 @@ function roleConfigs() {
|
|
|
340
337
|
{
|
|
341
338
|
roleName: 'FlowRbac',
|
|
342
339
|
statement: [
|
|
340
|
+
{
|
|
341
|
+
Sid: 'FlowRbacInvokeValidatorRbac',
|
|
342
|
+
Effect: 'Allow',
|
|
343
|
+
Action: ['lambda:InvokeFunction'],
|
|
344
|
+
Resource: [
|
|
345
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'ValidatorRbacHdrInv', 'Rbac')}`<% if (rbac) { %>,
|
|
346
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'ValidatorRbacHdrInv')}`<% } %><% (rbacValidatorServiceTags || []).forEach(function(tag) { %>,
|
|
347
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'ValidatorRbacHdrInv', '<%= tag %>')}`<% }); %>
|
|
348
|
+
]
|
|
349
|
+
},
|
|
343
350
|
{
|
|
344
351
|
Sid: 'FlowRbacPublishValidatorRbacTopics',
|
|
345
352
|
Effect: 'Allow',
|
|
@@ -32,7 +32,7 @@ export function createCrudActionPlan(
|
|
|
32
32
|
hasRbac: actionHasRbac,
|
|
33
33
|
hasQuotaReservation,
|
|
34
34
|
hasComplete: outputTopic && (actionHasRbac || hasGraph),
|
|
35
|
-
hasRbacCallback:
|
|
35
|
+
hasRbacCallback: false,
|
|
36
36
|
hasCreateNodeCallback:
|
|
37
37
|
outputTopic && action === 'Create' && actionHasRbac && hasGraph && hasQuotaReservation
|
|
38
38
|
};
|
|
@@ -73,16 +73,17 @@ function _createDynamicFlow(action, plan, serviceTag = '', initiateBy = 'user')
|
|
|
73
73
|
}
|
|
74
74
|
);
|
|
75
75
|
} else if (plan.hasComplete) {
|
|
76
|
+
const nextStepName = plan.hasCreateNodeCallback ? 'CreateNodeCallback' : 'Complete';
|
|
76
77
|
startNextSteps.push({
|
|
77
78
|
targetType: 'ownTopic',
|
|
78
|
-
stepName:
|
|
79
|
+
stepName: nextStepName
|
|
79
80
|
});
|
|
80
81
|
if (plan.hasGraph) {
|
|
81
82
|
startNextSteps.push({
|
|
82
83
|
targetType: 'extTopic',
|
|
83
84
|
serviceTag: 'GraphHandler',
|
|
84
85
|
topicName: `${action}Node_In`,
|
|
85
|
-
toStepNames: [
|
|
86
|
+
toStepNames: [nextStepName]
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
89
|
}
|
|
@@ -143,19 +144,20 @@ function _createDynamicFlow(action, plan, serviceTag = '', initiateBy = 'user')
|
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
if (plan.hasCreateNodeCallback) {
|
|
147
|
+
const prevStepName = plan.hasRbacCallback ? 'RbacCallback' : 'Start';
|
|
146
148
|
flowSteps.push({
|
|
147
149
|
stepName: 'CreateNodeCallback',
|
|
148
150
|
event: ['extTopic'],
|
|
149
151
|
previousSteps: [
|
|
150
152
|
{
|
|
151
153
|
sourceType: 'ownTopic',
|
|
152
|
-
stepName:
|
|
154
|
+
stepName: prevStepName
|
|
153
155
|
},
|
|
154
156
|
{
|
|
155
157
|
sourceType: 'extTopic',
|
|
156
158
|
serviceTag: 'GraphHandler',
|
|
157
159
|
topicName: 'CreateNode_Out',
|
|
158
|
-
fromStepNames: [
|
|
160
|
+
fromStepNames: [prevStepName]
|
|
159
161
|
}
|
|
160
162
|
],
|
|
161
163
|
nextSteps: [
|
|
@@ -381,11 +381,12 @@ export default async function <%- flowTag %>(
|
|
|
381
381
|
},
|
|
382
382
|
parameterGroups,
|
|
383
383
|
{
|
|
384
|
+
targetIdentifiers,
|
|
384
385
|
rbacObjType: {
|
|
385
386
|
serviceTag: <%- rbacServiceTags.length === 1 ? rbacServiceTags[0] : `{ ${Object.entries(rbacServiceTagMap).map(([k, v]) => `'${k}': ${v}`).join(', ')} }[requestParams.objectType] || process.env.iz_serviceTag` %>
|
|
386
387
|
},
|
|
387
388
|
requestParams: requestParams,
|
|
388
|
-
|
|
389
|
+
sync: true
|
|
389
390
|
}
|
|
390
391
|
);
|
|
391
392
|
|
|
@@ -394,10 +395,18 @@ export default async function <%- flowTag %>(
|
|
|
394
395
|
resultPermissionCheck
|
|
395
396
|
);
|
|
396
397
|
|
|
398
|
+
if (resultPermissionCheck && resultPermissionCheck.permission !== true) {
|
|
399
|
+
errorsFound.push('Permission denied');
|
|
400
|
+
return await <%- flowTag %>LogicalLib(
|
|
401
|
+
_izContext,
|
|
402
|
+
requestParams,
|
|
403
|
+
callingFlowConfig,
|
|
404
|
+
errorsFound
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
|
|
397
408
|
//(<rbacPublish_<%- flowTag %>)
|
|
398
409
|
//(</rbacPublish_<%- flowTag %>)
|
|
399
|
-
|
|
400
|
-
return resultPermissionCheck;
|
|
401
410
|
}
|
|
402
411
|
<%_ } _%>
|
|
403
412
|
|
|
@@ -385,21 +385,51 @@ export async function autoProvisionOwnerTargetRole(_izContext, { node, submitted
|
|
|
385
385
|
}
|
|
386
386
|
|
|
387
387
|
const identifiers = node.objInstanceFull.identifiers;
|
|
388
|
-
const
|
|
389
|
-
.filter(
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
388
|
+
const sortedKeys = Object.keys(identifiers)
|
|
389
|
+
.filter(
|
|
390
|
+
(k) =>
|
|
391
|
+
k !== 'submittedByUserId' &&
|
|
392
|
+
k !== 'identifierConcat' &&
|
|
393
|
+
k !== 'identifiersConcat'
|
|
394
|
+
)
|
|
395
|
+
.sort();
|
|
396
|
+
const parts = [];
|
|
397
|
+
for (const key of sortedKeys) {
|
|
398
|
+
const value = identifiers[key];
|
|
399
|
+
if (value !== undefined && value !== null) {
|
|
400
|
+
parts.push(`${key}#${value}`);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
const targetIdentifiersConcat = parts.join('|');
|
|
398
404
|
|
|
399
405
|
if (!targetIdentifiersConcat) {
|
|
400
406
|
return;
|
|
401
407
|
}
|
|
402
408
|
|
|
409
|
+
const targetPlanTier =
|
|
410
|
+
node?.objInstanceFull?.planTier ||
|
|
411
|
+
node?.objInstanceFull?.targetIdentifiers?.planTier ||
|
|
412
|
+
'tier-free';
|
|
413
|
+
let planTierName = 'Free Plan';
|
|
414
|
+
if (targetPlanTier === 'tier-pro') {
|
|
415
|
+
planTierName = 'Professional Plan';
|
|
416
|
+
} else if (targetPlanTier === 'tier-enterprise') {
|
|
417
|
+
planTierName = 'Enterprise Plan';
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
await dynamodbSharedLib.putItem(
|
|
421
|
+
_izContext,
|
|
422
|
+
dynamodbSharedLib.tableName(_izContext, 'TargetRoles'),
|
|
423
|
+
{
|
|
424
|
+
identifiersConcat: targetIdentifiersConcat,
|
|
425
|
+
roleIdKey: targetPlanTier,
|
|
426
|
+
roleType: 'plan_tier',
|
|
427
|
+
roleName: planTierName,
|
|
428
|
+
submittedByUserId,
|
|
429
|
+
createdAt: new Date().toISOString()
|
|
430
|
+
}
|
|
431
|
+
);
|
|
432
|
+
|
|
403
433
|
const roleIdKey = `${targetIdentifiersConcat}_owner`;
|
|
404
434
|
_izContext.logger.debug(
|
|
405
435
|
'[CreateNodeCallback] Auto-provisioning owner TargetRole:',
|
|
@@ -417,8 +447,9 @@ export async function autoProvisionOwnerTargetRole(_izContext, { node, submitted
|
|
|
417
447
|
{
|
|
418
448
|
identifiersConcat: targetIdentifiersConcat,
|
|
419
449
|
roleIdKey,
|
|
450
|
+
roleType: 'tenant_role',
|
|
451
|
+
roleName: 'Owner',
|
|
420
452
|
submittedByUserId,
|
|
421
|
-
roleName: 'owner',
|
|
422
453
|
assignedAt: new Date().toISOString()
|
|
423
454
|
}
|
|
424
455
|
);
|
|
@@ -816,16 +847,49 @@ export async function autoProvisionOwnerTargetRoleForDynamoOnly(
|
|
|
816
847
|
_izContext.correlationIds?.get(coreConsts.SUBMITTED_BY_USER_ID);
|
|
817
848
|
|
|
818
849
|
if (submittedByUserId) {
|
|
819
|
-
const
|
|
820
|
-
.
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
850
|
+
const sortedKeys = Object.keys(identifiersForCreateData)
|
|
851
|
+
.filter(
|
|
852
|
+
(k) =>
|
|
853
|
+
k !== 'submittedByUserId' &&
|
|
854
|
+
k !== 'identifierConcat' &&
|
|
855
|
+
k !== 'identifiersConcat'
|
|
856
|
+
)
|
|
857
|
+
.sort();
|
|
858
|
+
const parts = [];
|
|
859
|
+
for (const key of sortedKeys) {
|
|
860
|
+
const value = identifiersForCreateData[key];
|
|
861
|
+
if (value !== undefined && value !== null) {
|
|
862
|
+
parts.push(`${key}#${value}`);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
const targetIdentifiersConcat = parts.join('|');
|
|
827
866
|
|
|
828
867
|
if (targetIdentifiersConcat) {
|
|
868
|
+
const targetPlanTier =
|
|
869
|
+
actionData?.planTier ||
|
|
870
|
+
requestParams?.planTier ||
|
|
871
|
+
requestParams?.passBackProperties?.planTier ||
|
|
872
|
+
'tier-free';
|
|
873
|
+
let planTierName = 'Free Plan';
|
|
874
|
+
if (targetPlanTier === 'tier-pro') {
|
|
875
|
+
planTierName = 'Professional Plan';
|
|
876
|
+
} else if (targetPlanTier === 'tier-enterprise') {
|
|
877
|
+
planTierName = 'Enterprise Plan';
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
await dynamodbSharedLib.putItem(
|
|
881
|
+
_izContext,
|
|
882
|
+
dynamodbSharedLib.tableName(_izContext, 'TargetRoles'),
|
|
883
|
+
{
|
|
884
|
+
identifiersConcat: targetIdentifiersConcat,
|
|
885
|
+
roleIdKey: targetPlanTier,
|
|
886
|
+
roleType: 'plan_tier',
|
|
887
|
+
roleName: planTierName,
|
|
888
|
+
submittedByUserId,
|
|
889
|
+
createdAt: new Date().toISOString()
|
|
890
|
+
}
|
|
891
|
+
);
|
|
892
|
+
|
|
829
893
|
const roleIdKey = `${targetIdentifiersConcat}_owner`;
|
|
830
894
|
_izContext.logger.debug(
|
|
831
895
|
'[<%- flowTag %>LogicalLib] Auto-provisioning owner TargetRole for DynamoDB-only:',
|
|
@@ -843,8 +907,9 @@ export async function autoProvisionOwnerTargetRoleForDynamoOnly(
|
|
|
843
907
|
{
|
|
844
908
|
identifiersConcat: targetIdentifiersConcat,
|
|
845
909
|
roleIdKey,
|
|
910
|
+
roleType: 'tenant_role',
|
|
911
|
+
roleName: 'Owner',
|
|
846
912
|
submittedByUserId,
|
|
847
|
-
roleName: 'owner',
|
|
848
913
|
assignedAt: new Date().toISOString()
|
|
849
914
|
}
|
|
850
915
|
);
|
|
@@ -200,7 +200,8 @@ export default async function <%- flowTag %>(
|
|
|
200
200
|
serviceTag: <%- rbacServiceTags.length === 1 ? rbacServiceTags[0] : `{ ${Object.entries(rbacServiceTagMap).map(([k, v]) => `'${k}': ${v}`).join(', ')} }[requestParams.objectType] || process.env.iz_serviceTag` %>
|
|
201
201
|
},
|
|
202
202
|
requestParams: requestParams,
|
|
203
|
-
nextFlowStepName: '<%- plan?.hasRbacCallback ? `${flowTag}RbacCallback` : `${flowTag}Complete` %>'
|
|
203
|
+
nextFlowStepName: '<%- plan?.hasRbacCallback ? `${flowTag}RbacCallback` : `${flowTag}Complete` %>',
|
|
204
|
+
sync: true
|
|
204
205
|
}
|
|
205
206
|
);
|
|
206
207
|
|
|
@@ -209,10 +210,18 @@ export default async function <%- flowTag %>(
|
|
|
209
210
|
resultPermissionCheck
|
|
210
211
|
);
|
|
211
212
|
|
|
213
|
+
if (resultPermissionCheck && resultPermissionCheck.permission !== true) {
|
|
214
|
+
errorsFound.push('Permission denied');
|
|
215
|
+
return await <%- flowTag %>LogicalLib(
|
|
216
|
+
_izContext,
|
|
217
|
+
requestParams,
|
|
218
|
+
callingFlowConfig,
|
|
219
|
+
errorsFound
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
212
223
|
//(<rbacPublish_<%- flowTag %>)
|
|
213
224
|
//(</rbacPublish_<%- flowTag %>)
|
|
214
|
-
|
|
215
|
-
return resultPermissionCheck;
|
|
216
225
|
}
|
|
217
226
|
<%_ } _%>
|
|
218
227
|
|
|
@@ -218,7 +218,8 @@ export default async function <%- flowTag %>(
|
|
|
218
218
|
serviceTag: <%- rbacServiceTags.length === 1 ? rbacServiceTags[0] : `{ ${Object.entries(rbacServiceTagMap).map(([k, v]) => `'${k}': ${v}`).join(', ')} }[requestParams.objectType] || process.env.iz_serviceTag` %>
|
|
219
219
|
},
|
|
220
220
|
requestParams: requestParams,
|
|
221
|
-
nextFlowStepName: '<%- plan?.hasRbacCallback ? `${flowTag}RbacCallback` : `${flowTag}Complete` %>'
|
|
221
|
+
nextFlowStepName: '<%- plan?.hasRbacCallback ? `${flowTag}RbacCallback` : `${flowTag}Complete` %>',
|
|
222
|
+
sync: true
|
|
222
223
|
}
|
|
223
224
|
);
|
|
224
225
|
|
|
@@ -227,10 +228,18 @@ export default async function <%- flowTag %>(
|
|
|
227
228
|
resultPermissionCheck
|
|
228
229
|
);
|
|
229
230
|
|
|
231
|
+
if (resultPermissionCheck && resultPermissionCheck.permission !== true) {
|
|
232
|
+
errorsFound.push('Permission denied');
|
|
233
|
+
return await <%- flowTag %>LogicalLib(
|
|
234
|
+
_izContext,
|
|
235
|
+
requestParams,
|
|
236
|
+
callingFlowConfig,
|
|
237
|
+
errorsFound
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
230
241
|
//(<rbacPublish_<%- flowTag %>)
|
|
231
242
|
//(</rbacPublish_<%- flowTag %>)
|
|
232
|
-
|
|
233
|
-
return resultPermissionCheck;
|
|
234
243
|
}
|
|
235
244
|
<%_ } _%>
|
|
236
245
|
|
|
@@ -319,8 +319,10 @@ function _sqsFilterPatterns(
|
|
|
319
319
|
- body:
|
|
320
320
|
MessageAttributes:
|
|
321
321
|
callingFlow:
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
- exists: false
|
|
323
|
+
- body:
|
|
324
|
+
MessageAttributes:
|
|
325
|
+
- exists: false
|
|
324
326
|
#<#/${hookFunctionName}FilterPatterns#>
|
|
325
327
|
`;
|
|
326
328
|
}
|
|
@@ -18,9 +18,6 @@ const RBAC_CORE_FLOW_DEFINITIONS = [
|
|
|
18
18
|
];
|
|
19
19
|
|
|
20
20
|
const LIMIT_FLOW_DEFINITIONS = [
|
|
21
|
-
{ flowTag: 'CreateRoleLimit', event: ['ownTopic'] },
|
|
22
|
-
{ flowTag: 'ListRoleLimits', event: ['lambdaSyncApi'] },
|
|
23
|
-
{ flowTag: 'DeleteRoleLimit', event: ['ownTopic'] },
|
|
24
21
|
{ flowTag: 'ReservedDynamicUsage', event: ['ownTopic'] },
|
|
25
22
|
{ flowTag: 'ConfirmUsage', event: ['ownTopic'] },
|
|
26
23
|
{ flowTag: 'CancelUsage', event: ['ownTopic'] }
|
|
@@ -52,11 +52,7 @@ export async function emitRbacApplicationArtifacts(objects) {
|
|
|
52
52
|
|
|
53
53
|
const limitHandlers = await Promise.all(
|
|
54
54
|
hasSelfRbac
|
|
55
|
-
?
|
|
56
|
-
...LIMIT_LIST_DEFINITIONS.map(createLimitListHandler),
|
|
57
|
-
...LIMIT_MUTATION_DEFINITIONS.map(createLimitMutationHandler),
|
|
58
|
-
...ACCOUNT_LIMIT_HANDLERS.map(createAccountLimitHandler)
|
|
59
|
-
]
|
|
55
|
+
? ACCOUNT_LIMIT_HANDLERS.map(createAccountLimitHandler)
|
|
60
56
|
: []
|
|
61
57
|
);
|
|
62
58
|
|
|
@@ -104,14 +100,6 @@ const LIST_DEFINITIONS = [
|
|
|
104
100
|
}
|
|
105
101
|
];
|
|
106
102
|
|
|
107
|
-
const LIMIT_LIST_DEFINITIONS = [
|
|
108
|
-
{
|
|
109
|
-
flowTag: 'ListRoleLimits',
|
|
110
|
-
tableName: 'RoleLimit',
|
|
111
|
-
requestProperty: 'roleLimitId'
|
|
112
|
-
}
|
|
113
|
-
];
|
|
114
|
-
|
|
115
103
|
const MUTATION_DEFINITIONS = [
|
|
116
104
|
{
|
|
117
105
|
flowTag: 'CreateRolePermissions',
|
|
@@ -127,21 +115,6 @@ const MUTATION_DEFINITIONS = [
|
|
|
127
115
|
}
|
|
128
116
|
];
|
|
129
117
|
|
|
130
|
-
const LIMIT_MUTATION_DEFINITIONS = [
|
|
131
|
-
{
|
|
132
|
-
flowTag: 'CreateRoleLimit',
|
|
133
|
-
tableName: 'RoleLimit',
|
|
134
|
-
method: 'putItem',
|
|
135
|
-
fields: ['roleLimitId', 'limitType', 'limitValue', 'actionType']
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
flowTag: 'DeleteRoleLimit',
|
|
139
|
-
tableName: 'RoleLimit',
|
|
140
|
-
method: 'deleteItem',
|
|
141
|
-
fields: ['roleLimitId', 'limitType']
|
|
142
|
-
}
|
|
143
|
-
];
|
|
144
|
-
|
|
145
118
|
const USER_ROLE_MUTATIONS = [
|
|
146
119
|
{ flowTag: 'CreateUserRole', operation: 'Put' },
|
|
147
120
|
{ flowTag: 'DeleteUserFromRole', operation: 'Delete' }
|
|
@@ -197,17 +170,6 @@ const STATIC_RBAC_APPLICATION_PATHS = [
|
|
|
197
170
|
];
|
|
198
171
|
|
|
199
172
|
const STATIC_LIMIT_APPLICATION_PATHS = [
|
|
200
|
-
...LIMIT_LIST_DEFINITIONS.flatMap(({ flowTag }) => [
|
|
201
|
-
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_Main.js`,
|
|
202
|
-
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_HdrSqs.js`,
|
|
203
|
-
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_HdrApi.js`
|
|
204
|
-
]),
|
|
205
|
-
...LIMIT_MUTATION_DEFINITIONS.flatMap(({ flowTag }) => [
|
|
206
|
-
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_Main.js`,
|
|
207
|
-
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_HdrSqs.js`,
|
|
208
|
-
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_WbsMain.js`,
|
|
209
|
-
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_HdrWbs.js`
|
|
210
|
-
]),
|
|
211
173
|
...ACCOUNT_LIMIT_HANDLERS.flatMap((flowTag) => [
|
|
212
174
|
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_Main.js`,
|
|
213
175
|
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_HdrSqs.js`,
|
|
@@ -274,83 +236,6 @@ async function createAccountLimitHandler(flowTag) {
|
|
|
274
236
|
};
|
|
275
237
|
}
|
|
276
238
|
|
|
277
|
-
async function createLimitListHandler(definition) {
|
|
278
|
-
const sourcePath = `app/src/generatedCode/FlowLimit/${definition.flowTag}/source`;
|
|
279
|
-
const handlerPath = `src/generatedCode/FlowLimit/${definition.flowTag}/source`;
|
|
280
|
-
return {
|
|
281
|
-
artifacts: [
|
|
282
|
-
{
|
|
283
|
-
path: `${sourcePath}/${definition.flowTag}_Main.js`,
|
|
284
|
-
content: await renderRbacTemplate('ListRbac_Main.ejs', {
|
|
285
|
-
...definition,
|
|
286
|
-
useContextUserId: definition.useContextUserId ?? false
|
|
287
|
-
})
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
path: `${sourcePath}/${definition.flowTag}_HdrSqs.js`,
|
|
291
|
-
content: await renderRbacTemplate('ListRbac_HdrSqs.ejs', definition)
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
path: `${sourcePath}/${definition.flowTag}_HdrApi.js`,
|
|
295
|
-
content: await renderRbacTemplate('ListRbac_HdrApi.ejs', definition)
|
|
296
|
-
}
|
|
297
|
-
],
|
|
298
|
-
functions: [
|
|
299
|
-
{
|
|
300
|
-
type: 'sqs',
|
|
301
|
-
functionName: `${definition.flowTag}HdrSqs`,
|
|
302
|
-
handlerPath: `${handlerPath}/${definition.flowTag}_HdrSqs.main`,
|
|
303
|
-
roleName: 'FlowRbacRole',
|
|
304
|
-
queueName: `${definition.flowTag}HdrSqs`,
|
|
305
|
-
flowTag: definition.flowTag,
|
|
306
|
-
flowStepName: ''
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
type: 'api',
|
|
310
|
-
functionName: `${definition.flowTag}HdrApi`,
|
|
311
|
-
handlerPath: `${handlerPath}/${definition.flowTag}_HdrApi.main`,
|
|
312
|
-
roleName: 'FlowRbacRole',
|
|
313
|
-
flowTag: definition.flowTag,
|
|
314
|
-
flowStepName: ''
|
|
315
|
-
}
|
|
316
|
-
]
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
async function createLimitMutationHandler(definition) {
|
|
321
|
-
const sourcePath = `app/src/generatedCode/FlowLimit/${definition.flowTag}/source`;
|
|
322
|
-
const handlerPath = `src/generatedCode/FlowLimit/${definition.flowTag}/source`;
|
|
323
|
-
const webSocket = await createWebSocketEntry(
|
|
324
|
-
definition.flowTag,
|
|
325
|
-
sourcePath,
|
|
326
|
-
handlerPath
|
|
327
|
-
);
|
|
328
|
-
return {
|
|
329
|
-
artifacts: [
|
|
330
|
-
{
|
|
331
|
-
path: `${sourcePath}/${definition.flowTag}_Main.js`,
|
|
332
|
-
content: await renderRbacTemplate('RbacMutation_Main.ejs', definition)
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
path: `${sourcePath}/${definition.flowTag}_HdrSqs.js`,
|
|
336
|
-
content: await renderRbacTemplate('ListRbac_HdrSqs.ejs', definition)
|
|
337
|
-
},
|
|
338
|
-
...webSocket.artifacts
|
|
339
|
-
],
|
|
340
|
-
functions: [
|
|
341
|
-
{
|
|
342
|
-
type: 'sqs',
|
|
343
|
-
functionName: `${definition.flowTag}HdrSqs`,
|
|
344
|
-
handlerPath: `${handlerPath}/${definition.flowTag}_HdrSqs.main`,
|
|
345
|
-
roleName: 'FlowRbacRole',
|
|
346
|
-
queueName: `${definition.flowTag}HdrSqs`,
|
|
347
|
-
flowTag: definition.flowTag,
|
|
348
|
-
flowStepName: ''
|
|
349
|
-
},
|
|
350
|
-
...webSocket.functions
|
|
351
|
-
]
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
239
|
|
|
355
240
|
async function createCustomRbacOwnTopicHandler(flowTag, mainTemplateName) {
|
|
356
241
|
const sourcePath = `app/src/generatedCode/FlowRbac/${flowTag}/source`;
|
|
@@ -39,21 +39,25 @@ export default async function CancelUsage(_izContext, requestParams) {
|
|
|
39
39
|
requestParams?.limitTag;
|
|
40
40
|
|
|
41
41
|
const targetIdentifiers = requestParams?.targetIdentifiers;
|
|
42
|
-
let identifiersConcat =
|
|
42
|
+
let identifiersConcat =
|
|
43
|
+
requestParams?.identifiersConcat || requestParams?.identifierConcat;
|
|
43
44
|
if (!identifiersConcat && targetIdentifiers && typeof targetIdentifiers === 'object') {
|
|
44
|
-
if (targetIdentifiers.identifierConcat) {
|
|
45
|
-
identifiersConcat =
|
|
45
|
+
if (targetIdentifiers.identifiersConcat || targetIdentifiers.identifierConcat) {
|
|
46
|
+
identifiersConcat =
|
|
47
|
+
targetIdentifiers.identifiersConcat || targetIdentifiers.identifierConcat;
|
|
46
48
|
} else {
|
|
47
|
-
const sortedKeys = Object.keys(targetIdentifiers)
|
|
49
|
+
const sortedKeys = Object.keys(targetIdentifiers)
|
|
50
|
+
.filter(
|
|
51
|
+
(k) =>
|
|
52
|
+
k !== 'submittedByUserId' &&
|
|
53
|
+
k !== 'identifierConcat' &&
|
|
54
|
+
k !== 'identifiersConcat'
|
|
55
|
+
)
|
|
56
|
+
.sort();
|
|
48
57
|
const parts = [];
|
|
49
58
|
for (const key of sortedKeys) {
|
|
50
59
|
const value = targetIdentifiers[key];
|
|
51
|
-
if (
|
|
52
|
-
key !== 'submittedByUserId' &&
|
|
53
|
-
key !== 'identifierConcat' &&
|
|
54
|
-
value !== undefined &&
|
|
55
|
-
value !== null
|
|
56
|
-
) {
|
|
60
|
+
if (value !== undefined && value !== null) {
|
|
57
61
|
parts.push(`${key}#${value}`);
|
|
58
62
|
}
|
|
59
63
|
}
|
|
@@ -39,21 +39,25 @@ export default async function ConfirmUsage(_izContext, requestParams) {
|
|
|
39
39
|
requestParams?.limitTag;
|
|
40
40
|
|
|
41
41
|
const targetIdentifiers = requestParams?.targetIdentifiers;
|
|
42
|
-
let identifiersConcat =
|
|
42
|
+
let identifiersConcat =
|
|
43
|
+
requestParams?.identifiersConcat || requestParams?.identifierConcat;
|
|
43
44
|
if (!identifiersConcat && targetIdentifiers && typeof targetIdentifiers === 'object') {
|
|
44
|
-
if (targetIdentifiers.identifierConcat) {
|
|
45
|
-
identifiersConcat =
|
|
45
|
+
if (targetIdentifiers.identifiersConcat || targetIdentifiers.identifierConcat) {
|
|
46
|
+
identifiersConcat =
|
|
47
|
+
targetIdentifiers.identifiersConcat || targetIdentifiers.identifierConcat;
|
|
46
48
|
} else {
|
|
47
|
-
const sortedKeys = Object.keys(targetIdentifiers)
|
|
49
|
+
const sortedKeys = Object.keys(targetIdentifiers)
|
|
50
|
+
.filter(
|
|
51
|
+
(k) =>
|
|
52
|
+
k !== 'submittedByUserId' &&
|
|
53
|
+
k !== 'identifierConcat' &&
|
|
54
|
+
k !== 'identifiersConcat'
|
|
55
|
+
)
|
|
56
|
+
.sort();
|
|
48
57
|
const parts = [];
|
|
49
58
|
for (const key of sortedKeys) {
|
|
50
59
|
const value = targetIdentifiers[key];
|
|
51
|
-
if (
|
|
52
|
-
key !== 'submittedByUserId' &&
|
|
53
|
-
key !== 'identifierConcat' &&
|
|
54
|
-
value !== undefined &&
|
|
55
|
-
value !== null
|
|
56
|
-
) {
|
|
60
|
+
if (value !== undefined && value !== null) {
|
|
57
61
|
parts.push(`${key}#${value}`);
|
|
58
62
|
}
|
|
59
63
|
}
|