@aws-amplify/graphql-auth-transformer 0.4.8-beta.0 → 0.5.0-apiext4.0
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 +6 -3
- package/lib/accesscontrol/acm.js +1 -1
- package/lib/accesscontrol/acm.js.map +1 -1
- package/lib/graphql-auth-transformer.js +58 -58
- package/lib/graphql-auth-transformer.js.map +1 -1
- package/lib/resolvers/field.js +33 -33
- package/lib/resolvers/field.js.map +1 -1
- package/lib/resolvers/helpers.js +36 -36
- package/lib/resolvers/helpers.js.map +1 -1
- package/lib/resolvers/mutation.create.js +49 -49
- package/lib/resolvers/mutation.create.js.map +1 -1
- package/lib/resolvers/mutation.delete.js +36 -36
- package/lib/resolvers/mutation.delete.js.map +1 -1
- package/lib/resolvers/mutation.update.js +69 -69
- package/lib/resolvers/mutation.update.js.map +1 -1
- package/lib/resolvers/query.js +77 -77
- package/lib/resolvers/query.js.map +1 -1
- package/lib/resolvers/search.js +48 -48
- package/lib/resolvers/search.js.map +1 -1
- package/lib/resolvers/subscriptions.js +13 -13
- package/lib/resolvers/subscriptions.js.map +1 -1
- package/lib/utils/schema.js +23 -23
- package/lib/utils/schema.js.map +1 -1
- package/lib/utils/validations.js +4 -4
- package/lib/utils/validations.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,15 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# [0.5.0-apiext4.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-auth-transformer@0.4.6...@aws-amplify/graphql-auth-transformer@0.5.0-apiext4.0) (2021-11-21)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* extensibility for Amplify API ([#8954](https://github.com/aws-amplify/amplify-cli/issues/8954)) ([d8c732c](https://github.com/aws-amplify/amplify-cli/commit/d8c732c305d51066e19739c0ed315a05f8526f33))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
|
12
15
|
|
|
13
16
|
|
|
14
|
-
## [0.4.
|
|
17
|
+
## [0.4.6](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-auth-transformer@0.4.5...@aws-amplify/graphql-auth-transformer@0.4.6) (2021-11-21)
|
|
15
18
|
|
|
16
19
|
**Note:** Version bump only for package @aws-amplify/graphql-auth-transformer
|
|
17
20
|
|
package/lib/accesscontrol/acm.js
CHANGED
|
@@ -22,7 +22,7 @@ class AccessControlMatrix {
|
|
|
22
22
|
allowedVector = this.getResourceOperationMatrix({ operations, resource });
|
|
23
23
|
this.roles.push(input.role);
|
|
24
24
|
this.matrix.push(allowedVector);
|
|
25
|
-
assert_1.default(this.roles.length === this.matrix.length, 'Roles are not aligned with Roles added in Matrix');
|
|
25
|
+
(0, assert_1.default)(this.roles.length === this.matrix.length, 'Roles are not aligned with Roles added in Matrix');
|
|
26
26
|
}
|
|
27
27
|
else if (this.roles.includes(role) && (resource || allowRoleOverwrite)) {
|
|
28
28
|
allowedVector = this.getResourceOperationMatrix({ operations, resource, role });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acm.js","sourceRoot":"","sources":["../../src/accesscontrol/acm.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,oFAAwG;AAkCxG,MAAa,mBAAmB;IAO9B,YAAY,MAAiB;QAC3B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,EAA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Base {
|
|
|
40
40
|
this.before = (context) => {
|
|
41
41
|
var _a;
|
|
42
42
|
this.config.authConfig = (_a = this.config.authConfig) !== null && _a !== void 0 ? _a : context.authConfig;
|
|
43
|
-
this.configuredAuthProviders = utils_1.getConfiguredAuthProviders(this.config);
|
|
43
|
+
this.configuredAuthProviders = (0, utils_1.getConfiguredAuthProviders)(this.config);
|
|
44
44
|
};
|
|
45
45
|
this.object = (def, directive, context) => {
|
|
46
46
|
var _a;
|
|
@@ -55,18 +55,18 @@ class AuthTransformer extends graphql_transformer_core_1.TransformerAuthBase {
|
|
|
55
55
|
}
|
|
56
56
|
const authDir = new graphql_transformer_core_1.DirectiveWrapper(directive);
|
|
57
57
|
const rules = authDir.getArguments({ rules: [] }).rules;
|
|
58
|
-
utils_1.ensureAuthRuleDefaults(rules);
|
|
59
|
-
utils_1.validateRules(rules, this.configuredAuthProviders, def.name.value);
|
|
58
|
+
(0, utils_1.ensureAuthRuleDefaults)(rules);
|
|
59
|
+
(0, utils_1.validateRules)(rules, this.configuredAuthProviders, def.name.value);
|
|
60
60
|
const acm = new accesscontrol_1.AccessControlMatrix({
|
|
61
61
|
name: def.name.value,
|
|
62
62
|
operations: utils_1.MODEL_OPERATIONS,
|
|
63
|
-
resources: utils_1.collectFieldNames(def),
|
|
63
|
+
resources: (0, utils_1.collectFieldNames)(def),
|
|
64
64
|
});
|
|
65
65
|
this.setAuthPolicyFlag(rules);
|
|
66
66
|
this.setUnauthPolicyFlag(rules);
|
|
67
67
|
this.addTypeToResourceReferences(def.name.value, rules);
|
|
68
68
|
this.convertRulesToRoles(acm, rules, isJoinType);
|
|
69
|
-
this.modelDirectiveConfig.set(typeName, utils_1.getModelConfig(modelDirective, typeName, context.isProjectUsingDataStore()));
|
|
69
|
+
this.modelDirectiveConfig.set(typeName, (0, utils_1.getModelConfig)(modelDirective, typeName, context.isProjectUsingDataStore()));
|
|
70
70
|
this.authModelConfig.set(typeName, acm);
|
|
71
71
|
};
|
|
72
72
|
this.field = (parent, field, directive, context) => {
|
|
@@ -87,19 +87,19 @@ Static group authorization should perform as expected.`);
|
|
|
87
87
|
const fieldName = field.name.value;
|
|
88
88
|
const authDir = new graphql_transformer_core_1.DirectiveWrapper(directive);
|
|
89
89
|
const rules = authDir.getArguments({ rules: [] }).rules;
|
|
90
|
-
utils_1.ensureAuthRuleDefaults(rules);
|
|
91
|
-
utils_1.validateFieldRules(rules, isParentTypeBuiltinType, modelDirective !== undefined, this.configuredAuthProviders, field.name.value);
|
|
90
|
+
(0, utils_1.ensureAuthRuleDefaults)(rules);
|
|
91
|
+
(0, utils_1.validateFieldRules)(rules, isParentTypeBuiltinType, modelDirective !== undefined, this.configuredAuthProviders, field.name.value);
|
|
92
92
|
this.setAuthPolicyFlag(rules);
|
|
93
93
|
this.setUnauthPolicyFlag(rules);
|
|
94
94
|
this.addFieldToResourceReferences(parent.name.value, field.name.value, rules);
|
|
95
95
|
if (modelDirective) {
|
|
96
96
|
let acm;
|
|
97
97
|
if (!this.modelDirectiveConfig.has(typeName)) {
|
|
98
|
-
this.modelDirectiveConfig.set(typeName, utils_1.getModelConfig(modelDirective, typeName, context.isProjectUsingDataStore()));
|
|
98
|
+
this.modelDirectiveConfig.set(typeName, (0, utils_1.getModelConfig)(modelDirective, typeName, context.isProjectUsingDataStore()));
|
|
99
99
|
acm = new accesscontrol_1.AccessControlMatrix({
|
|
100
100
|
name: parent.name.value,
|
|
101
101
|
operations: utils_1.MODEL_OPERATIONS,
|
|
102
|
-
resources: utils_1.collectFieldNames(parent),
|
|
102
|
+
resources: (0, utils_1.collectFieldNames)(parent),
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
else {
|
|
@@ -140,7 +140,7 @@ Static group authorization should perform as expected.`);
|
|
|
140
140
|
providers.forEach(p => searchableAggregateServiceDirectives.add(p));
|
|
141
141
|
}
|
|
142
142
|
if (directives.length > 0) {
|
|
143
|
-
utils_1.extendTypeWithDirectives(context, modelName, directives);
|
|
143
|
+
(0, utils_1.extendTypeWithDirectives)(context, modelName, directives);
|
|
144
144
|
}
|
|
145
145
|
this.protectSchemaOperations(context, def, acm);
|
|
146
146
|
this.propagateAuthDirectivesToNestedTypes(context, context.output.getObject(modelName), providers);
|
|
@@ -150,13 +150,13 @@ Static group authorization should perform as expected.`);
|
|
|
150
150
|
const providers = this.getAuthProviders(acm.getRoles());
|
|
151
151
|
const directives = this.getServiceDirectives(providers, false);
|
|
152
152
|
if (directives.length > 0) {
|
|
153
|
-
utils_1.addDirectivesToField(context, typeName, fieldName, directives);
|
|
153
|
+
(0, utils_1.addDirectivesToField)(context, typeName, fieldName, directives);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
if (searchableAggregateServiceDirectives.size > 0) {
|
|
157
157
|
const serviceDirectives = this.getServiceDirectives(Array.from(searchableAggregateServiceDirectives), false);
|
|
158
158
|
for (let aggType of utils_1.SEARCHABLE_AGGREGATE_TYPES) {
|
|
159
|
-
utils_1.extendTypeWithDirectives(context, aggType, serviceDirectives);
|
|
159
|
+
(0, utils_1.extendTypeWithDirectives)(context, aggType, serviceDirectives);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
};
|
|
@@ -168,7 +168,7 @@ Static group authorization should perform as expected.`);
|
|
|
168
168
|
const def = context.output.getObject(modelName);
|
|
169
169
|
const modelNameConfig = this.modelDirectiveConfig.get(modelName);
|
|
170
170
|
const searchableDirective = def.directives.find(dir => dir.name.value === 'searchable');
|
|
171
|
-
const queryFields = utils_1.getQueryFieldNames(this.modelDirectiveConfig.get(modelName));
|
|
171
|
+
const queryFields = (0, utils_1.getQueryFieldNames)(this.modelDirectiveConfig.get(modelName));
|
|
172
172
|
for (let query of queryFields.values()) {
|
|
173
173
|
switch (query.type) {
|
|
174
174
|
case graphql_transformer_interfaces_1.QueryFieldType.GET:
|
|
@@ -191,20 +191,20 @@ Static group authorization should perform as expected.`);
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
if (searchableDirective) {
|
|
194
|
-
const config = utils_1.getSearchableConfig(searchableDirective, modelName);
|
|
194
|
+
const config = (0, utils_1.getSearchableConfig)(searchableDirective, modelName);
|
|
195
195
|
this.protectSearchResolver(context, def, context.output.getQueryTypeName(), config.queries.search, acm);
|
|
196
196
|
}
|
|
197
197
|
const readRoles = acm.getRolesPerOperation('read');
|
|
198
198
|
const modelFields = (_b = (_a = def.fields) === null || _a === void 0 ? void 0 : _a.filter(f => acm.hasResource(f.name.value))) !== null && _b !== void 0 ? _b : [];
|
|
199
199
|
const errorFields = new Array();
|
|
200
200
|
for (let field of modelFields) {
|
|
201
|
-
const fieldReadRoles = utils_1.getReadRolesForField(acm, readRoles, field.name.value);
|
|
201
|
+
const fieldReadRoles = (0, utils_1.getReadRolesForField)(acm, readRoles, field.name.value);
|
|
202
202
|
const allowedRoles = fieldReadRoles.filter(r => acm.isAllowed(r, field.name.value, 'read'));
|
|
203
203
|
const needsFieldResolver = allowedRoles.length < fieldReadRoles.length;
|
|
204
204
|
if (needsFieldResolver && field.type.kind === graphql_1.Kind.NON_NULL_TYPE) {
|
|
205
205
|
errorFields.push(field.name.value);
|
|
206
206
|
}
|
|
207
|
-
else if (utils_1.hasRelationalDirective(field)) {
|
|
207
|
+
else if ((0, utils_1.hasRelationalDirective)(field)) {
|
|
208
208
|
this.protectRelationalResolver(context, def, modelName, field, needsFieldResolver ? allowedRoles : null);
|
|
209
209
|
}
|
|
210
210
|
else if (needsFieldResolver) {
|
|
@@ -215,7 +215,7 @@ Static group authorization should perform as expected.`);
|
|
|
215
215
|
throw new graphql_transformer_core_1.InvalidDirectiveError(`Because "${def.name.value}" has a field-level authorization rule and subscriptions are enabled,` +
|
|
216
216
|
` you need to either apply field-level authorization rules to all required fields where all rules have read access ${JSON.stringify(errorFields)}, make those fields nullable, or disable subscriptions for "${def.name.value}" (setting level to off or public).`);
|
|
217
217
|
}
|
|
218
|
-
const mutationFields = utils_1.getMutationFieldNames(this.modelDirectiveConfig.get(modelName));
|
|
218
|
+
const mutationFields = (0, utils_1.getMutationFieldNames)(this.modelDirectiveConfig.get(modelName));
|
|
219
219
|
for (let mutation of mutationFields.values()) {
|
|
220
220
|
switch (mutation.type) {
|
|
221
221
|
case graphql_transformer_interfaces_1.MutationFieldType.CREATE:
|
|
@@ -231,11 +231,11 @@ Static group authorization should perform as expected.`);
|
|
|
231
231
|
throw new graphql_transformer_core_1.TransformerContractError('Unkown Mutation field type');
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
-
const subscriptionFieldNames = utils_1.getSubscriptionFieldNames(this.modelDirectiveConfig.get(modelName));
|
|
234
|
+
const subscriptionFieldNames = (0, utils_1.getSubscriptionFieldNames)(this.modelDirectiveConfig.get(modelName));
|
|
235
235
|
const subscriptionRoles = acm
|
|
236
236
|
.getRolesPerOperation('read')
|
|
237
237
|
.map(role => this.roleMap.get(role))
|
|
238
|
-
.filter(roleDef => { var _a; return (roleDef.strategy === 'owner' && !utils_1.fieldIsList((_a = def.fields) !== null && _a !== void 0 ? _a : [], roleDef.entity)) || roleDef.static; });
|
|
238
|
+
.filter(roleDef => { var _a; return (roleDef.strategy === 'owner' && !(0, utils_1.fieldIsList)((_a = def.fields) !== null && _a !== void 0 ? _a : [], roleDef.entity)) || roleDef.static; });
|
|
239
239
|
for (let subscription of subscriptionFieldNames) {
|
|
240
240
|
this.protectSubscriptionResolver(context, subscription.typeName, subscription.fieldName, subscriptionRoles);
|
|
241
241
|
}
|
|
@@ -257,7 +257,7 @@ Static group authorization should perform as expected.`);
|
|
|
257
257
|
const providers = this.getAuthProviders(acm.getRolesPerOperation(operation, operation === 'delete'));
|
|
258
258
|
const operationDirectives = this.getServiceDirectives(providers, includeDefault);
|
|
259
259
|
if (operationDirectives.length > 0) {
|
|
260
|
-
utils_1.addDirectivesToOperation(ctx, typeName, operationName, operationDirectives);
|
|
260
|
+
(0, utils_1.addDirectivesToOperation)(ctx, typeName, operationName, operationDirectives);
|
|
261
261
|
}
|
|
262
262
|
this.addOperationToResourceReferences(typeName, operationName, acm.getRoles());
|
|
263
263
|
}
|
|
@@ -274,7 +274,7 @@ Static group authorization should perform as expected.`);
|
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
if (searchableDirective) {
|
|
277
|
-
const config = utils_1.getSearchableConfig(searchableDirective, def.name.value);
|
|
277
|
+
const config = (0, utils_1.getSearchableConfig)(searchableDirective, def.name.value);
|
|
278
278
|
addServiceDirective(ctx.output.getQueryTypeName(), 'read', config.queries.search);
|
|
279
279
|
}
|
|
280
280
|
const subscriptions = modelConfig === null || modelConfig === void 0 ? void 0 : modelConfig.subscriptions;
|
|
@@ -282,23 +282,23 @@ Static group authorization should perform as expected.`);
|
|
|
282
282
|
const subscriptionArguments = acm
|
|
283
283
|
.getRolesPerOperation('read')
|
|
284
284
|
.map(role => this.roleMap.get(role))
|
|
285
|
-
.filter(roleDef => { var _a; return roleDef.strategy === 'owner' && !utils_1.fieldIsList((_a = def.fields) !== null && _a !== void 0 ? _a : [], roleDef.entity); });
|
|
285
|
+
.filter(roleDef => { var _a; return roleDef.strategy === 'owner' && !(0, utils_1.fieldIsList)((_a = def.fields) !== null && _a !== void 0 ? _a : [], roleDef.entity); });
|
|
286
286
|
if (subscriptions.onCreate && ((_g = modelConfig === null || modelConfig === void 0 ? void 0 : modelConfig.mutations) === null || _g === void 0 ? void 0 : _g.create)) {
|
|
287
287
|
for (let onCreateSub of subscriptions.onCreate) {
|
|
288
288
|
addServiceDirective(ctx.output.getSubscriptionTypeName(), 'read', onCreateSub);
|
|
289
|
-
utils_1.addSubscriptionArguments(ctx, onCreateSub, subscriptionArguments);
|
|
289
|
+
(0, utils_1.addSubscriptionArguments)(ctx, onCreateSub, subscriptionArguments);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
if (subscriptions.onUpdate && ((_h = modelConfig === null || modelConfig === void 0 ? void 0 : modelConfig.mutations) === null || _h === void 0 ? void 0 : _h.update)) {
|
|
293
293
|
for (let onUpdateSub of subscriptions.onUpdate) {
|
|
294
294
|
addServiceDirective(ctx.output.getSubscriptionTypeName(), 'read', onUpdateSub);
|
|
295
|
-
utils_1.addSubscriptionArguments(ctx, onUpdateSub, subscriptionArguments);
|
|
295
|
+
(0, utils_1.addSubscriptionArguments)(ctx, onUpdateSub, subscriptionArguments);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
if (subscriptions.onDelete && ((_j = modelConfig === null || modelConfig === void 0 ? void 0 : modelConfig.mutations) === null || _j === void 0 ? void 0 : _j.delete)) {
|
|
299
299
|
for (let onDeleteSub of subscriptions.onDelete) {
|
|
300
300
|
addServiceDirective(ctx.output.getSubscriptionTypeName(), 'read', onDeleteSub);
|
|
301
|
-
utils_1.addSubscriptionArguments(ctx, onDeleteSub, subscriptionArguments);
|
|
301
|
+
(0, utils_1.addSubscriptionArguments)(ctx, onDeleteSub, subscriptionArguments);
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
}
|
|
@@ -307,8 +307,8 @@ Static group authorization should perform as expected.`);
|
|
|
307
307
|
var _a;
|
|
308
308
|
const resolver = ctx.resolvers.getResolver(typeName, fieldName);
|
|
309
309
|
const roleDefinitions = acm.getRolesPerOperation('read').map(r => this.roleMap.get(r));
|
|
310
|
-
const primaryFields = utils_1.getTable(ctx, def).keySchema.map(att => att.attributeName);
|
|
311
|
-
const authExpression = resolvers_1.generateAuthExpressionForQueries(this.configuredAuthProviders, roleDefinitions, (_a = def.fields) !== null && _a !== void 0 ? _a : [], primaryFields);
|
|
310
|
+
const primaryFields = (0, utils_1.getTable)(ctx, def).keySchema.map(att => att.attributeName);
|
|
311
|
+
const authExpression = (0, resolvers_1.generateAuthExpressionForQueries)(this.configuredAuthProviders, roleDefinitions, (_a = def.fields) !== null && _a !== void 0 ? _a : [], primaryFields);
|
|
312
312
|
resolver.addToSlot('auth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(authExpression, `${typeName}.${fieldName}.{slotName}.{slotIndex}.req.vtl`));
|
|
313
313
|
};
|
|
314
314
|
this.protectListResolver = (ctx, def, typeName, fieldName, acm, indexName) => {
|
|
@@ -316,7 +316,7 @@ Static group authorization should perform as expected.`);
|
|
|
316
316
|
const resolver = ctx.resolvers.getResolver(typeName, fieldName);
|
|
317
317
|
const roleDefinitions = acm.getRolesPerOperation('read').map(r => this.roleMap.get(r));
|
|
318
318
|
let primaryFields;
|
|
319
|
-
const table = utils_1.getTable(ctx, def);
|
|
319
|
+
const table = (0, utils_1.getTable)(ctx, def);
|
|
320
320
|
try {
|
|
321
321
|
if (indexName) {
|
|
322
322
|
primaryFields = table.globalSecondaryIndexes
|
|
@@ -330,28 +330,28 @@ Static group authorization should perform as expected.`);
|
|
|
330
330
|
catch (err) {
|
|
331
331
|
throw new graphql_transformer_core_1.InvalidDirectiveError(`Could not fetch keySchema for ${def.name.value}.`);
|
|
332
332
|
}
|
|
333
|
-
const authExpression = resolvers_1.generateAuthExpressionForQueries(this.configuredAuthProviders, roleDefinitions, (_a = def.fields) !== null && _a !== void 0 ? _a : [], primaryFields, !!indexName);
|
|
333
|
+
const authExpression = (0, resolvers_1.generateAuthExpressionForQueries)(this.configuredAuthProviders, roleDefinitions, (_a = def.fields) !== null && _a !== void 0 ? _a : [], primaryFields, !!indexName);
|
|
334
334
|
resolver.addToSlot('auth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(authExpression, `${typeName}.${fieldName}.{slotName}.{slotIndex}.req.vtl`));
|
|
335
335
|
};
|
|
336
336
|
this.protectRelationalResolver = (ctx, def, typeName, field, fieldRoles) => {
|
|
337
337
|
var _a, _b;
|
|
338
338
|
let fieldAuthExpression;
|
|
339
339
|
let relatedAuthExpression;
|
|
340
|
-
const relatedModelObject = this.getRelatedModelObject(ctx, graphql_transformer_common_1.getBaseType(field.type));
|
|
340
|
+
const relatedModelObject = this.getRelatedModelObject(ctx, (0, graphql_transformer_common_1.getBaseType)(field.type));
|
|
341
341
|
if (this.authModelConfig.has(relatedModelObject.name.value)) {
|
|
342
342
|
const acm = this.authModelConfig.get(relatedModelObject.name.value);
|
|
343
343
|
const roleDefinitions = acm.getRolesPerOperation('read').map(r => this.roleMap.get(r));
|
|
344
|
-
const relationalPrimaryMap = utils_1.getRelationalPrimaryMap(ctx, def, field, relatedModelObject);
|
|
345
|
-
relatedAuthExpression = resolvers_1.generateAuthExpressionForRelationQuery(this.configuredAuthProviders, roleDefinitions, (_a = relatedModelObject.fields) !== null && _a !== void 0 ? _a : [], relationalPrimaryMap);
|
|
344
|
+
const relationalPrimaryMap = (0, utils_1.getRelationalPrimaryMap)(ctx, def, field, relatedModelObject);
|
|
345
|
+
relatedAuthExpression = (0, resolvers_1.generateAuthExpressionForRelationQuery)(this.configuredAuthProviders, roleDefinitions, (_a = relatedModelObject.fields) !== null && _a !== void 0 ? _a : [], relationalPrimaryMap);
|
|
346
346
|
}
|
|
347
347
|
else {
|
|
348
|
-
relatedAuthExpression = field_1.generateSandboxExpressionForField(ctx.sandboxModeEnabled);
|
|
348
|
+
relatedAuthExpression = (0, field_1.generateSandboxExpressionForField)(ctx.sandboxModeEnabled);
|
|
349
349
|
}
|
|
350
350
|
if (fieldRoles) {
|
|
351
351
|
const roleDefinitions = fieldRoles.map(r => this.roleMap.get(r));
|
|
352
352
|
const hasSubsEnabled = this.modelDirectiveConfig.get(typeName).subscriptions.level === 'on';
|
|
353
|
-
relatedAuthExpression = resolvers_1.setDeniedFieldFlag('Mutation', hasSubsEnabled) + '\n' + relatedAuthExpression;
|
|
354
|
-
fieldAuthExpression = resolvers_1.generateAuthExpressionForField(this.configuredAuthProviders, roleDefinitions, (_b = def.fields) !== null && _b !== void 0 ? _b : []);
|
|
353
|
+
relatedAuthExpression = (0, resolvers_1.setDeniedFieldFlag)('Mutation', hasSubsEnabled) + '\n' + relatedAuthExpression;
|
|
354
|
+
fieldAuthExpression = (0, resolvers_1.generateAuthExpressionForField)(this.configuredAuthProviders, roleDefinitions, (_b = def.fields) !== null && _b !== void 0 ? _b : []);
|
|
355
355
|
}
|
|
356
356
|
const resolver = ctx.resolvers.getResolver(typeName, field.name.value);
|
|
357
357
|
if (fieldAuthExpression) {
|
|
@@ -366,8 +366,8 @@ Static group authorization should perform as expected.`);
|
|
|
366
366
|
if (ctx.isProjectUsingDataStore()) {
|
|
367
367
|
const resolver = ctx.resolvers.getResolver(typeName, fieldName);
|
|
368
368
|
const roleDefinitions = acm.getRolesPerOperation('read').map(r => this.roleMap.get(r));
|
|
369
|
-
const primaryFields = utils_1.getTable(ctx, def).keySchema.map(att => att.attributeName);
|
|
370
|
-
const authExpression = resolvers_1.generateAuthExpressionForQueries(this.configuredAuthProviders, roleDefinitions, (_a = def.fields) !== null && _a !== void 0 ? _a : [], primaryFields);
|
|
369
|
+
const primaryFields = (0, utils_1.getTable)(ctx, def).keySchema.map(att => att.attributeName);
|
|
370
|
+
const authExpression = (0, resolvers_1.generateAuthExpressionForQueries)(this.configuredAuthProviders, roleDefinitions, (_a = def.fields) !== null && _a !== void 0 ? _a : [], primaryFields);
|
|
371
371
|
resolver.addToSlot('auth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(authExpression, `${typeName}.${fieldName}.{slotName}.{slotIndex}.req.vtl`));
|
|
372
372
|
}
|
|
373
373
|
};
|
|
@@ -378,7 +378,7 @@ Static group authorization should perform as expected.`);
|
|
|
378
378
|
const name = acm.getName();
|
|
379
379
|
const allowedAggFields = modelFields.map(f => f.name.value).filter(f => !acmFields.includes(f));
|
|
380
380
|
let leastAllowedFields = acmFields;
|
|
381
|
-
const resolver = ctx.resolvers.getResolver('Search', graphql_transformer_common_2.toUpper(name));
|
|
381
|
+
const resolver = ctx.resolvers.getResolver('Search', (0, graphql_transformer_common_2.toUpper)(name));
|
|
382
382
|
const readRoleDefinitions = acm.getRolesPerOperation('read').map(role => {
|
|
383
383
|
const allowedFields = acmFields.filter(resource => acm.isAllowed(role, resource, 'read'));
|
|
384
384
|
const roleDefinition = this.roleMap.get(role);
|
|
@@ -392,27 +392,27 @@ Static group authorization should perform as expected.`);
|
|
|
392
392
|
return roleDefinition;
|
|
393
393
|
});
|
|
394
394
|
allowedAggFields.push(...leastAllowedFields);
|
|
395
|
-
const authExpression = resolvers_1.generateAuthExpressionForSearchQueries(this.configuredAuthProviders, readRoleDefinitions, modelFields, allowedAggFields);
|
|
395
|
+
const authExpression = (0, resolvers_1.generateAuthExpressionForSearchQueries)(this.configuredAuthProviders, readRoleDefinitions, modelFields, allowedAggFields);
|
|
396
396
|
resolver.addToSlot('auth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(authExpression, `${typeName}.${fieldName}.{slotName}.{slotIndex}.req.vtl`));
|
|
397
397
|
};
|
|
398
398
|
this.protectFieldResolver = (ctx, def, typeName, fieldName, roles) => {
|
|
399
399
|
var _a;
|
|
400
400
|
const roleDefinitions = roles.map(r => this.roleMap.get(r));
|
|
401
401
|
const hasModelDirective = def.directives.some(dir => dir.name.value === 'model');
|
|
402
|
-
const stack = utils_1.getStackForField(ctx, def, fieldName, hasModelDirective);
|
|
402
|
+
const stack = (0, utils_1.getStackForField)(ctx, def, fieldName, hasModelDirective);
|
|
403
403
|
if (ctx.api.host.hasResolver(typeName, fieldName)) {
|
|
404
404
|
const fieldResolver = ctx.api.host.getResolver(typeName, fieldName);
|
|
405
|
-
const fieldAuthExpression = resolvers_1.generateAuthExpressionForField(this.configuredAuthProviders, roleDefinitions, []);
|
|
405
|
+
const fieldAuthExpression = (0, resolvers_1.generateAuthExpressionForField)(this.configuredAuthProviders, roleDefinitions, []);
|
|
406
406
|
if (!ctx.api.host.hasDataSource(utils_1.NONE_DS)) {
|
|
407
407
|
ctx.api.host.addNoneDataSource(utils_1.NONE_DS);
|
|
408
408
|
}
|
|
409
|
-
const authFunction = ctx.api.host.addAppSyncFunction(`${graphql_transformer_common_2.toUpper(typeName)}${graphql_transformer_common_2.toUpper(fieldName)}AuthFN`, graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(fieldAuthExpression, `${typeName}.${fieldName}.auth.req.vtl`), graphql_transformer_core_1.MappingTemplate.inlineTemplateFromString('$util.toJson({})'), utils_1.NONE_DS, stack);
|
|
409
|
+
const authFunction = ctx.api.host.addAppSyncFunction(`${(0, graphql_transformer_common_2.toUpper)(typeName)}${(0, graphql_transformer_common_2.toUpper)(fieldName)}AuthFN`, graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(fieldAuthExpression, `${typeName}.${fieldName}.auth.req.vtl`), graphql_transformer_core_1.MappingTemplate.inlineTemplateFromString('$util.toJson({})'), utils_1.NONE_DS, stack);
|
|
410
410
|
fieldResolver.pipelineConfig.functions.unshift(authFunction.functionId);
|
|
411
411
|
}
|
|
412
412
|
else {
|
|
413
|
-
const fieldAuthExpression = resolvers_1.generateAuthExpressionForField(this.configuredAuthProviders, roleDefinitions, (_a = def.fields) !== null && _a !== void 0 ? _a : []);
|
|
413
|
+
const fieldAuthExpression = (0, resolvers_1.generateAuthExpressionForField)(this.configuredAuthProviders, roleDefinitions, (_a = def.fields) !== null && _a !== void 0 ? _a : []);
|
|
414
414
|
const subsEnabled = hasModelDirective ? this.modelDirectiveConfig.get(typeName).subscriptions.level === 'on' : false;
|
|
415
|
-
const fieldResponse = resolvers_1.generateFieldAuthResponse('Mutation', fieldName, subsEnabled);
|
|
415
|
+
const fieldResponse = (0, resolvers_1.generateFieldAuthResponse)('Mutation', fieldName, subsEnabled);
|
|
416
416
|
const resolver = ctx.resolvers.addResolver(typeName, fieldName, new graphql_transformer_core_1.TransformerResolver(typeName, fieldName, graphql_transformer_common_1.ResolverResourceIDs.ResolverResourceID(typeName, fieldName), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(fieldAuthExpression, `${typeName}.${fieldName}.req.vtl`), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(fieldResponse, `${typeName}.${fieldName}.res.vtl`), ['init'], ['finish']));
|
|
417
417
|
resolver.mapToStack(stack);
|
|
418
418
|
}
|
|
@@ -427,7 +427,7 @@ Static group authorization should perform as expected.`);
|
|
|
427
427
|
roleDefinition.allowedFields = allowedFields.length === fields.length ? [] : allowedFields;
|
|
428
428
|
return roleDefinition;
|
|
429
429
|
});
|
|
430
|
-
const authExpression = resolvers_1.generateAuthExpressionForCreate(this.configuredAuthProviders, createRoles, (_a = def.fields) !== null && _a !== void 0 ? _a : []);
|
|
430
|
+
const authExpression = (0, resolvers_1.generateAuthExpressionForCreate)(this.configuredAuthProviders, createRoles, (_a = def.fields) !== null && _a !== void 0 ? _a : []);
|
|
431
431
|
resolver.addToSlot('auth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(authExpression, `${typeName}.${fieldName}.{slotName}.{slotIndex}.req.vtl`));
|
|
432
432
|
};
|
|
433
433
|
this.protectUpdateResolver = (ctx, def, typeName, fieldName, acm) => {
|
|
@@ -444,8 +444,8 @@ Static group authorization should perform as expected.`);
|
|
|
444
444
|
return roleDefinition;
|
|
445
445
|
});
|
|
446
446
|
const datasource = ctx.api.host.getDataSource(`${def.name.value}Table`);
|
|
447
|
-
const requestExpression = resolvers_1.generateAuthRequestExpression();
|
|
448
|
-
const authExpression = resolvers_1.generateAuthExpressionForUpdate(this.configuredAuthProviders, totalRoles, (_a = def.fields) !== null && _a !== void 0 ? _a : []);
|
|
447
|
+
const requestExpression = (0, resolvers_1.generateAuthRequestExpression)();
|
|
448
|
+
const authExpression = (0, resolvers_1.generateAuthExpressionForUpdate)(this.configuredAuthProviders, totalRoles, (_a = def.fields) !== null && _a !== void 0 ? _a : []);
|
|
449
449
|
resolver.addToSlot('auth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(requestExpression, `${typeName}.${fieldName}.{slotName}.{slotIndex}.req.vtl`), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(authExpression, `${typeName}.${fieldName}.{slotName}.{slotIndex}.res.vtl`), datasource);
|
|
450
450
|
};
|
|
451
451
|
this.protectDeleteResolver = (ctx, def, typeName, fieldName, acm) => {
|
|
@@ -453,13 +453,13 @@ Static group authorization should perform as expected.`);
|
|
|
453
453
|
const resolver = ctx.resolvers.getResolver(typeName, fieldName);
|
|
454
454
|
const deleteRoles = acm.getRolesPerOperation('delete', true).map(role => this.roleMap.get(role));
|
|
455
455
|
const datasource = ctx.api.host.getDataSource(`${def.name.value}Table`);
|
|
456
|
-
const requestExpression = resolvers_1.generateAuthRequestExpression();
|
|
457
|
-
const authExpression = resolvers_1.geneateAuthExpressionForDelete(this.configuredAuthProviders, deleteRoles, (_a = def.fields) !== null && _a !== void 0 ? _a : []);
|
|
456
|
+
const requestExpression = (0, resolvers_1.generateAuthRequestExpression)();
|
|
457
|
+
const authExpression = (0, resolvers_1.geneateAuthExpressionForDelete)(this.configuredAuthProviders, deleteRoles, (_a = def.fields) !== null && _a !== void 0 ? _a : []);
|
|
458
458
|
resolver.addToSlot('auth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(requestExpression, `${typeName}.${fieldName}.{slotName}.{slotIndex}.req.vtl`), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(authExpression, `${typeName}.${fieldName}.{slotName}.{slotIndex}.res.vtl`), datasource);
|
|
459
459
|
};
|
|
460
460
|
this.protectSubscriptionResolver = (ctx, typeName, fieldName, subscriptionRoles) => {
|
|
461
461
|
const resolver = ctx.resolvers.getResolver(typeName, fieldName);
|
|
462
|
-
const authExpression = resolvers_1.generateAuthExpressionForSubscriptions(this.configuredAuthProviders, subscriptionRoles);
|
|
462
|
+
const authExpression = (0, resolvers_1.generateAuthExpressionForSubscriptions)(this.configuredAuthProviders, subscriptionRoles);
|
|
463
463
|
resolver.addToSlot('auth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(authExpression, `${typeName}.${fieldName}.{slotName}.{slotIndex}.req.vtl`));
|
|
464
464
|
};
|
|
465
465
|
this.config = config;
|
|
@@ -589,10 +589,10 @@ Static group authorization should perform as expected.`);
|
|
|
589
589
|
}
|
|
590
590
|
addFieldsToObject(ctx, modelName, ownerFields) {
|
|
591
591
|
const modelObject = ctx.output.getObject(modelName);
|
|
592
|
-
const existingFields = utils_1.collectFieldNames(modelObject);
|
|
592
|
+
const existingFields = (0, utils_1.collectFieldNames)(modelObject);
|
|
593
593
|
const ownerFieldsToAdd = ownerFields.filter(field => !existingFields.includes(field));
|
|
594
594
|
for (let ownerField of ownerFieldsToAdd) {
|
|
595
|
-
modelObject.fields.push(graphql_transformer_common_1.makeField(ownerField, [], graphql_transformer_common_1.makeNamedType('String')));
|
|
595
|
+
modelObject.fields.push((0, graphql_transformer_common_1.makeField)(ownerField, [], (0, graphql_transformer_common_1.makeNamedType)('String')));
|
|
596
596
|
}
|
|
597
597
|
ctx.output.putType(modelObject);
|
|
598
598
|
}
|
|
@@ -608,7 +608,7 @@ Static group authorization should perform as expected.`);
|
|
|
608
608
|
return fieldType;
|
|
609
609
|
};
|
|
610
610
|
const nonModelFieldTypes = def
|
|
611
|
-
.fields.map(f => ctx.output.getType(graphql_transformer_common_1.getBaseType(f.type)))
|
|
611
|
+
.fields.map(f => ctx.output.getType((0, graphql_transformer_common_1.getBaseType)(f.type)))
|
|
612
612
|
.filter(nonModelTypePredicate);
|
|
613
613
|
for (const nonModelFieldType of nonModelFieldTypes) {
|
|
614
614
|
const nonModelName = nonModelFieldType.name.value;
|
|
@@ -628,7 +628,7 @@ Static group authorization should perform as expected.`);
|
|
|
628
628
|
this.seenNonModelTypes.set(nonModelName, new Set([...directives.map(dir => dir.name.value), ...currentDirectives]));
|
|
629
629
|
}
|
|
630
630
|
if (directives.length > 0 || !hasSeenType) {
|
|
631
|
-
utils_1.extendTypeWithDirectives(ctx, nonModelFieldType.name.value, directives);
|
|
631
|
+
(0, utils_1.extendTypeWithDirectives)(ctx, nonModelFieldType.name.value, directives);
|
|
632
632
|
this.propagateAuthDirectivesToNestedTypes(ctx, nonModelFieldType, providers);
|
|
633
633
|
}
|
|
634
634
|
}
|
|
@@ -641,7 +641,7 @@ Static group authorization should perform as expected.`);
|
|
|
641
641
|
const addDirectiveIfNeeded = (provider, directiveName) => {
|
|
642
642
|
if ((this.configuredAuthProviders.default !== provider && providers.some(p => p === provider)) ||
|
|
643
643
|
(this.configuredAuthProviders.default === provider && providers.some(p => p !== provider && addDefaultIfNeeded === true))) {
|
|
644
|
-
directives.push(graphql_transformer_common_1.makeDirective(directiveName, []));
|
|
644
|
+
directives.push((0, graphql_transformer_common_1.makeDirective)(directiveName, []));
|
|
645
645
|
}
|
|
646
646
|
};
|
|
647
647
|
for (let [authProvider, directiveName] of utils_1.AUTH_PROVIDER_DIRECTIVE_MAP) {
|
|
@@ -650,7 +650,7 @@ Static group authorization should perform as expected.`);
|
|
|
650
650
|
if (providers.some(p => p === this.configuredAuthProviders.default) &&
|
|
651
651
|
providers.some(p => p !== this.configuredAuthProviders.default) &&
|
|
652
652
|
!directives.some(d => d.name.value === utils_1.AUTH_PROVIDER_DIRECTIVE_MAP.get(this.configuredAuthProviders.default))) {
|
|
653
|
-
directives.push(graphql_transformer_common_1.makeDirective(utils_1.AUTH_PROVIDER_DIRECTIVE_MAP.get(this.configuredAuthProviders.default), []));
|
|
653
|
+
directives.push((0, graphql_transformer_common_1.makeDirective)(utils_1.AUTH_PROVIDER_DIRECTIVE_MAP.get(this.configuredAuthProviders.default), []));
|
|
654
654
|
}
|
|
655
655
|
return directives;
|
|
656
656
|
}
|
|
@@ -666,7 +666,7 @@ Static group authorization should perform as expected.`);
|
|
|
666
666
|
}
|
|
667
667
|
else {
|
|
668
668
|
const authRoleParameter = ctx.stackManager.getParameter(graphql_transformer_core_1.IAM_AUTH_ROLE_PARAMETER).valueAsString;
|
|
669
|
-
const authPolicyDocuments = utils_1.createPolicyDocumentForManagedPolicy(this.authPolicyResources);
|
|
669
|
+
const authPolicyDocuments = (0, utils_1.createPolicyDocumentForManagedPolicy)(this.authPolicyResources);
|
|
670
670
|
const rootStack = ctx.stackManager.rootStack;
|
|
671
671
|
const iamAuthRoleArn = iam.Role.fromRoleArn(rootStack, 'auth-role-name', `arn:aws:iam::${cdk.Stack.of(rootStack).account}:role/${authRoleParameter}`);
|
|
672
672
|
for (let i = 0; i < authPolicyDocuments.length; i++) {
|
|
@@ -684,7 +684,7 @@ Static group authorization should perform as expected.`);
|
|
|
684
684
|
throw new graphql_transformer_core_1.TransformerContractError('UnauthRole policies should be generated, but no resources were added');
|
|
685
685
|
}
|
|
686
686
|
const unauthRoleParameter = ctx.stackManager.getParameter(graphql_transformer_core_1.IAM_UNAUTH_ROLE_PARAMETER).valueAsString;
|
|
687
|
-
const unauthPolicyDocuments = utils_1.createPolicyDocumentForManagedPolicy(this.unauthPolicyResources);
|
|
687
|
+
const unauthPolicyDocuments = (0, utils_1.createPolicyDocumentForManagedPolicy)(this.unauthPolicyResources);
|
|
688
688
|
const rootStack = ctx.stackManager.rootStack;
|
|
689
689
|
const iamUnauthRoleArn = iam.Role.fromRoleArn(rootStack, 'unauth-role-name', `arn:aws:iam::${cdk.Stack.of(rootStack).account}:role/${unauthRoleParameter}`);
|
|
690
690
|
for (let i = 0; i < unauthPolicyDocuments.length; i++) {
|