quidproquo-deploy-awscdk 0.0.71 → 0.0.73
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/lib/constructs/base/QpqConstructBlock.js +2 -2
- package/lib/constructs/basic/Function.js +5 -0
- package/lib/constructs/basic/LambdaLayers.js +1 -1
- package/lib/constructs/feature/core/auth/QpqCoreUserDirectoryConstruct.d.ts +19 -0
- package/lib/constructs/feature/core/auth/QpqCoreUserDirectoryConstruct.js +89 -0
- package/lib/constructs/feature/core/auth/index.d.ts +1 -0
- package/lib/constructs/feature/core/auth/index.js +17 -0
- package/lib/constructs/feature/core/index.d.ts +1 -0
- package/lib/constructs/feature/core/index.js +1 -0
- package/lib/constructs/feature/webserver/api/QpqWebserverApiConstruct.js +1 -1
- package/lib/lambdas/lambdaAPIGatewayEvent.js +3 -1
- package/lib/lambdas/lambdaEventBridgeEvent.js +1 -1
- package/lib/lambdas/lambdaEventOriginRequest.js +1 -1
- package/lib/lambdas/lambdaSQSEvent.js +1 -1
- package/lib/stacks/InfQpqServiceStack.js +6 -0
- package/lib/utils/qpqDeployAwsCdkUtils.d.ts +7 -0
- package/lib/utils/qpqDeployAwsCdkUtils.js +69 -1
- package/package.json +1 -1
- package/src/constructs/base/QpqConstructBlock.ts +2 -2
- package/src/constructs/basic/Function.ts +9 -1
- package/src/constructs/basic/LambdaLayers.ts +4 -1
- package/src/constructs/feature/core/auth/QpqCoreUserDirectoryConstruct.ts +136 -0
- package/src/constructs/feature/core/auth/index.ts +1 -0
- package/src/constructs/feature/core/index.ts +1 -0
- package/src/constructs/feature/webserver/api/QpqWebserverApiConstruct.ts +2 -1
- package/src/lambdas/lambdaAPIGatewayEvent.ts +5 -0
- package/src/lambdas/lambdaEventBridgeEvent.ts +2 -0
- package/src/lambdas/lambdaEventOriginRequest.ts +4 -0
- package/src/lambdas/lambdaSQSEvent.ts +2 -0
- package/src/stacks/InfQpqServiceStack.ts +12 -0
- package/src/utils/qpqDeployAwsCdkUtils.ts +90 -1
|
@@ -10,10 +10,10 @@ class QpqConstructBlock extends constructs_1.Construct {
|
|
|
10
10
|
this.qpqConfig = props.qpqConfig;
|
|
11
11
|
}
|
|
12
12
|
resourceName(name) {
|
|
13
|
-
return quidproquo_actionprocessor_awslambda_1.awsNamingUtils.
|
|
13
|
+
return quidproquo_actionprocessor_awslambda_1.awsNamingUtils.getConfigRuntimeResourceNameFromConfig(name, this.qpqConfig);
|
|
14
14
|
}
|
|
15
15
|
qpqResourceName(name, resourceType) {
|
|
16
|
-
return quidproquo_actionprocessor_awslambda_1.awsNamingUtils.
|
|
16
|
+
return quidproquo_actionprocessor_awslambda_1.awsNamingUtils.getQpqRuntimeResourceNameFromConfig(name, this.qpqConfig, resourceType);
|
|
17
17
|
}
|
|
18
18
|
grantRead(grantee) { }
|
|
19
19
|
grantWrite(grantee) { }
|
|
@@ -44,6 +44,11 @@ class Function extends QpqConstructBlock_1.QpqConstructBlock {
|
|
|
44
44
|
handler: `index.${props.executorName}`,
|
|
45
45
|
environment: props.environment,
|
|
46
46
|
});
|
|
47
|
+
// Let lambdas read from the exported variables in cloudformation
|
|
48
|
+
this.lambdaFunction.addToRolePolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
49
|
+
actions: ['cloudformation:ListExports'],
|
|
50
|
+
resources: ['*'],
|
|
51
|
+
}));
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
exports.Function = Function;
|
|
@@ -10,7 +10,7 @@ class LambdaLayers extends QpqConstructBlock_1.QpqConstructBlock {
|
|
|
10
10
|
this.layers = (props.apiLayers || []).map((layer) => {
|
|
11
11
|
return layer.buildPath
|
|
12
12
|
? new aws_cdk_lib_1.aws_lambda.LayerVersion(this, `${layer.name}-layer`, {
|
|
13
|
-
layerVersionName: quidproquo_actionprocessor_awslambda_1.awsNamingUtils.
|
|
13
|
+
layerVersionName: quidproquo_actionprocessor_awslambda_1.awsNamingUtils.getQpqRuntimeResourceNameFromConfig(layer.name, props.qpqConfig),
|
|
14
14
|
code: new aws_cdk_lib_1.aws_lambda.AssetCode(layer.buildPath),
|
|
15
15
|
compatibleRuntimes: [aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_18_X],
|
|
16
16
|
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { QPQConfig, UserDirectoryQPQConfigSetting } from 'quidproquo-core';
|
|
2
|
+
import { QpqConstructBlock, QpqConstructBlockProps } from '../../../base/QpqConstructBlock';
|
|
3
|
+
import { QpqResource } from '../../../base/QpqResource';
|
|
4
|
+
import { Construct } from 'constructs';
|
|
5
|
+
import { aws_iam, aws_cognito } from 'aws-cdk-lib';
|
|
6
|
+
export interface QpqCoreUserDirectoryConstructProps extends QpqConstructBlockProps {
|
|
7
|
+
userDirectoryConfig: UserDirectoryQPQConfigSetting;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class QpqCoreUserDirectoryConstructBase extends QpqConstructBlock {
|
|
10
|
+
abstract userPool: aws_cognito.IUserPool;
|
|
11
|
+
grantRead(grantee: aws_iam.IGrantable): void;
|
|
12
|
+
grantWrite(grantee: aws_iam.IGrantable): void;
|
|
13
|
+
grantAll(grantee: aws_iam.IGrantable): void;
|
|
14
|
+
}
|
|
15
|
+
export declare class QpqCoreUserDirectoryConstruct extends QpqCoreUserDirectoryConstructBase {
|
|
16
|
+
userPool: aws_cognito.IUserPool;
|
|
17
|
+
static fromOtherStack(scope: Construct, id: string, qpqConfig: QPQConfig, awsAccountId: string, userDirectoryName: string, serviceOverride?: string, applicationOverride?: string): QpqResource;
|
|
18
|
+
constructor(scope: Construct, id: string, props: QpqCoreUserDirectoryConstructProps);
|
|
19
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.QpqCoreUserDirectoryConstruct = exports.QpqCoreUserDirectoryConstructBase = void 0;
|
|
27
|
+
const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
|
|
28
|
+
const QpqConstructBlock_1 = require("../../../base/QpqConstructBlock");
|
|
29
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
30
|
+
const cdk = __importStar(require("aws-cdk-lib"));
|
|
31
|
+
const qpqDeployAwsCdkUtils = __importStar(require("../../../../utils"));
|
|
32
|
+
class QpqCoreUserDirectoryConstructBase extends QpqConstructBlock_1.QpqConstructBlock {
|
|
33
|
+
grantRead(grantee) {
|
|
34
|
+
this.userPool.grant(grantee, 'cognito-idp:ListUsers', 'cognito-idp:GetUser', 'cognito-idp:ListGroups', 'cognito-idp:GetGroup', 'cognito-idp:ListUserPools', 'cognito-idp:DescribeUserPool', 'cognito-idp:DescribeUserPoolClient');
|
|
35
|
+
}
|
|
36
|
+
grantWrite(grantee) {
|
|
37
|
+
this.userPool.grant(grantee, 'cognito-idp:SignUp', 'cognito-idp:AdminCreateUser', 'cognito-idp:AdminInitiateAuth', 'cognito-idp:AdminRespondToAuthChallenge', 'cognito-idp:AdminAddUserToGroup', 'cognito-idp:AdminDeleteUser', 'cognito-idp:AdminUpdateUserAttributes', 'cognito-idp:AdminDeleteUserAttributes', 'cognito-idp:AdminSetUserPassword');
|
|
38
|
+
}
|
|
39
|
+
grantAll(grantee) {
|
|
40
|
+
this.grantRead(grantee);
|
|
41
|
+
this.grantWrite(grantee);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.QpqCoreUserDirectoryConstructBase = QpqCoreUserDirectoryConstructBase;
|
|
45
|
+
class QpqCoreUserDirectoryConstruct extends QpqCoreUserDirectoryConstructBase {
|
|
46
|
+
static fromOtherStack(scope, id, qpqConfig, awsAccountId, userDirectoryName, serviceOverride, applicationOverride) {
|
|
47
|
+
const userPoolId = qpqDeployAwsCdkUtils.importStackValue(quidproquo_actionprocessor_awslambda_1.awsNamingUtils.getCFExportNameUserPoolIdFromConfig(userDirectoryName, qpqConfig, serviceOverride, applicationOverride));
|
|
48
|
+
class Import extends QpqCoreUserDirectoryConstructBase {
|
|
49
|
+
constructor() {
|
|
50
|
+
super(...arguments);
|
|
51
|
+
this.userPool = aws_cdk_lib_1.aws_cognito.UserPool.fromUserPoolId(this, 'pool-id', userPoolId);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return new Import(scope, id, { qpqConfig, awsAccountId });
|
|
55
|
+
}
|
|
56
|
+
constructor(scope, id, props) {
|
|
57
|
+
super(scope, id, props);
|
|
58
|
+
this.userPool = new aws_cdk_lib_1.aws_cognito.UserPool(this, 'user-pool', {
|
|
59
|
+
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
60
|
+
userPoolName: this.resourceName(props.userDirectoryConfig.name),
|
|
61
|
+
selfSignUpEnabled: props.userDirectoryConfig.selfSignUpEnabled,
|
|
62
|
+
standardAttributes: {
|
|
63
|
+
email: {
|
|
64
|
+
required: true,
|
|
65
|
+
mutable: true,
|
|
66
|
+
},
|
|
67
|
+
phoneNumber: {
|
|
68
|
+
required: props.userDirectoryConfig.phoneRequired,
|
|
69
|
+
mutable: true,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
autoVerify: {
|
|
73
|
+
email: true,
|
|
74
|
+
phone: props.userDirectoryConfig.phoneRequired,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
qpqDeployAwsCdkUtils.exportStackValue(this, quidproquo_actionprocessor_awslambda_1.awsNamingUtils.getCFExportNameUserPoolIdFromConfig(props.userDirectoryConfig.name, props.qpqConfig), this.userPool.userPoolId);
|
|
78
|
+
const userPoolClient = new aws_cdk_lib_1.aws_cognito.UserPoolClient(this, 'user-pool-client', {
|
|
79
|
+
userPoolClientName: this.qpqResourceName(props.userDirectoryConfig.name, 'upc'),
|
|
80
|
+
userPool: this.userPool,
|
|
81
|
+
generateSecret: true,
|
|
82
|
+
authFlows: {
|
|
83
|
+
adminUserPassword: true,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
qpqDeployAwsCdkUtils.exportStackValue(this, quidproquo_actionprocessor_awslambda_1.awsNamingUtils.getCFExportNameUserPoolClientIdFromConfig(props.userDirectoryConfig.name, props.qpqConfig), userPoolClient.userPoolClientId);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.QpqCoreUserDirectoryConstruct = QpqCoreUserDirectoryConstruct;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './QpqCoreUserDirectoryConstruct';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./QpqCoreUserDirectoryConstruct"), exports);
|
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./auth"), exports);
|
|
17
18
|
__exportStar(require("./parameter"), exports);
|
|
18
19
|
__exportStar(require("./queue"), exports);
|
|
19
20
|
__exportStar(require("./schedule"), exports);
|
|
@@ -54,7 +54,7 @@ class QpqWebserverApiConstruct extends QpqConstructBlock_1.QpqConstructBlock {
|
|
|
54
54
|
apiLayerVersions: props.apiLayerVersions,
|
|
55
55
|
awsAccountId: props.awsAccountId,
|
|
56
56
|
});
|
|
57
|
-
const grantables = qpqDeployAwsCdkUtils.
|
|
57
|
+
const grantables = qpqDeployAwsCdkUtils.getQqpGrantableResourcesForApiConfig(this, 'grantable', this.qpqConfig, props.awsAccountId, props.apiConfig);
|
|
58
58
|
grantables.forEach((g) => {
|
|
59
59
|
g.grantAll(func.lambdaFunction);
|
|
60
60
|
});
|
|
@@ -32,6 +32,7 @@ const ErrorTypeHttpResponseMap = {
|
|
|
32
32
|
[quidproquo_core_1.ErrorTypeEnum.Forbidden]: 403,
|
|
33
33
|
[quidproquo_core_1.ErrorTypeEnum.NotFound]: 404,
|
|
34
34
|
[quidproquo_core_1.ErrorTypeEnum.TimeOut]: 408,
|
|
35
|
+
[quidproquo_core_1.ErrorTypeEnum.Conflict]: 409,
|
|
35
36
|
[quidproquo_core_1.ErrorTypeEnum.UnsupportedMediaType]: 415,
|
|
36
37
|
[quidproquo_core_1.ErrorTypeEnum.OutOfResources]: 500,
|
|
37
38
|
[quidproquo_core_1.ErrorTypeEnum.GenericError]: 500,
|
|
@@ -44,7 +45,7 @@ const getAPIGatewayEventExecutor = (dynamicModuleLoader, getCustomActionProcesso
|
|
|
44
45
|
const cdkConfig = yield (0, lambdaConfig_1.getLambdaConfigs)();
|
|
45
46
|
// Build a processor for the session and stuff
|
|
46
47
|
// Remove the non route ones ~ let the story execute action add them
|
|
47
|
-
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getAPIGatewayEventActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_node_2.getConfigActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getQueueActionProcessor)(cdkConfig.qpqConfig)), getCustomActionProcessors(cdkConfig.qpqConfig)), (0, qpq_custom_action_processors_loader_1.default)());
|
|
48
|
+
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getAPIGatewayEventActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_node_2.getConfigActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getQueueActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getUserDirectoryActionProcessor)(cdkConfig.qpqConfig)), getCustomActionProcessors(cdkConfig.qpqConfig)), (0, qpq_custom_action_processors_loader_1.default)());
|
|
48
49
|
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
50
|
// addResult(
|
|
50
51
|
// envConfig.appName,
|
|
@@ -67,6 +68,7 @@ const getAPIGatewayEventExecutor = (dynamicModuleLoader, getCustomActionProcesso
|
|
|
67
68
|
headers: result.result.headers,
|
|
68
69
|
isBase64Encoded: result.result.isBase64Encoded,
|
|
69
70
|
};
|
|
71
|
+
console.log('Response: ', response);
|
|
70
72
|
return response;
|
|
71
73
|
}
|
|
72
74
|
const code = ErrorTypeHttpResponseMap[result.error.errorType];
|
|
@@ -30,7 +30,7 @@ const getEventBridgeEventExecutor = (dynamicModuleLoader, getCustomActionProcess
|
|
|
30
30
|
const lambdaRuntimeConfig = JSON.parse(process.env.lambdaRuntimeConfig || '{}');
|
|
31
31
|
// Build a processor for the session and stuff
|
|
32
32
|
// Remove the non event ones
|
|
33
|
-
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getEventBridgeEventActionProcessor)(lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_node_2.getConfigActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getQueueActionProcessor)(cdkConfig.qpqConfig)), getCustomActionProcessors(cdkConfig.qpqConfig)), (0, qpq_custom_action_processors_loader_1.default)());
|
|
33
|
+
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getEventBridgeEventActionProcessor)(lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_node_2.getConfigActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getQueueActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getUserDirectoryActionProcessor)(cdkConfig.qpqConfig)), getCustomActionProcessors(cdkConfig.qpqConfig)), (0, qpq_custom_action_processors_loader_1.default)());
|
|
34
34
|
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () { });
|
|
35
35
|
// Run the callback
|
|
36
36
|
const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, quidproquo_actionprocessor_awslambda_1.awsLambdaUtils.randomGuid);
|
|
@@ -30,7 +30,7 @@ const getOriginRequestEventExecutor = (dynamicModuleLoader, getCustomActionProce
|
|
|
30
30
|
const cdkConfig = yield (0, lambdaConfig_1.getLambdaConfigs)();
|
|
31
31
|
// Build a processor for the session and stuff
|
|
32
32
|
// Remove the non route ones ~ let the story execute action add them
|
|
33
|
-
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getCloudFrontOriginRequestEventActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_node_2.getConfigActionProcessor)(cdkConfig.qpqConfig)), getCustomActionProcessors(cdkConfig.qpqConfig)), (0, qpq_custom_action_processors_loader_1.default)());
|
|
33
|
+
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getCloudFrontOriginRequestEventActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_node_2.getConfigActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getUserDirectoryActionProcessor)(cdkConfig.qpqConfig)), getCustomActionProcessors(cdkConfig.qpqConfig)), (0, qpq_custom_action_processors_loader_1.default)());
|
|
34
34
|
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () { });
|
|
35
35
|
// Run the callback
|
|
36
36
|
const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, quidproquo_actionprocessor_awslambda_1.awsLambdaUtils.randomGuid);
|
|
@@ -28,7 +28,7 @@ const getStoryActionRuntime = (dynamicModuleLoader, getCustomActionProcessors =
|
|
|
28
28
|
const cdkConfig = yield (0, lambdaConfig_1.getLambdaConfigs)();
|
|
29
29
|
// Build a processor for the session and stuff
|
|
30
30
|
// Remove the non route ones ~ let the story execute action add them
|
|
31
|
-
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getSQSEventRecordActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_node_2.getConfigActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getQueueActionProcessor)(cdkConfig.qpqConfig)), getCustomActionProcessors(cdkConfig.qpqConfig)), (0, qpq_custom_action_processors_loader_1.default)());
|
|
31
|
+
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getSQSEventRecordActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_node_2.getConfigActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getQueueActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getUserDirectoryActionProcessor)(cdkConfig.qpqConfig)), getCustomActionProcessors(cdkConfig.qpqConfig)), (0, qpq_custom_action_processors_loader_1.default)());
|
|
32
32
|
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () { });
|
|
33
33
|
// Run the callback
|
|
34
34
|
const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, quidproquo_actionprocessor_awslambda_1.awsLambdaUtils.randomGuid);
|
|
@@ -38,6 +38,12 @@ class InfQpqServiceStack extends QpqServiceStack_1.QpqServiceStack {
|
|
|
38
38
|
qpqConfig: props.qpqConfig,
|
|
39
39
|
dnsConfig: setting,
|
|
40
40
|
}));
|
|
41
|
+
// User Directories
|
|
42
|
+
const userDirectories = quidproquo_core_1.qpqCoreUtils.getUserDirectories(props.qpqConfig).map((setting) => new constructs_1.QpqCoreUserDirectoryConstruct(this, quidproquo_core_1.qpqCoreUtils.getUniqueKeyForSetting(setting), {
|
|
43
|
+
awsAccountId: props.awsAccountId,
|
|
44
|
+
qpqConfig: props.qpqConfig,
|
|
45
|
+
userDirectoryConfig: setting,
|
|
46
|
+
}));
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
exports.InfQpqServiceStack = InfQpqServiceStack;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { Construct } from 'constructs';
|
|
2
|
+
import * as cdk from 'aws-cdk-lib';
|
|
2
3
|
import { QPQConfig } from 'quidproquo-core';
|
|
4
|
+
import { ApiQPQWebServerConfigSetting } from 'quidproquo-webserver';
|
|
3
5
|
import { QpqResource } from '../constructs';
|
|
4
6
|
export declare const getQqpSecretGrantables: (scope: Construct, id: string, qpqConfig: QPQConfig, awsAccountId: string) => QpqResource[];
|
|
5
7
|
export declare const getQqpParameterGrantables: (scope: Construct, id: string, qpqConfig: QPQConfig, awsAccountId: string) => QpqResource[];
|
|
6
8
|
export declare const getQqpStorageDriveGrantables: (scope: Construct, id: string, qpqConfig: QPQConfig, awsAccountId: string) => QpqResource[];
|
|
7
9
|
export declare const getQqpQueueGrantables: (scope: Construct, id: string, qpqConfig: QPQConfig, awsAccountId: string) => QpqResource[];
|
|
10
|
+
export declare const getQqpUserPoolGrantables: (scope: Construct, id: string, qpqConfig: QPQConfig, awsAccountId: string) => QpqResource[];
|
|
11
|
+
export declare const getQqpUserPoolGrantablesForApiConfig: (scope: Construct, id: string, qpqConfig: QPQConfig, awsAccountId: string, config: ApiQPQWebServerConfigSetting) => QpqResource[];
|
|
8
12
|
export declare const serviceNeedsServiceHostedZone: (qpqConfig: QPQConfig) => boolean;
|
|
9
13
|
export declare const getQqpGrantableResources: (scope: Construct, id: string, qpqConfig: QPQConfig, awsAccountId: string) => QpqResource[];
|
|
14
|
+
export declare const getQqpGrantableResourcesForApiConfig: (scope: Construct, id: string, qpqConfig: QPQConfig, awsAccountId: string, config: ApiQPQWebServerConfigSetting) => QpqResource[];
|
|
15
|
+
export declare const exportStackValue: (scope: Construct, uniqueKey: string, value: string) => cdk.CfnOutput;
|
|
16
|
+
export declare const importStackValue: (uniqueKey: string) => string;
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getQqpGrantableResources = exports.serviceNeedsServiceHostedZone = exports.getQqpQueueGrantables = exports.getQqpStorageDriveGrantables = exports.getQqpParameterGrantables = exports.getQqpSecretGrantables = void 0;
|
|
26
|
+
exports.importStackValue = exports.exportStackValue = exports.getQqpGrantableResourcesForApiConfig = exports.getQqpGrantableResources = exports.serviceNeedsServiceHostedZone = exports.getQqpUserPoolGrantablesForApiConfig = exports.getQqpUserPoolGrantables = exports.getQqpQueueGrantables = exports.getQqpStorageDriveGrantables = exports.getQqpParameterGrantables = exports.getQqpSecretGrantables = void 0;
|
|
27
|
+
const cdk = __importStar(require("aws-cdk-lib"));
|
|
4
28
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
5
29
|
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
6
30
|
const constructs_1 = require("../constructs");
|
|
@@ -44,6 +68,29 @@ const getQqpQueueGrantables = (scope, id, qpqConfig, awsAccountId) => {
|
|
|
44
68
|
return queueResources;
|
|
45
69
|
};
|
|
46
70
|
exports.getQqpQueueGrantables = getQqpQueueGrantables;
|
|
71
|
+
const getQqpUserPoolGrantables = (scope, id, qpqConfig, awsAccountId) => {
|
|
72
|
+
const userDirectoryConfigs = quidproquo_core_1.qpqCoreUtils.getUserDirectories(qpqConfig);
|
|
73
|
+
const userDirectoryResources = userDirectoryConfigs.map((userDirectoryConfig) => {
|
|
74
|
+
return constructs_1.QpqCoreUserDirectoryConstruct.fromOtherStack(scope, `${id}-${quidproquo_core_1.qpqCoreUtils.getUniqueKeyForSetting(userDirectoryConfig)}-grantable`, qpqConfig, awsAccountId, userDirectoryConfig.name);
|
|
75
|
+
});
|
|
76
|
+
return userDirectoryResources;
|
|
77
|
+
};
|
|
78
|
+
exports.getQqpUserPoolGrantables = getQqpUserPoolGrantables;
|
|
79
|
+
const getQqpUserPoolGrantablesForApiConfig = (scope, id, qpqConfig, awsAccountId, config) => {
|
|
80
|
+
const routesWithAuth = quidproquo_webserver_1.qpqWebServerUtils
|
|
81
|
+
.getAllRoutesForApi(config.apiName, qpqConfig)
|
|
82
|
+
.filter((r) => {
|
|
83
|
+
var _a, _b, _c;
|
|
84
|
+
return ((_a = r.options.routeAuthSettings) === null || _a === void 0 ? void 0 : _a.userDirectoryName) &&
|
|
85
|
+
(((_b = r.options.routeAuthSettings) === null || _b === void 0 ? void 0 : _b.applicationName) || ((_c = r.options.routeAuthSettings) === null || _c === void 0 ? void 0 : _c.serviceName));
|
|
86
|
+
});
|
|
87
|
+
const userDirectoryResources = routesWithAuth.map((route) => {
|
|
88
|
+
var _a, _b, _c;
|
|
89
|
+
return constructs_1.QpqCoreUserDirectoryConstruct.fromOtherStack(scope, `${id}-${quidproquo_core_1.qpqCoreUtils.getUniqueKeyForSetting(route)}-grantable-xserver`, qpqConfig, awsAccountId, (_a = route.options.routeAuthSettings) === null || _a === void 0 ? void 0 : _a.userDirectoryName, (_b = route.options.routeAuthSettings) === null || _b === void 0 ? void 0 : _b.serviceName, (_c = route.options.routeAuthSettings) === null || _c === void 0 ? void 0 : _c.applicationName);
|
|
90
|
+
});
|
|
91
|
+
return userDirectoryResources;
|
|
92
|
+
};
|
|
93
|
+
exports.getQqpUserPoolGrantablesForApiConfig = getQqpUserPoolGrantablesForApiConfig;
|
|
47
94
|
const serviceNeedsServiceHostedZone = (qpqConfig) => {
|
|
48
95
|
// We need it if we are deploying our api to a service domain
|
|
49
96
|
const apiConfigs = quidproquo_core_1.qpqCoreUtils
|
|
@@ -61,6 +108,27 @@ const getQqpGrantableResources = (scope, id, qpqConfig, awsAccountId) => {
|
|
|
61
108
|
...(0, exports.getQqpSecretGrantables)(scope, id, qpqConfig, awsAccountId),
|
|
62
109
|
...(0, exports.getQqpStorageDriveGrantables)(scope, id, qpqConfig, awsAccountId),
|
|
63
110
|
...(0, exports.getQqpQueueGrantables)(scope, id, qpqConfig, awsAccountId),
|
|
111
|
+
...(0, exports.getQqpUserPoolGrantables)(scope, id, qpqConfig, awsAccountId),
|
|
64
112
|
];
|
|
65
113
|
};
|
|
66
114
|
exports.getQqpGrantableResources = getQqpGrantableResources;
|
|
115
|
+
const getQqpGrantableResourcesForApiConfig = (scope, id, qpqConfig, awsAccountId, config) => {
|
|
116
|
+
return [
|
|
117
|
+
// All the normal grantables
|
|
118
|
+
...(0, exports.getQqpGrantableResources)(scope, id, qpqConfig, awsAccountId),
|
|
119
|
+
// Then special grantables just for this config.
|
|
120
|
+
...(0, exports.getQqpUserPoolGrantablesForApiConfig)(scope, id, qpqConfig, awsAccountId, config),
|
|
121
|
+
];
|
|
122
|
+
};
|
|
123
|
+
exports.getQqpGrantableResourcesForApiConfig = getQqpGrantableResourcesForApiConfig;
|
|
124
|
+
const exportStackValue = (scope, uniqueKey, value) => {
|
|
125
|
+
return new cdk.CfnOutput(scope, uniqueKey, {
|
|
126
|
+
exportName: uniqueKey,
|
|
127
|
+
value,
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
exports.exportStackValue = exportStackValue;
|
|
131
|
+
const importStackValue = (uniqueKey) => {
|
|
132
|
+
return cdk.Fn.importValue(uniqueKey);
|
|
133
|
+
};
|
|
134
|
+
exports.importStackValue = importStackValue;
|
package/package.json
CHANGED
|
@@ -22,11 +22,11 @@ export class QpqConstructBlock extends Construct implements QpqResource {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
resourceName(name: string) {
|
|
25
|
-
return awsNamingUtils.
|
|
25
|
+
return awsNamingUtils.getConfigRuntimeResourceNameFromConfig(name, this.qpqConfig);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
qpqResourceName(name: string, resourceType: string) {
|
|
29
|
-
return awsNamingUtils.
|
|
29
|
+
return awsNamingUtils.getQpqRuntimeResourceNameFromConfig(name, this.qpqConfig, resourceType);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
grantRead(grantee: IGrantable): void {}
|
|
@@ -2,7 +2,7 @@ import path from 'path';
|
|
|
2
2
|
|
|
3
3
|
import { QpqConstructBlock, QpqConstructBlockProps } from '../base/QpqConstructBlock';
|
|
4
4
|
import { Construct } from 'constructs';
|
|
5
|
-
import { aws_lambda } from 'aws-cdk-lib';
|
|
5
|
+
import { aws_lambda, aws_iam } from 'aws-cdk-lib';
|
|
6
6
|
import * as cdk from 'aws-cdk-lib';
|
|
7
7
|
|
|
8
8
|
export interface FunctionProps extends QpqConstructBlockProps {
|
|
@@ -41,5 +41,13 @@ export class Function extends QpqConstructBlock {
|
|
|
41
41
|
|
|
42
42
|
environment: props.environment,
|
|
43
43
|
});
|
|
44
|
+
|
|
45
|
+
// Let lambdas read from the exported variables in cloudformation
|
|
46
|
+
this.lambdaFunction.addToRolePolicy(
|
|
47
|
+
new aws_iam.PolicyStatement({
|
|
48
|
+
actions: ['cloudformation:ListExports'],
|
|
49
|
+
resources: ['*'],
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
44
52
|
}
|
|
45
53
|
}
|
|
@@ -22,7 +22,10 @@ export class LambdaLayers extends QpqConstructBlock {
|
|
|
22
22
|
this.layers = (props.apiLayers || []).map((layer) => {
|
|
23
23
|
return layer.buildPath
|
|
24
24
|
? new aws_lambda.LayerVersion(this, `${layer.name}-layer`, {
|
|
25
|
-
layerVersionName: awsNamingUtils.
|
|
25
|
+
layerVersionName: awsNamingUtils.getQpqRuntimeResourceNameFromConfig(
|
|
26
|
+
layer.name,
|
|
27
|
+
props.qpqConfig,
|
|
28
|
+
),
|
|
26
29
|
code: new aws_lambda.AssetCode(layer.buildPath),
|
|
27
30
|
compatibleRuntimes: [aws_lambda.Runtime.NODEJS_18_X],
|
|
28
31
|
})
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { QPQConfig, UserDirectoryQPQConfigSetting } from 'quidproquo-core';
|
|
2
|
+
import { awsNamingUtils } from 'quidproquo-actionprocessor-awslambda';
|
|
3
|
+
|
|
4
|
+
import { QpqConstructBlock, QpqConstructBlockProps } from '../../../base/QpqConstructBlock';
|
|
5
|
+
import { QpqResource } from '../../../base/QpqResource';
|
|
6
|
+
|
|
7
|
+
import { Construct } from 'constructs';
|
|
8
|
+
import { aws_iam, aws_cognito } from 'aws-cdk-lib';
|
|
9
|
+
import * as cdk from 'aws-cdk-lib';
|
|
10
|
+
|
|
11
|
+
import * as qpqDeployAwsCdkUtils from '../../../../utils';
|
|
12
|
+
|
|
13
|
+
export interface QpqCoreUserDirectoryConstructProps extends QpqConstructBlockProps {
|
|
14
|
+
userDirectoryConfig: UserDirectoryQPQConfigSetting;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export abstract class QpqCoreUserDirectoryConstructBase extends QpqConstructBlock {
|
|
18
|
+
abstract userPool: aws_cognito.IUserPool;
|
|
19
|
+
|
|
20
|
+
public grantRead(grantee: aws_iam.IGrantable) {
|
|
21
|
+
this.userPool.grant(
|
|
22
|
+
grantee,
|
|
23
|
+
|
|
24
|
+
'cognito-idp:ListUsers',
|
|
25
|
+
'cognito-idp:GetUser',
|
|
26
|
+
|
|
27
|
+
'cognito-idp:ListGroups',
|
|
28
|
+
'cognito-idp:GetGroup',
|
|
29
|
+
|
|
30
|
+
'cognito-idp:ListUserPools',
|
|
31
|
+
|
|
32
|
+
'cognito-idp:DescribeUserPool',
|
|
33
|
+
'cognito-idp:DescribeUserPoolClient',
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public grantWrite(grantee: aws_iam.IGrantable): void {
|
|
38
|
+
this.userPool.grant(
|
|
39
|
+
grantee,
|
|
40
|
+
'cognito-idp:SignUp',
|
|
41
|
+
'cognito-idp:AdminCreateUser',
|
|
42
|
+
'cognito-idp:AdminInitiateAuth',
|
|
43
|
+
'cognito-idp:AdminRespondToAuthChallenge',
|
|
44
|
+
'cognito-idp:AdminAddUserToGroup',
|
|
45
|
+
'cognito-idp:AdminDeleteUser',
|
|
46
|
+
'cognito-idp:AdminUpdateUserAttributes',
|
|
47
|
+
'cognito-idp:AdminDeleteUserAttributes',
|
|
48
|
+
'cognito-idp:AdminSetUserPassword',
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public grantAll(grantee: aws_iam.IGrantable): void {
|
|
53
|
+
this.grantRead(grantee);
|
|
54
|
+
this.grantWrite(grantee);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export class QpqCoreUserDirectoryConstruct extends QpqCoreUserDirectoryConstructBase {
|
|
59
|
+
userPool: aws_cognito.IUserPool;
|
|
60
|
+
|
|
61
|
+
static fromOtherStack(
|
|
62
|
+
scope: Construct,
|
|
63
|
+
id: string,
|
|
64
|
+
qpqConfig: QPQConfig,
|
|
65
|
+
awsAccountId: string,
|
|
66
|
+
userDirectoryName: string,
|
|
67
|
+
serviceOverride?: string,
|
|
68
|
+
applicationOverride?: string,
|
|
69
|
+
): QpqResource {
|
|
70
|
+
const userPoolId = qpqDeployAwsCdkUtils.importStackValue(
|
|
71
|
+
awsNamingUtils.getCFExportNameUserPoolIdFromConfig(
|
|
72
|
+
userDirectoryName,
|
|
73
|
+
qpqConfig,
|
|
74
|
+
serviceOverride,
|
|
75
|
+
applicationOverride,
|
|
76
|
+
),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
class Import extends QpqCoreUserDirectoryConstructBase {
|
|
80
|
+
userPool = aws_cognito.UserPool.fromUserPoolId(this, 'pool-id', userPoolId);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return new Import(scope, id, { qpqConfig, awsAccountId });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
constructor(scope: Construct, id: string, props: QpqCoreUserDirectoryConstructProps) {
|
|
87
|
+
super(scope, id, props);
|
|
88
|
+
|
|
89
|
+
this.userPool = new aws_cognito.UserPool(this, 'user-pool', {
|
|
90
|
+
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
91
|
+
userPoolName: this.resourceName(props.userDirectoryConfig.name),
|
|
92
|
+
selfSignUpEnabled: props.userDirectoryConfig.selfSignUpEnabled,
|
|
93
|
+
standardAttributes: {
|
|
94
|
+
email: {
|
|
95
|
+
required: true,
|
|
96
|
+
mutable: true,
|
|
97
|
+
},
|
|
98
|
+
phoneNumber: {
|
|
99
|
+
required: props.userDirectoryConfig.phoneRequired,
|
|
100
|
+
mutable: true,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
autoVerify: {
|
|
104
|
+
email: true,
|
|
105
|
+
phone: props.userDirectoryConfig.phoneRequired,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
qpqDeployAwsCdkUtils.exportStackValue(
|
|
110
|
+
this,
|
|
111
|
+
awsNamingUtils.getCFExportNameUserPoolIdFromConfig(
|
|
112
|
+
props.userDirectoryConfig.name,
|
|
113
|
+
props.qpqConfig,
|
|
114
|
+
),
|
|
115
|
+
this.userPool.userPoolId,
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const userPoolClient = new aws_cognito.UserPoolClient(this, 'user-pool-client', {
|
|
119
|
+
userPoolClientName: this.qpqResourceName(props.userDirectoryConfig.name, 'upc'),
|
|
120
|
+
userPool: this.userPool,
|
|
121
|
+
generateSecret: true,
|
|
122
|
+
authFlows: {
|
|
123
|
+
adminUserPassword: true,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
qpqDeployAwsCdkUtils.exportStackValue(
|
|
128
|
+
this,
|
|
129
|
+
awsNamingUtils.getCFExportNameUserPoolClientIdFromConfig(
|
|
130
|
+
props.userDirectoryConfig.name,
|
|
131
|
+
props.qpqConfig,
|
|
132
|
+
),
|
|
133
|
+
userPoolClient.userPoolClientId,
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './QpqCoreUserDirectoryConstruct';
|
|
@@ -47,11 +47,12 @@ export class QpqWebserverApiConstruct extends QpqConstructBlock {
|
|
|
47
47
|
awsAccountId: props.awsAccountId,
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
const grantables = qpqDeployAwsCdkUtils.
|
|
50
|
+
const grantables = qpqDeployAwsCdkUtils.getQqpGrantableResourcesForApiConfig(
|
|
51
51
|
this,
|
|
52
52
|
'grantable',
|
|
53
53
|
this.qpqConfig,
|
|
54
54
|
props.awsAccountId,
|
|
55
|
+
props.apiConfig,
|
|
55
56
|
);
|
|
56
57
|
|
|
57
58
|
grantables.forEach((g) => {
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
getConfigGetSecretActionProcessor,
|
|
9
9
|
getConfigGetParameterActionProcessor,
|
|
10
10
|
getConfigGetParametersActionProcessor,
|
|
11
|
+
getUserDirectoryActionProcessor,
|
|
11
12
|
awsLambdaUtils,
|
|
12
13
|
DynamicModuleLoader,
|
|
13
14
|
} from 'quidproquo-actionprocessor-awslambda';
|
|
@@ -39,6 +40,7 @@ const ErrorTypeHttpResponseMap = {
|
|
|
39
40
|
[ErrorTypeEnum.Forbidden]: 403,
|
|
40
41
|
[ErrorTypeEnum.NotFound]: 404,
|
|
41
42
|
[ErrorTypeEnum.TimeOut]: 408,
|
|
43
|
+
[ErrorTypeEnum.Conflict]: 409,
|
|
42
44
|
[ErrorTypeEnum.UnsupportedMediaType]: 415,
|
|
43
45
|
[ErrorTypeEnum.OutOfResources]: 500,
|
|
44
46
|
[ErrorTypeEnum.GenericError]: 500,
|
|
@@ -68,6 +70,7 @@ export const getAPIGatewayEventExecutor = (
|
|
|
68
70
|
...getFileActionProcessor(cdkConfig.qpqConfig),
|
|
69
71
|
...getConfigActionProcessor(cdkConfig.qpqConfig),
|
|
70
72
|
...getQueueActionProcessor(cdkConfig.qpqConfig),
|
|
73
|
+
...getUserDirectoryActionProcessor(cdkConfig.qpqConfig),
|
|
71
74
|
|
|
72
75
|
...getCustomActionProcessors(cdkConfig.qpqConfig),
|
|
73
76
|
...qpqCustomActionProcessors(),
|
|
@@ -105,6 +108,8 @@ export const getAPIGatewayEventExecutor = (
|
|
|
105
108
|
headers: result.result.headers,
|
|
106
109
|
isBase64Encoded: result.result.isBase64Encoded,
|
|
107
110
|
};
|
|
111
|
+
|
|
112
|
+
console.log('Response: ', response);
|
|
108
113
|
return response;
|
|
109
114
|
}
|
|
110
115
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
getSystemActionProcessor,
|
|
6
6
|
getFileActionProcessor,
|
|
7
7
|
getQueueActionProcessor,
|
|
8
|
+
getUserDirectoryActionProcessor,
|
|
8
9
|
getConfigGetSecretActionProcessor,
|
|
9
10
|
getConfigGetParameterActionProcessor,
|
|
10
11
|
getConfigGetParametersActionProcessor,
|
|
@@ -56,6 +57,7 @@ export const getEventBridgeEventExecutor = (
|
|
|
56
57
|
...getConfigGetParametersActionProcessor(cdkConfig.qpqConfig),
|
|
57
58
|
...getConfigActionProcessor(cdkConfig.qpqConfig),
|
|
58
59
|
...getQueueActionProcessor(cdkConfig.qpqConfig),
|
|
60
|
+
...getUserDirectoryActionProcessor(cdkConfig.qpqConfig),
|
|
59
61
|
|
|
60
62
|
...getCustomActionProcessors(cdkConfig.qpqConfig),
|
|
61
63
|
...qpqCustomActionProcessors(),
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
getCloudFrontOriginRequestEventActionProcessor,
|
|
5
5
|
getSystemActionProcessor,
|
|
6
6
|
getFileActionProcessor,
|
|
7
|
+
getUserDirectoryActionProcessor,
|
|
7
8
|
getConfigGetSecretActionProcessor,
|
|
8
9
|
getConfigGetParameterActionProcessor,
|
|
9
10
|
getConfigGetParametersActionProcessor,
|
|
@@ -53,6 +54,9 @@ export const getOriginRequestEventExecutor = (
|
|
|
53
54
|
...getFileActionProcessor(cdkConfig.qpqConfig),
|
|
54
55
|
...getConfigActionProcessor(cdkConfig.qpqConfig),
|
|
55
56
|
|
|
57
|
+
// We probably don't want this?
|
|
58
|
+
...getUserDirectoryActionProcessor(cdkConfig.qpqConfig),
|
|
59
|
+
|
|
56
60
|
...getCustomActionProcessors(cdkConfig.qpqConfig),
|
|
57
61
|
...qpqCustomActionProcessors(),
|
|
58
62
|
};
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
getConfigGetSecretActionProcessor,
|
|
11
11
|
getConfigGetParameterActionProcessor,
|
|
12
12
|
getConfigGetParametersActionProcessor,
|
|
13
|
+
getUserDirectoryActionProcessor,
|
|
13
14
|
awsLambdaUtils,
|
|
14
15
|
DynamicModuleLoader,
|
|
15
16
|
} from 'quidproquo-actionprocessor-awslambda';
|
|
@@ -57,6 +58,7 @@ export const getStoryActionRuntime = async (
|
|
|
57
58
|
...getFileActionProcessor(cdkConfig.qpqConfig),
|
|
58
59
|
...getConfigActionProcessor(cdkConfig.qpqConfig),
|
|
59
60
|
...getQueueActionProcessor(cdkConfig.qpqConfig),
|
|
61
|
+
...getUserDirectoryActionProcessor(cdkConfig.qpqConfig),
|
|
60
62
|
|
|
61
63
|
...getCustomActionProcessors(cdkConfig.qpqConfig),
|
|
62
64
|
...qpqCustomActionProcessors(),
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
QpqCoreQueueConstruct,
|
|
11
11
|
QpqCoreSecretConstruct,
|
|
12
12
|
QpqWebserverDomainConstruct,
|
|
13
|
+
QpqCoreUserDirectoryConstruct,
|
|
13
14
|
} from '../constructs';
|
|
14
15
|
|
|
15
16
|
export interface InfQpqServiceStackProps extends QpqServiceStackProps {}
|
|
@@ -72,5 +73,16 @@ export class InfQpqServiceStack extends QpqServiceStack {
|
|
|
72
73
|
dnsConfig: setting,
|
|
73
74
|
}),
|
|
74
75
|
);
|
|
76
|
+
|
|
77
|
+
// User Directories
|
|
78
|
+
const userDirectories = qpqCoreUtils.getUserDirectories(props.qpqConfig).map(
|
|
79
|
+
(setting) =>
|
|
80
|
+
new QpqCoreUserDirectoryConstruct(this, qpqCoreUtils.getUniqueKeyForSetting(setting), {
|
|
81
|
+
awsAccountId: props.awsAccountId,
|
|
82
|
+
qpqConfig: props.qpqConfig,
|
|
83
|
+
|
|
84
|
+
userDirectoryConfig: setting,
|
|
85
|
+
}),
|
|
86
|
+
);
|
|
75
87
|
}
|
|
76
88
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Construct } from 'constructs';
|
|
2
|
+
import * as cdk from 'aws-cdk-lib';
|
|
2
3
|
|
|
3
4
|
import {
|
|
4
5
|
QPQCoreConfigSettingType,
|
|
@@ -10,7 +11,11 @@ import {
|
|
|
10
11
|
QueueQPQConfigSetting,
|
|
11
12
|
} from 'quidproquo-core';
|
|
12
13
|
|
|
13
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
ApiQPQWebServerConfigSetting,
|
|
16
|
+
QPQWebServerConfigSettingType,
|
|
17
|
+
qpqWebServerUtils,
|
|
18
|
+
} from 'quidproquo-webserver';
|
|
14
19
|
|
|
15
20
|
import {
|
|
16
21
|
QpqResource,
|
|
@@ -18,6 +23,7 @@ import {
|
|
|
18
23
|
QpqCoreSecretConstruct,
|
|
19
24
|
QpqCoreStorageDriveConstruct,
|
|
20
25
|
QpqCoreQueueConstruct,
|
|
26
|
+
QpqCoreUserDirectoryConstruct,
|
|
21
27
|
} from '../constructs';
|
|
22
28
|
|
|
23
29
|
export const getQqpSecretGrantables = (
|
|
@@ -124,6 +130,57 @@ export const getQqpQueueGrantables = (
|
|
|
124
130
|
return queueResources;
|
|
125
131
|
};
|
|
126
132
|
|
|
133
|
+
export const getQqpUserPoolGrantables = (
|
|
134
|
+
scope: Construct,
|
|
135
|
+
id: string,
|
|
136
|
+
qpqConfig: QPQConfig,
|
|
137
|
+
awsAccountId: string,
|
|
138
|
+
): QpqResource[] => {
|
|
139
|
+
const userDirectoryConfigs = qpqCoreUtils.getUserDirectories(qpqConfig);
|
|
140
|
+
|
|
141
|
+
const userDirectoryResources = userDirectoryConfigs.map((userDirectoryConfig) => {
|
|
142
|
+
return QpqCoreUserDirectoryConstruct.fromOtherStack(
|
|
143
|
+
scope,
|
|
144
|
+
`${id}-${qpqCoreUtils.getUniqueKeyForSetting(userDirectoryConfig)}-grantable`,
|
|
145
|
+
qpqConfig,
|
|
146
|
+
awsAccountId,
|
|
147
|
+
userDirectoryConfig.name,
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
return userDirectoryResources;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export const getQqpUserPoolGrantablesForApiConfig = (
|
|
155
|
+
scope: Construct,
|
|
156
|
+
id: string,
|
|
157
|
+
qpqConfig: QPQConfig,
|
|
158
|
+
awsAccountId: string,
|
|
159
|
+
config: ApiQPQWebServerConfigSetting,
|
|
160
|
+
): QpqResource[] => {
|
|
161
|
+
const routesWithAuth = qpqWebServerUtils
|
|
162
|
+
.getAllRoutesForApi(config.apiName, qpqConfig)
|
|
163
|
+
.filter(
|
|
164
|
+
(r) =>
|
|
165
|
+
r.options.routeAuthSettings?.userDirectoryName &&
|
|
166
|
+
(r.options.routeAuthSettings?.applicationName || r.options.routeAuthSettings?.serviceName),
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
const userDirectoryResources = routesWithAuth.map((route) => {
|
|
170
|
+
return QpqCoreUserDirectoryConstruct.fromOtherStack(
|
|
171
|
+
scope,
|
|
172
|
+
`${id}-${qpqCoreUtils.getUniqueKeyForSetting(route)}-grantable-xserver`,
|
|
173
|
+
qpqConfig,
|
|
174
|
+
awsAccountId,
|
|
175
|
+
route.options.routeAuthSettings?.userDirectoryName!,
|
|
176
|
+
route.options.routeAuthSettings?.serviceName,
|
|
177
|
+
route.options.routeAuthSettings?.applicationName,
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
return userDirectoryResources;
|
|
182
|
+
};
|
|
183
|
+
|
|
127
184
|
export const serviceNeedsServiceHostedZone = (qpqConfig: QPQConfig) => {
|
|
128
185
|
// We need it if we are deploying our api to a service domain
|
|
129
186
|
const apiConfigs = qpqCoreUtils
|
|
@@ -148,5 +205,37 @@ export const getQqpGrantableResources = (
|
|
|
148
205
|
...getQqpSecretGrantables(scope, id, qpqConfig, awsAccountId),
|
|
149
206
|
...getQqpStorageDriveGrantables(scope, id, qpqConfig, awsAccountId),
|
|
150
207
|
...getQqpQueueGrantables(scope, id, qpqConfig, awsAccountId),
|
|
208
|
+
...getQqpUserPoolGrantables(scope, id, qpqConfig, awsAccountId),
|
|
151
209
|
];
|
|
152
210
|
};
|
|
211
|
+
|
|
212
|
+
export const getQqpGrantableResourcesForApiConfig = (
|
|
213
|
+
scope: Construct,
|
|
214
|
+
id: string,
|
|
215
|
+
qpqConfig: QPQConfig,
|
|
216
|
+
awsAccountId: string,
|
|
217
|
+
config: ApiQPQWebServerConfigSetting,
|
|
218
|
+
): QpqResource[] => {
|
|
219
|
+
return [
|
|
220
|
+
// All the normal grantables
|
|
221
|
+
...getQqpGrantableResources(scope, id, qpqConfig, awsAccountId),
|
|
222
|
+
|
|
223
|
+
// Then special grantables just for this config.
|
|
224
|
+
...getQqpUserPoolGrantablesForApiConfig(scope, id, qpqConfig, awsAccountId, config),
|
|
225
|
+
];
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
export const exportStackValue = (
|
|
229
|
+
scope: Construct,
|
|
230
|
+
uniqueKey: string,
|
|
231
|
+
value: string,
|
|
232
|
+
): cdk.CfnOutput => {
|
|
233
|
+
return new cdk.CfnOutput(scope, uniqueKey, {
|
|
234
|
+
exportName: uniqueKey,
|
|
235
|
+
value,
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export const importStackValue = (uniqueKey: string): string => {
|
|
240
|
+
return cdk.Fn.importValue(uniqueKey);
|
|
241
|
+
};
|