@webiny/api-audit-logs 5.38.0-beta.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/LICENSE +21 -0
- package/README.md +1 -0
- package/app/app.d.ts +2 -0
- package/app/app.js +121 -0
- package/app/app.js.map +1 -0
- package/app/contants.d.ts +2 -0
- package/app/contants.js +12 -0
- package/app/contants.js.map +1 -0
- package/app/createAppModifier.d.ts +4 -0
- package/app/createAppModifier.js +14 -0
- package/app/createAppModifier.js.map +1 -0
- package/app/index.d.ts +4 -0
- package/app/index.js +43 -0
- package/app/index.js.map +1 -0
- package/app/types.d.ts +7 -0
- package/app/types.js +7 -0
- package/app/types.js.map +1 -0
- package/config.d.ts +12 -0
- package/config.js +285 -0
- package/config.js.map +1 -0
- package/index.d.ts +5 -0
- package/index.js +49 -0
- package/index.js.map +1 -0
- package/package.json +56 -0
- package/subscriptions/aco/folders.d.ts +4 -0
- package/subscriptions/aco/folders.js +94 -0
- package/subscriptions/aco/folders.js.map +1 -0
- package/subscriptions/aco/index.d.ts +2 -0
- package/subscriptions/aco/index.js +18 -0
- package/subscriptions/aco/index.js.map +1 -0
- package/subscriptions/apw/changeRequests.d.ts +4 -0
- package/subscriptions/apw/changeRequests.js +81 -0
- package/subscriptions/apw/changeRequests.js.map +1 -0
- package/subscriptions/apw/comments.d.ts +2 -0
- package/subscriptions/apw/comments.js +28 -0
- package/subscriptions/apw/comments.js.map +1 -0
- package/subscriptions/apw/contentReviews.d.ts +2 -0
- package/subscriptions/apw/contentReviews.js +28 -0
- package/subscriptions/apw/contentReviews.js.map +1 -0
- package/subscriptions/apw/index.d.ts +2 -0
- package/subscriptions/apw/index.js +26 -0
- package/subscriptions/apw/index.js.map +1 -0
- package/subscriptions/apw/workflows.d.ts +4 -0
- package/subscriptions/apw/workflows.js +64 -0
- package/subscriptions/apw/workflows.js.map +1 -0
- package/subscriptions/fileManager/files.d.ts +4 -0
- package/subscriptions/fileManager/files.js +64 -0
- package/subscriptions/fileManager/files.js.map +1 -0
- package/subscriptions/fileManager/index.d.ts +2 -0
- package/subscriptions/fileManager/index.js +17 -0
- package/subscriptions/fileManager/index.js.map +1 -0
- package/subscriptions/fileManager/settings.d.ts +2 -0
- package/subscriptions/fileManager/settings.js +32 -0
- package/subscriptions/fileManager/settings.js.map +1 -0
- package/subscriptions/formBuilder/formRevisions.d.ts +6 -0
- package/subscriptions/formBuilder/formRevisions.js +96 -0
- package/subscriptions/formBuilder/formRevisions.js.map +1 -0
- package/subscriptions/formBuilder/formSubmissions.d.ts +2 -0
- package/subscriptions/formBuilder/formSubmissions.js +28 -0
- package/subscriptions/formBuilder/formSubmissions.js.map +1 -0
- package/subscriptions/formBuilder/forms.d.ts +5 -0
- package/subscriptions/formBuilder/forms.js +76 -0
- package/subscriptions/formBuilder/forms.js.map +1 -0
- package/subscriptions/formBuilder/index.d.ts +2 -0
- package/subscriptions/formBuilder/index.js +26 -0
- package/subscriptions/formBuilder/index.js.map +1 -0
- package/subscriptions/formBuilder/settings.d.ts +2 -0
- package/subscriptions/formBuilder/settings.js +32 -0
- package/subscriptions/formBuilder/settings.js.map +1 -0
- package/subscriptions/headlessCms/entries.d.ts +8 -0
- package/subscriptions/headlessCms/entries.js +157 -0
- package/subscriptions/headlessCms/entries.js.map +1 -0
- package/subscriptions/headlessCms/groups.d.ts +4 -0
- package/subscriptions/headlessCms/groups.js +64 -0
- package/subscriptions/headlessCms/groups.js.map +1 -0
- package/subscriptions/headlessCms/index.d.ts +2 -0
- package/subscriptions/headlessCms/index.js +30 -0
- package/subscriptions/headlessCms/index.js.map +1 -0
- package/subscriptions/headlessCms/models.d.ts +4 -0
- package/subscriptions/headlessCms/models.js +64 -0
- package/subscriptions/headlessCms/models.js.map +1 -0
- package/subscriptions/headlessCms/utils/isSearchModelEntry.d.ts +1 -0
- package/subscriptions/headlessCms/utils/isSearchModelEntry.js +13 -0
- package/subscriptions/headlessCms/utils/isSearchModelEntry.js.map +1 -0
- package/subscriptions/i18n/index.d.ts +2 -0
- package/subscriptions/i18n/index.js +15 -0
- package/subscriptions/i18n/index.js.map +1 -0
- package/subscriptions/i18n/locales.d.ts +4 -0
- package/subscriptions/i18n/locales.js +64 -0
- package/subscriptions/i18n/locales.js.map +1 -0
- package/subscriptions/index.d.ts +2 -0
- package/subscriptions/index.js +29 -0
- package/subscriptions/index.js.map +1 -0
- package/subscriptions/mailer/index.d.ts +2 -0
- package/subscriptions/mailer/index.js +13 -0
- package/subscriptions/mailer/index.js.map +1 -0
- package/subscriptions/mailer/settings.d.ts +2 -0
- package/subscriptions/mailer/settings.js +32 -0
- package/subscriptions/mailer/settings.js.map +1 -0
- package/subscriptions/pageBuilder/blockCategories.d.ts +4 -0
- package/subscriptions/pageBuilder/blockCategories.js +64 -0
- package/subscriptions/pageBuilder/blockCategories.js.map +1 -0
- package/subscriptions/pageBuilder/blocks.d.ts +6 -0
- package/subscriptions/pageBuilder/blocks.js +96 -0
- package/subscriptions/pageBuilder/blocks.js.map +1 -0
- package/subscriptions/pageBuilder/categories.d.ts +4 -0
- package/subscriptions/pageBuilder/categories.js +64 -0
- package/subscriptions/pageBuilder/categories.js.map +1 -0
- package/subscriptions/pageBuilder/index.d.ts +2 -0
- package/subscriptions/pageBuilder/index.js +51 -0
- package/subscriptions/pageBuilder/index.js.map +1 -0
- package/subscriptions/pageBuilder/menus.d.ts +4 -0
- package/subscriptions/pageBuilder/menus.js +64 -0
- package/subscriptions/pageBuilder/menus.js.map +1 -0
- package/subscriptions/pageBuilder/pageElements.d.ts +4 -0
- package/subscriptions/pageBuilder/pageElements.js +64 -0
- package/subscriptions/pageBuilder/pageElements.js.map +1 -0
- package/subscriptions/pageBuilder/pageRevisions.d.ts +6 -0
- package/subscriptions/pageBuilder/pageRevisions.js +101 -0
- package/subscriptions/pageBuilder/pageRevisions.js.map +1 -0
- package/subscriptions/pageBuilder/pages.d.ts +4 -0
- package/subscriptions/pageBuilder/pages.js +60 -0
- package/subscriptions/pageBuilder/pages.js.map +1 -0
- package/subscriptions/pageBuilder/settings.d.ts +2 -0
- package/subscriptions/pageBuilder/settings.js +32 -0
- package/subscriptions/pageBuilder/settings.js.map +1 -0
- package/subscriptions/pageBuilder/templates.d.ts +6 -0
- package/subscriptions/pageBuilder/templates.js +96 -0
- package/subscriptions/pageBuilder/templates.js.map +1 -0
- package/subscriptions/security/apiKeys.d.ts +4 -0
- package/subscriptions/security/apiKeys.js +85 -0
- package/subscriptions/security/apiKeys.js.map +1 -0
- package/subscriptions/security/index.d.ts +2 -0
- package/subscriptions/security/index.js +27 -0
- package/subscriptions/security/index.js.map +1 -0
- package/subscriptions/security/roles.d.ts +4 -0
- package/subscriptions/security/roles.js +64 -0
- package/subscriptions/security/roles.js.map +1 -0
- package/subscriptions/security/teams.d.ts +4 -0
- package/subscriptions/security/teams.js +64 -0
- package/subscriptions/security/teams.js.map +1 -0
- package/subscriptions/security/users.d.ts +4 -0
- package/subscriptions/security/users.js +64 -0
- package/subscriptions/security/users.js.map +1 -0
- package/types.d.ts +58 -0
- package/types.js +18 -0
- package/types.js.map +1 -0
- package/utils/compressor.d.ts +11 -0
- package/utils/compressor.js +110 -0
- package/utils/compressor.js.map +1 -0
- package/utils/getAuditConfig.d.ts +33 -0
- package/utils/getAuditConfig.js +138 -0
- package/utils/getAuditConfig.js.map +1 -0
- package/utils/getAuditObject.d.ts +2 -0
- package/utils/getAuditObject.js +25 -0
- package/utils/getAuditObject.js.map +1 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.onTemplatesAfterImportHook = exports.onTemplatesAfterExportHook = exports.onTemplateAfterUpdateHook = exports.onTemplateAfterDeleteHook = exports.onTemplateAfterCreateHook = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _config = require("../../config");
|
|
10
|
+
var _getAuditConfig = require("../../utils/getAuditConfig");
|
|
11
|
+
const onTemplateAfterCreateHook = context => {
|
|
12
|
+
context.pageBuilder.onPageTemplateAfterCreate.subscribe(async ({
|
|
13
|
+
pageTemplate
|
|
14
|
+
}) => {
|
|
15
|
+
try {
|
|
16
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.PAGE_BUILDER.TEMPLATE.CREATE);
|
|
17
|
+
await createAuditLog("Template created", pageTemplate, pageTemplate.id, context);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw _error.default.from(error, {
|
|
20
|
+
message: "Error while executing onTemplateAfterCreateHook hook",
|
|
21
|
+
code: "AUDIT_LOGS_AFTER_TEMPLATE_CREATE_HOOK"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.onTemplateAfterCreateHook = onTemplateAfterCreateHook;
|
|
27
|
+
const onTemplateAfterUpdateHook = context => {
|
|
28
|
+
context.pageBuilder.onPageTemplateAfterUpdate.subscribe(async ({
|
|
29
|
+
pageTemplate,
|
|
30
|
+
original
|
|
31
|
+
}) => {
|
|
32
|
+
try {
|
|
33
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.PAGE_BUILDER.TEMPLATE.UPDATE);
|
|
34
|
+
await createAuditLog("Template updated", {
|
|
35
|
+
before: original,
|
|
36
|
+
after: pageTemplate
|
|
37
|
+
}, pageTemplate.id, context);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw _error.default.from(error, {
|
|
40
|
+
message: "Error while executing onTemplateAfterUpdateHook hook",
|
|
41
|
+
code: "AUDIT_LOGS_AFTER_TEMPLATE_UPDATE_HOOK"
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
exports.onTemplateAfterUpdateHook = onTemplateAfterUpdateHook;
|
|
47
|
+
const onTemplateAfterDeleteHook = context => {
|
|
48
|
+
context.pageBuilder.onPageTemplateAfterDelete.subscribe(async ({
|
|
49
|
+
pageTemplate
|
|
50
|
+
}) => {
|
|
51
|
+
try {
|
|
52
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.PAGE_BUILDER.TEMPLATE.DELETE);
|
|
53
|
+
await createAuditLog("Template deleted", pageTemplate, pageTemplate.id, context);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw _error.default.from(error, {
|
|
56
|
+
message: "Error while executing onTemplateAfterDeleteHook hook",
|
|
57
|
+
code: "AUDIT_LOGS_AFTER_TEMPLATE_DELETE_HOOK"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
exports.onTemplateAfterDeleteHook = onTemplateAfterDeleteHook;
|
|
63
|
+
const onTemplatesAfterExportHook = context => {
|
|
64
|
+
context.pageBuilder.templates.onTemplatesAfterExport.subscribe(async ({
|
|
65
|
+
params
|
|
66
|
+
}) => {
|
|
67
|
+
try {
|
|
68
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.PAGE_BUILDER.TEMPLATE.EXPORT);
|
|
69
|
+
await createAuditLog("Templates exported", params, "-", context);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw _error.default.from(error, {
|
|
72
|
+
message: "Error while executing onTemplatesAfterExportHook hook",
|
|
73
|
+
code: "AUDIT_LOGS_TEMPLATES_EXPORT_HOOK"
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
exports.onTemplatesAfterExportHook = onTemplatesAfterExportHook;
|
|
79
|
+
const onTemplatesAfterImportHook = context => {
|
|
80
|
+
context.pageBuilder.templates.onTemplatesAfterImport.subscribe(async ({
|
|
81
|
+
params
|
|
82
|
+
}) => {
|
|
83
|
+
try {
|
|
84
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.PAGE_BUILDER.TEMPLATE.IMPORT);
|
|
85
|
+
await createAuditLog("Templates imported", params, "-", context);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
throw _error.default.from(error, {
|
|
88
|
+
message: "Error while executing onTemplatesAfterImportHook hook",
|
|
89
|
+
code: "AUDIT_LOGS_TEMPLATES_IMPORT_HOOK"
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
exports.onTemplatesAfterImportHook = onTemplatesAfterImportHook;
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onTemplateAfterCreateHook","context","pageBuilder","onPageTemplateAfterCreate","subscribe","pageTemplate","createAuditLog","getAuditConfig","AUDIT","PAGE_BUILDER","TEMPLATE","CREATE","id","error","WebinyError","from","message","code","exports","onTemplateAfterUpdateHook","onPageTemplateAfterUpdate","original","UPDATE","before","after","onTemplateAfterDeleteHook","onPageTemplateAfterDelete","DELETE","onTemplatesAfterExportHook","templates","onTemplatesAfterExport","params","EXPORT","onTemplatesAfterImportHook","onTemplatesAfterImport","IMPORT"],"sources":["templates.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport { AuditLogsContext } from \"~/types\";\n\nexport const onTemplateAfterCreateHook = (context: AuditLogsContext) => {\n context.pageBuilder.onPageTemplateAfterCreate.subscribe(async ({ pageTemplate }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.PAGE_BUILDER.TEMPLATE.CREATE);\n\n await createAuditLog(\"Template created\", pageTemplate, pageTemplate.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onTemplateAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_TEMPLATE_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onTemplateAfterUpdateHook = (context: AuditLogsContext) => {\n context.pageBuilder.onPageTemplateAfterUpdate.subscribe(async ({ pageTemplate, original }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.PAGE_BUILDER.TEMPLATE.UPDATE);\n\n await createAuditLog(\n \"Template updated\",\n { before: original, after: pageTemplate },\n pageTemplate.id,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onTemplateAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_TEMPLATE_UPDATE_HOOK\"\n });\n }\n });\n};\n\nexport const onTemplateAfterDeleteHook = (context: AuditLogsContext) => {\n context.pageBuilder.onPageTemplateAfterDelete.subscribe(async ({ pageTemplate }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.PAGE_BUILDER.TEMPLATE.DELETE);\n\n await createAuditLog(\"Template deleted\", pageTemplate, pageTemplate.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onTemplateAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_TEMPLATE_DELETE_HOOK\"\n });\n }\n });\n};\n\nexport const onTemplatesAfterExportHook = (context: AuditLogsContext) => {\n context.pageBuilder.templates.onTemplatesAfterExport.subscribe(async ({ params }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.PAGE_BUILDER.TEMPLATE.EXPORT);\n\n await createAuditLog(\"Templates exported\", params, \"-\", context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onTemplatesAfterExportHook hook\",\n code: \"AUDIT_LOGS_TEMPLATES_EXPORT_HOOK\"\n });\n }\n });\n};\n\nexport const onTemplatesAfterImportHook = (context: AuditLogsContext) => {\n context.pageBuilder.templates.onTemplatesAfterImport.subscribe(async ({ params }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.PAGE_BUILDER.TEMPLATE.IMPORT);\n\n await createAuditLog(\"Templates imported\", params, \"-\", context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \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EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAU,0BAAA,GAAAA,0BAAA;AAEK,MAAMK,0BAA0B,GAAIhC,OAAyB,IAAK;EACrEA,OAAO,CAACC,WAAW,CAAC2B,SAAS,CAACK,sBAAsB,CAAC9B,SAAS,CAAC,OAAO;IAAE2B;EAAO,CAAC,KAAK;IACjF,IAAI;MACA,MAAMzB,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,QAAQ,CAACyB,MAAM,CAAC;MAEzE,MAAM7B,cAAc,CAAC,oBAAoB,EAAEyB,MAAM,EAAE,GAAG,EAAE9B,OAAO,CAAC;IACpE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,uDAAuD;QAChEC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAe,0BAAA,GAAAA,0BAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AuditLogsContext } from "../../types";
|
|
2
|
+
export declare const onApiKeyAfterCreateHook: (context: AuditLogsContext) => void;
|
|
3
|
+
export declare const onApiKeyAfterUpdateHook: (context: AuditLogsContext) => void;
|
|
4
|
+
export declare const onApiKeyAfterDeleteHook: (context: AuditLogsContext) => void;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.onApiKeyAfterUpdateHook = exports.onApiKeyAfterDeleteHook = exports.onApiKeyAfterCreateHook = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _config = require("../../config");
|
|
10
|
+
var _getAuditConfig = require("../../utils/getAuditConfig");
|
|
11
|
+
/**
|
|
12
|
+
* We need to remove the token from the API Key object, as it is a security risk.
|
|
13
|
+
*
|
|
14
|
+
* We assign the API Key object explicitly, so we do not miss any new properties that might be added in the future - and they should not be in the log.
|
|
15
|
+
*/
|
|
16
|
+
const cleanupApiKey = apiKey => {
|
|
17
|
+
return {
|
|
18
|
+
id: apiKey.id,
|
|
19
|
+
createdBy: apiKey.createdBy,
|
|
20
|
+
createdOn: apiKey.createdOn,
|
|
21
|
+
description: apiKey.description,
|
|
22
|
+
name: apiKey.name,
|
|
23
|
+
permissions: apiKey.permissions,
|
|
24
|
+
tenant: apiKey.tenant,
|
|
25
|
+
webinyVersion: apiKey.webinyVersion
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const onApiKeyAfterCreateHook = context => {
|
|
29
|
+
context.security.onApiKeyAfterCreate.subscribe(async ({
|
|
30
|
+
apiKey: initialApiKey
|
|
31
|
+
}) => {
|
|
32
|
+
try {
|
|
33
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.API_KEY.CREATE);
|
|
34
|
+
const apiKey = cleanupApiKey(initialApiKey);
|
|
35
|
+
await createAuditLog("API key created", apiKey, apiKey.id, context);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
throw _error.default.from(error, {
|
|
38
|
+
message: "Error while executing onApiKeyAfterCreateHook hook",
|
|
39
|
+
code: "AUDIT_LOGS_AFTER_API_KEY_CREATE_HOOK"
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
exports.onApiKeyAfterCreateHook = onApiKeyAfterCreateHook;
|
|
45
|
+
const onApiKeyAfterUpdateHook = context => {
|
|
46
|
+
context.security.onApiKeyAfterUpdate.subscribe(async ({
|
|
47
|
+
apiKey: initialApiKey,
|
|
48
|
+
original: initialOriginalApiKey
|
|
49
|
+
}) => {
|
|
50
|
+
try {
|
|
51
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.API_KEY.UPDATE);
|
|
52
|
+
const apiKey = cleanupApiKey(initialApiKey);
|
|
53
|
+
const original = cleanupApiKey(initialOriginalApiKey);
|
|
54
|
+
await createAuditLog("API key updated", {
|
|
55
|
+
before: original,
|
|
56
|
+
after: apiKey
|
|
57
|
+
}, apiKey.id, context);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
throw _error.default.from(error, {
|
|
60
|
+
message: "Error while executing onApiKeyAfterUpdateHook hook",
|
|
61
|
+
code: "AUDIT_LOGS_AFTER_API_KEY_UPDATE_HOOK"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
exports.onApiKeyAfterUpdateHook = onApiKeyAfterUpdateHook;
|
|
67
|
+
const onApiKeyAfterDeleteHook = context => {
|
|
68
|
+
context.security.onApiKeyAfterDelete.subscribe(async ({
|
|
69
|
+
apiKey: initialApiKey
|
|
70
|
+
}) => {
|
|
71
|
+
try {
|
|
72
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.API_KEY.DELETE);
|
|
73
|
+
const apiKey = cleanupApiKey(initialApiKey);
|
|
74
|
+
await createAuditLog("API key deleted", apiKey, apiKey.id, context);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
throw _error.default.from(error, {
|
|
77
|
+
message: "Error while executing onApiKeyAfterDeleteHook hook",
|
|
78
|
+
code: "AUDIT_LOGS_AFTER_API_KEY_DELETE_HOOK"
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
exports.onApiKeyAfterDeleteHook = onApiKeyAfterDeleteHook;
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=apiKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","cleanupApiKey","apiKey","id","createdBy","createdOn","description","name","permissions","tenant","webinyVersion","onApiKeyAfterCreateHook","context","security","onApiKeyAfterCreate","subscribe","initialApiKey","createAuditLog","getAuditConfig","AUDIT","SECURITY","API_KEY","CREATE","error","WebinyError","from","message","code","exports","onApiKeyAfterUpdateHook","onApiKeyAfterUpdate","original","initialOriginalApiKey","UPDATE","before","after","onApiKeyAfterDeleteHook","onApiKeyAfterDelete","DELETE"],"sources":["apiKeys.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport { AuditLogsContext } from \"~/types\";\nimport { ApiKey } from \"@webiny/api-security/types\";\n\n/**\n * We need to remove the token from the API Key object, as it is a security risk.\n *\n * We assign the API Key object explicitly, so we do not miss any new properties that might be added in the future - and they should not be in the log.\n */\nconst cleanupApiKey = (apiKey: ApiKey): Omit<ApiKey, \"token\"> => {\n return {\n id: apiKey.id,\n createdBy: apiKey.createdBy,\n createdOn: apiKey.createdOn,\n description: apiKey.description,\n name: apiKey.name,\n permissions: apiKey.permissions,\n tenant: apiKey.tenant,\n webinyVersion: apiKey.webinyVersion\n };\n};\n\nexport const onApiKeyAfterCreateHook = (context: AuditLogsContext) => {\n context.security.onApiKeyAfterCreate.subscribe(async ({ apiKey: initialApiKey }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.API_KEY.CREATE);\n\n const apiKey = cleanupApiKey(initialApiKey);\n\n await createAuditLog(\"API key created\", apiKey, apiKey.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onApiKeyAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_API_KEY_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onApiKeyAfterUpdateHook = (context: AuditLogsContext) => {\n context.security.onApiKeyAfterUpdate.subscribe(\n async ({ apiKey: initialApiKey, original: initialOriginalApiKey }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.API_KEY.UPDATE);\n\n const apiKey = cleanupApiKey(initialApiKey);\n const original = cleanupApiKey(initialOriginalApiKey);\n\n await createAuditLog(\n \"API key updated\",\n {\n before: original,\n after: apiKey\n },\n apiKey.id,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onApiKeyAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_API_KEY_UPDATE_HOOK\"\n });\n }\n }\n );\n};\n\nexport const onApiKeyAfterDeleteHook = (context: AuditLogsContext) => {\n context.security.onApiKeyAfterDelete.subscribe(async ({ apiKey: initialApiKey }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.API_KEY.DELETE);\n\n const apiKey = cleanupApiKey(initialApiKey);\n\n await createAuditLog(\"API key deleted\", apiKey, apiKey.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onApiKeyAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_API_KEY_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA,MAAMG,aAAa,GAAIC,MAAc,IAA4B;EAC7D,OAAO;IACHC,EAAE,EAAED,MAAM,CAACC,EAAE;IACbC,SAAS,EAAEF,MAAM,CAACE,SAAS;IAC3BC,SAAS,EAAEH,MAAM,CAACG,SAAS;IAC3BC,WAAW,EAAEJ,MAAM,CAACI,WAAW;IAC/BC,IAAI,EAAEL,MAAM,CAACK,IAAI;IACjBC,WAAW,EAAEN,MAAM,CAACM,WAAW;IAC/BC,MAAM,EAAEP,MAAM,CAACO,MAAM;IACrBC,aAAa,EAAER,MAAM,CAACQ;EAC1B,CAAC;AACL,CAAC;AAEM,MAAMC,uBAAuB,GAAIC,OAAyB,IAAK;EAClEA,OAAO,CAACC,QAAQ,CAACC,mBAAmB,CAACC,SAAS,CAAC,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AAC;AACL,CAAC;AAACC,OAAA,CAAAC,uBAAA,GAAAA,uBAAA;AAEK,MAAMO,uBAAuB,GAAIxB,OAAyB,IAAK;EAClEA,OAAO,CAACC,QAAQ,CAACwB,mBAAmB,CAACtB,SAAS,CAAC,OAAO;IAAEb,MAAM,EAAEc;EAAc,CAAC,KAAK;IAChF,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,OAAO,CAACiB,MAAM,CAAC;MAEpE,MAAMpC,MAAM,GAAGD,aAAa,CAACe,aAAa,CAAC;MAE3C,MAAMC,cAAc,CAAC,iBAAiB,EAAEf,MAAM,EAAEA,MAAM,CAACC,EAAE,EAAES,OAAO,CAAC;IACvE,CAAC,CAAC,OAAOW,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,oDAAoD;QAC7DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAQ,uBAAA,GAAAA,uBAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createSecurityHooks = void 0;
|
|
7
|
+
var _apiKeys = require("./apiKeys");
|
|
8
|
+
var _roles = require("./roles");
|
|
9
|
+
var _teams = require("./teams");
|
|
10
|
+
var _users = require("./users");
|
|
11
|
+
const createSecurityHooks = context => {
|
|
12
|
+
(0, _apiKeys.onApiKeyAfterCreateHook)(context);
|
|
13
|
+
(0, _apiKeys.onApiKeyAfterUpdateHook)(context);
|
|
14
|
+
(0, _apiKeys.onApiKeyAfterDeleteHook)(context);
|
|
15
|
+
(0, _roles.onRoleAfterCreateHook)(context);
|
|
16
|
+
(0, _roles.onRoleAfterUpdateHook)(context);
|
|
17
|
+
(0, _roles.onRoleAfterDeleteHook)(context);
|
|
18
|
+
(0, _teams.onTeamAfterCreateHook)(context);
|
|
19
|
+
(0, _teams.onTeamAfterUpdateHook)(context);
|
|
20
|
+
(0, _teams.onTeamAfterDeleteHook)(context);
|
|
21
|
+
(0, _users.onUserAfterCreateHook)(context);
|
|
22
|
+
(0, _users.onUserAfterUpdateHook)(context);
|
|
23
|
+
(0, _users.onUserAfterDeleteHook)(context);
|
|
24
|
+
};
|
|
25
|
+
exports.createSecurityHooks = createSecurityHooks;
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_apiKeys","require","_roles","_teams","_users","createSecurityHooks","context","onApiKeyAfterCreateHook","onApiKeyAfterUpdateHook","onApiKeyAfterDeleteHook","onRoleAfterCreateHook","onRoleAfterUpdateHook","onRoleAfterDeleteHook","onTeamAfterCreateHook","onTeamAfterUpdateHook","onTeamAfterDeleteHook","onUserAfterCreateHook","onUserAfterUpdateHook","onUserAfterDeleteHook","exports"],"sources":["index.ts"],"sourcesContent":["import {\n onApiKeyAfterCreateHook,\n onApiKeyAfterUpdateHook,\n onApiKeyAfterDeleteHook\n} from \"./apiKeys\";\nimport { onRoleAfterCreateHook, onRoleAfterUpdateHook, onRoleAfterDeleteHook } from \"./roles\";\nimport { onTeamAfterCreateHook, onTeamAfterUpdateHook, onTeamAfterDeleteHook } from \"./teams\";\nimport { onUserAfterCreateHook, onUserAfterUpdateHook, onUserAfterDeleteHook } from \"./users\";\n\nimport { AuditLogsContext } from \"~/types\";\n\nexport const createSecurityHooks = (context: AuditLogsContext) => {\n onApiKeyAfterCreateHook(context);\n onApiKeyAfterUpdateHook(context);\n onApiKeyAfterDeleteHook(context);\n onRoleAfterCreateHook(context);\n onRoleAfterUpdateHook(context);\n onRoleAfterDeleteHook(context);\n onTeamAfterCreateHook(context);\n onTeamAfterUpdateHook(context);\n onTeamAfterDeleteHook(context);\n onUserAfterCreateHook(context);\n onUserAfterUpdateHook(context);\n onUserAfterDeleteHook(context);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAIO,MAAMI,mBAAmB,GAAIC,OAAyB,IAAK;EAC9D,IAAAC,gCAAuB,EAACD,OAAO,CAAC;EAChC,IAAAE,gCAAuB,EAACF,OAAO,CAAC;EAChC,IAAAG,gCAAuB,EAACH,OAAO,CAAC;EAChC,IAAAI,4BAAqB,EAACJ,OAAO,CAAC;EAC9B,IAAAK,4BAAqB,EAACL,OAAO,CAAC;EAC9B,IAAAM,4BAAqB,EAACN,OAAO,CAAC;EAC9B,IAAAO,4BAAqB,EAACP,OAAO,CAAC;EAC9B,IAAAQ,4BAAqB,EAACR,OAAO,CAAC;EAC9B,IAAAS,4BAAqB,EAACT,OAAO,CAAC;EAC9B,IAAAU,4BAAqB,EAACV,OAAO,CAAC;EAC9B,IAAAW,4BAAqB,EAACX,OAAO,CAAC;EAC9B,IAAAY,4BAAqB,EAACZ,OAAO,CAAC;AAClC,CAAC;AAACa,OAAA,CAAAd,mBAAA,GAAAA,mBAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AuditLogsContext } from "../../types";
|
|
2
|
+
export declare const onRoleAfterCreateHook: (context: AuditLogsContext) => void;
|
|
3
|
+
export declare const onRoleAfterUpdateHook: (context: AuditLogsContext) => void;
|
|
4
|
+
export declare const onRoleAfterDeleteHook: (context: AuditLogsContext) => void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.onRoleAfterUpdateHook = exports.onRoleAfterDeleteHook = exports.onRoleAfterCreateHook = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _config = require("../../config");
|
|
10
|
+
var _getAuditConfig = require("../../utils/getAuditConfig");
|
|
11
|
+
const onRoleAfterCreateHook = context => {
|
|
12
|
+
context.security.onGroupAfterCreate.subscribe(async ({
|
|
13
|
+
group
|
|
14
|
+
}) => {
|
|
15
|
+
try {
|
|
16
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.ROLE.CREATE);
|
|
17
|
+
await createAuditLog("Role created", group, group.id, context);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw _error.default.from(error, {
|
|
20
|
+
message: "Error while executing onRoleAfterCreateHook hook",
|
|
21
|
+
code: "AUDIT_LOGS_AFTER_ROLE_CREATE_HOOK"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.onRoleAfterCreateHook = onRoleAfterCreateHook;
|
|
27
|
+
const onRoleAfterUpdateHook = context => {
|
|
28
|
+
context.security.onGroupAfterUpdate.subscribe(async ({
|
|
29
|
+
group,
|
|
30
|
+
original
|
|
31
|
+
}) => {
|
|
32
|
+
try {
|
|
33
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.ROLE.UPDATE);
|
|
34
|
+
await createAuditLog("Role updated", {
|
|
35
|
+
before: original,
|
|
36
|
+
after: group
|
|
37
|
+
}, group.id, context);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw _error.default.from(error, {
|
|
40
|
+
message: "Error while executing onRoleAfterUpdateHook hook",
|
|
41
|
+
code: "AUDIT_LOGS_AFTER_ROLE_UPDATE_HOOK"
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
exports.onRoleAfterUpdateHook = onRoleAfterUpdateHook;
|
|
47
|
+
const onRoleAfterDeleteHook = context => {
|
|
48
|
+
context.security.onGroupAfterDelete.subscribe(async ({
|
|
49
|
+
group
|
|
50
|
+
}) => {
|
|
51
|
+
try {
|
|
52
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.ROLE.DELETE);
|
|
53
|
+
await createAuditLog("Role deleted", group, group.id, context);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw _error.default.from(error, {
|
|
56
|
+
message: "Error while executing onRoleAfterDeleteHook hook",
|
|
57
|
+
code: "AUDIT_LOGS_AFTER_ROLE_DELETE_HOOK"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
exports.onRoleAfterDeleteHook = onRoleAfterDeleteHook;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onRoleAfterCreateHook","context","security","onGroupAfterCreate","subscribe","group","createAuditLog","getAuditConfig","AUDIT","SECURITY","ROLE","CREATE","id","error","WebinyError","from","message","code","exports","onRoleAfterUpdateHook","onGroupAfterUpdate","original","UPDATE","before","after","onRoleAfterDeleteHook","onGroupAfterDelete","DELETE"],"sources":["roles.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport { AuditLogsContext } from \"~/types\";\n\nexport const onRoleAfterCreateHook = (context: AuditLogsContext) => {\n context.security.onGroupAfterCreate.subscribe(async ({ group }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.ROLE.CREATE);\n\n await createAuditLog(\"Role created\", group, group.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onRoleAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_ROLE_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onRoleAfterUpdateHook = (context: AuditLogsContext) => {\n context.security.onGroupAfterUpdate.subscribe(async ({ group, original }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.ROLE.UPDATE);\n\n await createAuditLog(\n \"Role updated\",\n { before: original, after: group },\n group.id,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onRoleAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_ROLE_UPDATE_HOOK\"\n });\n }\n });\n};\n\nexport const onRoleAfterDeleteHook = (context: AuditLogsContext) => {\n context.security.onGroupAfterDelete.subscribe(async ({ group }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.ROLE.DELETE);\n\n await createAuditLog(\"Role deleted\", group, group.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onRoleAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_ROLE_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,qBAAqB,GAAIC,OAAyB,IAAK;EAChEA,OAAO,CAACC,QAAQ,CAACC,kBAAkB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IAC/D,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACC,MAAM,CAAC;MAEjE,MAAML,cAAc,CAAC,cAAc,EAAED,KAAK,EAAEA,KAAK,CAACO,EAAE,EAAEX,OAAO,CAAC;IAClE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAlB,qBAAA,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
|
|
1
|
+
import { AuditLogsContext } from "../../types";
|
|
2
|
+
export declare const onTeamAfterCreateHook: (context: AuditLogsContext) => void;
|
|
3
|
+
export declare const onTeamAfterUpdateHook: (context: AuditLogsContext) => void;
|
|
4
|
+
export declare const onTeamAfterDeleteHook: (context: AuditLogsContext) => void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.onTeamAfterUpdateHook = exports.onTeamAfterDeleteHook = exports.onTeamAfterCreateHook = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _config = require("../../config");
|
|
10
|
+
var _getAuditConfig = require("../../utils/getAuditConfig");
|
|
11
|
+
const onTeamAfterCreateHook = context => {
|
|
12
|
+
context.security.onTeamAfterCreate.subscribe(async ({
|
|
13
|
+
team
|
|
14
|
+
}) => {
|
|
15
|
+
try {
|
|
16
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.TEAM.CREATE);
|
|
17
|
+
await createAuditLog("Team created", team, team.id, context);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw _error.default.from(error, {
|
|
20
|
+
message: "Error while executing onTeamAfterCreateHook hook",
|
|
21
|
+
code: "AUDIT_LOGS_AFTER_TEAM_CREATE_HOOK"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.onTeamAfterCreateHook = onTeamAfterCreateHook;
|
|
27
|
+
const onTeamAfterUpdateHook = context => {
|
|
28
|
+
context.security.onTeamAfterUpdate.subscribe(async ({
|
|
29
|
+
team,
|
|
30
|
+
original
|
|
31
|
+
}) => {
|
|
32
|
+
try {
|
|
33
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.TEAM.UPDATE);
|
|
34
|
+
await createAuditLog("Team updated", {
|
|
35
|
+
before: original,
|
|
36
|
+
after: team
|
|
37
|
+
}, team.id, context);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw _error.default.from(error, {
|
|
40
|
+
message: "Error while executing onTeamAfterUpdateHook hook",
|
|
41
|
+
code: "AUDIT_LOGS_AFTER_TEAM_UPDATE_HOOK"
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
exports.onTeamAfterUpdateHook = onTeamAfterUpdateHook;
|
|
47
|
+
const onTeamAfterDeleteHook = context => {
|
|
48
|
+
context.security.onTeamAfterDelete.subscribe(async ({
|
|
49
|
+
team
|
|
50
|
+
}) => {
|
|
51
|
+
try {
|
|
52
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.TEAM.DELETE);
|
|
53
|
+
await createAuditLog("Team deleted", team, team.id, context);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw _error.default.from(error, {
|
|
56
|
+
message: "Error while executing onTeamAfterDeleteHook hook",
|
|
57
|
+
code: "AUDIT_LOGS_AFTER_TEAM_DELETE_HOOK"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
exports.onTeamAfterDeleteHook = onTeamAfterDeleteHook;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=teams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onTeamAfterCreateHook","context","security","onTeamAfterCreate","subscribe","team","createAuditLog","getAuditConfig","AUDIT","SECURITY","TEAM","CREATE","id","error","WebinyError","from","message","code","exports","onTeamAfterUpdateHook","onTeamAfterUpdate","original","UPDATE","before","after","onTeamAfterDeleteHook","onTeamAfterDelete","DELETE"],"sources":["teams.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport { AuditLogsContext } from \"~/types\";\n\nexport const onTeamAfterCreateHook = (context: AuditLogsContext) => {\n context.security.onTeamAfterCreate.subscribe(async ({ team }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.TEAM.CREATE);\n\n await createAuditLog(\"Team created\", team, team.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onTeamAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_TEAM_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onTeamAfterUpdateHook = (context: AuditLogsContext) => {\n context.security.onTeamAfterUpdate.subscribe(async ({ team, original }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.TEAM.UPDATE);\n\n await createAuditLog(\n \"Team updated\",\n { before: original, after: team },\n team.id,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onTeamAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_TEAM_UPDATE_HOOK\"\n });\n }\n });\n};\n\nexport const onTeamAfterDeleteHook = (context: AuditLogsContext) => {\n context.security.onTeamAfterDelete.subscribe(async ({ team }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.TEAM.DELETE);\n\n await createAuditLog(\"Team deleted\", team, team.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onTeamAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_TEAM_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,qBAAqB,GAAIC,OAAyB,IAAK;EAChEA,OAAO,CAACC,QAAQ,CAACC,iBAAiB,CAACC,SAAS,CAAC,OAAO;IAAEC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cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACiB,MAAM,CAAC;MAEjE,MAAMrB,cAAc,CAAC,cAAc,EAAED,IAAI,EAAEA,IAAI,CAACO,EAAE,EAAEX,OAAO,CAAC;IAChE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAO,qBAAA,GAAAA,qBAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AuditLogsContext } from "../../types";
|
|
2
|
+
export declare const onUserAfterCreateHook: (context: AuditLogsContext) => void;
|
|
3
|
+
export declare const onUserAfterUpdateHook: (context: AuditLogsContext) => void;
|
|
4
|
+
export declare const onUserAfterDeleteHook: (context: AuditLogsContext) => void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.onUserAfterUpdateHook = exports.onUserAfterDeleteHook = exports.onUserAfterCreateHook = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _config = require("../../config");
|
|
10
|
+
var _getAuditConfig = require("../../utils/getAuditConfig");
|
|
11
|
+
const onUserAfterCreateHook = context => {
|
|
12
|
+
context.adminUsers.onUserAfterCreate.subscribe(async ({
|
|
13
|
+
user
|
|
14
|
+
}) => {
|
|
15
|
+
try {
|
|
16
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.USER.CREATE);
|
|
17
|
+
await createAuditLog("User created", user, user.id, context);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw _error.default.from(error, {
|
|
20
|
+
message: "Error while executing onUserAfterCreateHook hook",
|
|
21
|
+
code: "AUDIT_LOGS_AFTER_USER_CREATE_HOOK"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.onUserAfterCreateHook = onUserAfterCreateHook;
|
|
27
|
+
const onUserAfterUpdateHook = context => {
|
|
28
|
+
context.adminUsers.onUserAfterUpdate.subscribe(async ({
|
|
29
|
+
updatedUser,
|
|
30
|
+
originalUser
|
|
31
|
+
}) => {
|
|
32
|
+
try {
|
|
33
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.USER.UPDATE);
|
|
34
|
+
await createAuditLog("User updated", {
|
|
35
|
+
before: originalUser,
|
|
36
|
+
after: updatedUser
|
|
37
|
+
}, updatedUser.id, context);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw _error.default.from(error, {
|
|
40
|
+
message: "Error while executing onUserAfterUpdateHook hook",
|
|
41
|
+
code: "AUDIT_LOGS_AFTER_USER_UPDATE_HOOK"
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
exports.onUserAfterUpdateHook = onUserAfterUpdateHook;
|
|
47
|
+
const onUserAfterDeleteHook = context => {
|
|
48
|
+
context.adminUsers.onUserAfterDelete.subscribe(async ({
|
|
49
|
+
user
|
|
50
|
+
}) => {
|
|
51
|
+
try {
|
|
52
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.USER.DELETE);
|
|
53
|
+
await createAuditLog("User deleted", user, user.id, context);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw _error.default.from(error, {
|
|
56
|
+
message: "Error while executing onUserAfterDeleteHook hook",
|
|
57
|
+
code: "AUDIT_LOGS_AFTER_USER_DELETE_HOOK"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
exports.onUserAfterDeleteHook = onUserAfterDeleteHook;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=users.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onUserAfterCreateHook","context","adminUsers","onUserAfterCreate","subscribe","user","createAuditLog","getAuditConfig","AUDIT","SECURITY","USER","CREATE","id","error","WebinyError","from","message","code","exports","onUserAfterUpdateHook","onUserAfterUpdate","updatedUser","originalUser","UPDATE","before","after","onUserAfterDeleteHook","onUserAfterDelete","DELETE"],"sources":["users.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport { AuditLogsContext } from \"~/types\";\n\nexport const onUserAfterCreateHook = (context: AuditLogsContext) => {\n context.adminUsers.onUserAfterCreate.subscribe(async ({ user }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.USER.CREATE);\n\n await createAuditLog(\"User created\", user, user.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onUserAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_USER_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onUserAfterUpdateHook = (context: AuditLogsContext) => {\n context.adminUsers.onUserAfterUpdate.subscribe(async ({ updatedUser, originalUser }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.USER.UPDATE);\n\n await createAuditLog(\n \"User updated\",\n { before: originalUser, after: updatedUser },\n updatedUser.id,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onUserAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_USER_UPDATE_HOOK\"\n });\n }\n });\n};\n\nexport const onUserAfterDeleteHook = (context: AuditLogsContext) => {\n context.adminUsers.onUserAfterDelete.subscribe(async ({ user }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.USER.DELETE);\n\n await createAuditLog(\"User deleted\", user, user.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onUserAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_USER_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,qBAAqB,GAAIC,OAAyB,IAAK;EAChEA,OAAO,CAACC,UAAU,CAACC,iBAAiB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAC/D,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACC,MAAM,CAAC;MAEjE,MAAML,cAAc,CAAC,cAAc,EAAED,IAAI,EAAEA,IAAI,CAACO,EAAE,EAAEX,OAAO,CAAC;IAChE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAlB,qBAAA,GAAAA,qBAAA;AAEK,MAAMmB,qBAAqB,GAAIlB,OAAyB,IAAK;EAChEA,OAAO,CAACC,UAAU,CAACkB,iBAAiB,CAAChB,SAAS,CAAC,OAAO;IAAEiB,WAAW;IAAEC;EAAa,CAAC,KAAK;IACpF,IAAI;MACA,MAAMhB,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACa,MAAM,CAAC;MAEjE,MAAMjB,cAAc,CAChB,cAAc,EACd;QAAEkB,MAAM,EAAEF,YAAY;QAAEG,KAAK,EAAEJ;MAAY,CAAC,EAC5CA,WAAW,CAACT,EAAE,EACdX,OACJ,CAAC;IACL,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAEK,MAAMO,qBAAqB,GAAIzB,OAAyB,IAAK;EAChEA,OAAO,CAACC,UAAU,CAACyB,iBAAiB,CAACvB,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAC/D,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACkB,MAAM,CAAC;MAEjE,MAAMtB,cAAc,CAAC,cAAc,EAAED,IAAI,EAAEA,IAAI,CAACO,EAAE,EAAEX,OAAO,CAAC;IAChE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAQ,qBAAA,GAAAA,qBAAA"}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { PbContext } from "@webiny/api-page-builder/graphql/types";
|
|
2
|
+
import { FormBuilderContext } from "@webiny/api-form-builder/types";
|
|
3
|
+
import { AcoContext } from "@webiny/api-aco/types";
|
|
4
|
+
import { MailerContext } from "@webiny/api-mailer/types";
|
|
5
|
+
import { SecurityContext } from "@webiny/api-security/types";
|
|
6
|
+
import { PbImportExportContext } from "@webiny/api-page-builder-import-export/graphql/types";
|
|
7
|
+
import { ApwContext } from "@webiny/api-apw/types";
|
|
8
|
+
import { Context as BaseContext } from "@webiny/handler/types";
|
|
9
|
+
export * from "./app/types";
|
|
10
|
+
export interface Action {
|
|
11
|
+
type: string;
|
|
12
|
+
displayName: string;
|
|
13
|
+
/**
|
|
14
|
+
* Delay in seconds before a new audit log can be created.
|
|
15
|
+
* During this delay actions will update existing audit log instead of creating new ones.
|
|
16
|
+
*/
|
|
17
|
+
newEntryDelay?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface Entity {
|
|
20
|
+
type: string;
|
|
21
|
+
displayName: string;
|
|
22
|
+
linkToEntity?: (id: string) => string;
|
|
23
|
+
actions: Action[];
|
|
24
|
+
}
|
|
25
|
+
export interface App {
|
|
26
|
+
app: string;
|
|
27
|
+
displayName: string;
|
|
28
|
+
entities: Entity[];
|
|
29
|
+
}
|
|
30
|
+
export interface AuditLog {
|
|
31
|
+
id: string;
|
|
32
|
+
message: string;
|
|
33
|
+
app: string;
|
|
34
|
+
entity: string;
|
|
35
|
+
entityId: string;
|
|
36
|
+
action: string;
|
|
37
|
+
data: JSON;
|
|
38
|
+
timestamp: Date;
|
|
39
|
+
initiator: string;
|
|
40
|
+
}
|
|
41
|
+
export interface AuditLogsContext extends BaseContext, PbContext, FormBuilderContext, AcoContext, MailerContext, SecurityContext, ApwContext {
|
|
42
|
+
pageBuilder: PbImportExportContext["pageBuilder"];
|
|
43
|
+
formBuilder: PbImportExportContext["formBuilder"];
|
|
44
|
+
}
|
|
45
|
+
export interface AuditObject {
|
|
46
|
+
[app: string]: EntityObject;
|
|
47
|
+
}
|
|
48
|
+
export interface EntityObject {
|
|
49
|
+
[entity: string]: ActionObject;
|
|
50
|
+
}
|
|
51
|
+
export interface ActionObject {
|
|
52
|
+
[action: string]: AuditAction;
|
|
53
|
+
}
|
|
54
|
+
export interface AuditAction {
|
|
55
|
+
app: App;
|
|
56
|
+
entity: Entity;
|
|
57
|
+
action: Action;
|
|
58
|
+
}
|
package/types.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _types = require("./app/types");
|
|
7
|
+
Object.keys(_types).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _types[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_types","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["types.ts"],"sourcesContent":["import { PbContext } from \"@webiny/api-page-builder/graphql/types\";\nimport { FormBuilderContext } from \"@webiny/api-form-builder/types\";\nimport { AcoContext } from \"@webiny/api-aco/types\";\nimport { MailerContext } from \"@webiny/api-mailer/types\";\nimport { SecurityContext } from \"@webiny/api-security/types\";\nimport { PbImportExportContext } from \"@webiny/api-page-builder-import-export/graphql/types\";\nimport { ApwContext } from \"@webiny/api-apw/types\";\nimport { Context as BaseContext } from \"@webiny/handler/types\";\n\nexport * from \"~/app/types\";\n\nexport interface Action {\n type: string;\n displayName: string;\n /**\n * Delay in seconds before a new audit log can be created.\n * During this delay actions will update existing audit log instead of creating new ones.\n */\n newEntryDelay?: number;\n}\n\nexport interface Entity {\n type: string;\n displayName: string;\n linkToEntity?: (id: string) => string;\n actions: Action[];\n}\n\nexport interface App {\n app: string;\n displayName: string;\n entities: Entity[];\n}\n\nexport interface AuditLog {\n id: string;\n message: string;\n app: string;\n entity: string;\n entityId: string;\n action: string;\n data: JSON;\n timestamp: Date;\n initiator: string;\n}\n\nexport interface AuditLogsContext\n extends BaseContext,\n PbContext,\n FormBuilderContext,\n AcoContext,\n MailerContext,\n SecurityContext,\n ApwContext {\n pageBuilder: PbImportExportContext[\"pageBuilder\"];\n formBuilder: PbImportExportContext[\"formBuilder\"];\n}\n\nexport interface AuditObject {\n [app: string]: EntityObject;\n}\n\nexport interface EntityObject {\n [entity: string]: ActionObject;\n}\n\nexport interface ActionObject {\n [action: string]: AuditAction;\n}\n\nexport interface AuditAction {\n app: App;\n entity: Entity;\n action: Action;\n}\n"],"mappings":";;;;;AASA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface OriginalData {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}
|
|
4
|
+
export interface Compressor {
|
|
5
|
+
canCompress(data: any): boolean;
|
|
6
|
+
compress(data: any): Promise<string>;
|
|
7
|
+
canDecompress(data: string): boolean;
|
|
8
|
+
decompress(data: string): Promise<OriginalData | null>;
|
|
9
|
+
}
|
|
10
|
+
declare const compressor: Pick<Compressor, "compress" | "decompress">;
|
|
11
|
+
export { compressor };
|