@mondaydotcomorg/monday-authorization 1.2.9 → 1.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## [1.2.9] - 2024-10-06
9
+ ### Added
10
+ - [`authz/bashanye/add-async-resource-attributes-support`](https://github.com/DaPulse/monday-npm-packages/pull/6859)
11
+ - `AuthorizationAttributesService` - now supports async upsert and delete - requests sent through SNS-SQS).
12
+
8
13
  ## [1.2.3] - 2024-06-10
9
14
  ### Added
10
15
 
package/README.md CHANGED
@@ -138,7 +138,10 @@ const canActionInScopeMultipleResponse: ScopedActionResponseObject[] =
138
138
  ```
139
139
 
140
140
  ### Authorization Attributes API
141
+ Authorization attributes have 2 options to get called: sync (http request) and async (send to SNS and consumed asynchronously).
142
+ When you have to make sure the change in the attributes applied before the function return, please use the sync method, otherwise use the async
141
143
 
144
+ #### Sync method
142
145
  Use `AuthorizationAttributesService.upsertResourceAttributesSync` to upsert multiple resource attributes in the authorization MS synchronously.
143
146
 
144
147
  ```ts
@@ -168,3 +171,25 @@ const attributeKeys: string[] = ['is_default_workspace', 'workspace_kind'];
168
171
  const response: ResourceAttributeResponse = await AuthorizationAttributesService.deleteResourceAttributesSync(accountId, userId, resource, attributeKeys);
169
172
  ```
170
173
 
174
+ #### Async method
175
+ use `AuthorizationAttributesService.updateResourceAttributesAsync` to upsert or delete multiple resource attributes at once.
176
+
177
+ ```ts
178
+ import { AuthorizationAttributesService, ResourceAttributeAssignment, ResourceAttributeResponse } from '@mondaydotcomorg/monday-authorization';
179
+
180
+ const accountId = 739630;
181
+ const appName = process.env.APP_NAME;
182
+ const callerActionIdentifier = "actions_v2";
183
+ const resourceAttributeOperations: ResourceAttributesOperation[] = [
184
+ { operationType: 'upsert', resourceId: 18, resourceType: 'workspace', key: 'is_default_workspace', value: 'true' },
185
+ { operationType: 'delete', resourceId: 23, resourceType: 'board', key: 'board_kind' }
186
+ ];
187
+
188
+ const response: ResourceAttributeResponse = await AuthorizationAttributesService.updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, resourceAttributeOperations);
189
+ ```
190
+
191
+ Special notes for asynchronous operations:
192
+ 1. There is no guarantee about the order of the updates, so don't do multiple operations on the same key in the same resource.
193
+ 2. To update an existing key, just use upsert operation, it'll override previous value.
194
+ 3. Requests with a lot of operations might split to chunks that will be consumed either sequence or in parallel, so there might be a timeframe where some of the operations already applied and some not. Eventually all of them will be applied.
195
+ 4. If your MS depends on the access to the asynchronous operation, you can use a health check operation `asyncResourceAttributesHealthCheck` that will return false if it can't reach to SNS or can't find the required topic. Note it doesn't check write permissions so make sure your MS have permissions to write to the SNS topic.
@@ -1,6 +1,7 @@
1
- import { ResourceAttributeAssignment, ResourceAttributeResponse } from './types/authorization-attributes-contracts';
1
+ import { ResourceAttributeAssignment, ResourceAttributeResponse, ResourceAttributesOperation } from './types/authorization-attributes-contracts';
2
2
  import { Resource } from './types/general';
3
3
  export declare class AuthorizationAttributesService {
4
+ private static LOG_TAG;
4
5
  /**
5
6
  * Upsert resource attributes synchronously, performing http call to the authorization MS to assign the given attributes to the given resource.
6
7
  * @param accountId
@@ -19,5 +20,25 @@ export declare class AuthorizationAttributesService {
19
20
  * @returns ResourceAttributeResponse - The affected (deleted) resource attributes assignments in the `attributes` field.
20
21
  */
21
22
  static deleteResourceAttributes(accountId: number, userId: number, resource: Resource, attributeKeys: string[]): Promise<ResourceAttributeResponse>;
23
+ /**
24
+ * Async function, this function only send the updates request to SNS and return before the change actually took place
25
+ * @param accountId
26
+ * @param appName - App name of the calling app
27
+ * @param callerActionIdentifier - action identifier
28
+ * @param resourceAttributeOperations - Array of operations to do on resource attributes.
29
+ * @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
30
+ * */
31
+ static updateResourceAttributesAsync(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperations: ResourceAttributesOperation[]): Promise<ResourceAttributesOperation[]>;
32
+ private static sendSingleSnsMessage;
33
+ private static getSnsTopicArn;
22
34
  private static getResourceAttributesUrl;
35
+ /**
36
+ * Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
37
+ * This function can be used as health check for services that updating resource attributes in async is crucial.
38
+ * Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
39
+ * errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
40
+ * However, this is the best we can do without actually push dummy messages to the SNS.
41
+ * @return {Promise<boolean>} - true if succeeded
42
+ */
43
+ static asyncResourceAttributesHealthCheck(): Promise<boolean>;
23
44
  }
@@ -8,11 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.AuthorizationAttributesService = void 0;
16
+ const chunk_1 = __importDefault(require("lodash/chunk"));
13
17
  const monday_fetch_1 = require("@mondaydotcomorg/monday-fetch");
14
18
  const authorization_internal_service_1 = require("./authorization-internal-service");
15
19
  const attributions_service_1 = require("./attributions-service");
20
+ const trident_backend_api_1 = require("@mondaydotcomorg/trident-backend-api");
21
+ const monday_sns_1 = require("@mondaydotcomorg/monday-sns");
22
+ const sns_1 = require("./constants/sns");
16
23
  class AuthorizationAttributesService {
17
24
  /**
18
25
  * Upsert resource attributes synchronously, performing http call to the authorization MS to assign the given attributes to the given resource.
@@ -61,9 +68,88 @@ class AuthorizationAttributesService {
61
68
  return { attributes: responseBody['attributes'] };
62
69
  });
63
70
  }
71
+ /**
72
+ * Async function, this function only send the updates request to SNS and return before the change actually took place
73
+ * @param accountId
74
+ * @param appName - App name of the calling app
75
+ * @param callerActionIdentifier - action identifier
76
+ * @param resourceAttributeOperations - Array of operations to do on resource attributes.
77
+ * @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
78
+ * */
79
+ static updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, resourceAttributeOperations) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ const topicArn = this.getSnsTopicArn();
82
+ const sendToSnsPromises = [];
83
+ const operationChucks = (0, chunk_1.default)(resourceAttributeOperations, sns_1.ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
84
+ for (const operationsChunk of operationChucks) {
85
+ sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk));
86
+ }
87
+ return (yield Promise.all(sendToSnsPromises)).flat();
88
+ });
89
+ }
90
+ static sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operations) {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ const payload = {
93
+ kind: sns_1.RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND,
94
+ payload: {
95
+ accountId: accountId,
96
+ callerAppName: appName,
97
+ callerActionIdentifier: callerActionIdentifier,
98
+ operations: operations,
99
+ }
100
+ };
101
+ try {
102
+ yield (0, monday_sns_1.sendToSns)(payload, topicArn);
103
+ return operations;
104
+ }
105
+ catch (error) {
106
+ authorization_internal_service_1.logger.error({ error, tag: this.LOG_TAG }, "Authorization resource attributes async update: failed to send operations to SNS");
107
+ return [];
108
+ }
109
+ });
110
+ }
111
+ static getSnsTopicArn() {
112
+ var _a;
113
+ const arnFromApi = (_a = trident_backend_api_1.Api.getPart('configurationVariables')) === null || _a === void 0 ? void 0 : _a.get(sns_1.RESOURCE_ATTRIBUTES_SNS_ARN_SECRET_NAME).arn;
114
+ if (arnFromApi) {
115
+ return arnFromApi;
116
+ }
117
+ const jsonArnFromEnv = process.env[sns_1.RESOURCE_ATTRIBUTES_SNS_ARN_SECRET_NAME];
118
+ const arnFromEnv = JSON.parse(jsonArnFromEnv).arn;
119
+ if (arnFromEnv) {
120
+ return arnFromEnv;
121
+ }
122
+ throw new Error('Unable to get sns topic arn from env variable');
123
+ }
64
124
  static getResourceAttributesUrl(accountId) {
65
125
  return `${process.env.AUTHORIZATION_URL}/attributes/${accountId}/resource`;
66
126
  }
127
+ /**
128
+ * Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
129
+ * This function can be used as health check for services that updating resource attributes in async is crucial.
130
+ * Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
131
+ * errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
132
+ * However, this is the best we can do without actually push dummy messages to the SNS.
133
+ * @return {Promise<boolean>} - true if succeeded
134
+ */
135
+ static asyncResourceAttributesHealthCheck() {
136
+ return __awaiter(this, void 0, void 0, function* () {
137
+ try {
138
+ const requestedTopicArn = this.getSnsTopicArn();
139
+ const attributes = yield (0, monday_sns_1.getTopicAttributes)(requestedTopicArn);
140
+ const isHealthy = !(!attributes || !("TopicArn" in attributes) || attributes.TopicArn !== requestedTopicArn);
141
+ if (!isHealthy) {
142
+ authorization_internal_service_1.logger.error({ requestedTopicArn, snsReturnedAttributes: attributes, tag: this.LOG_TAG }, "authorization-attributes-service failed in health check");
143
+ }
144
+ return isHealthy;
145
+ }
146
+ catch (error) {
147
+ authorization_internal_service_1.logger.error({ error, tag: this.LOG_TAG }, "authorization-attributes-service got error during health check");
148
+ return false;
149
+ }
150
+ });
151
+ }
67
152
  }
68
153
  exports.AuthorizationAttributesService = AuthorizationAttributesService;
154
+ AuthorizationAttributesService.LOG_TAG = "authorization_attributes";
69
155
  //# sourceMappingURL=authorization-attributes-service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"authorization-attributes-service.js","sourceRoot":"","sources":["../../lib/authorization-attributes-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,gEAAsD;AACtD,qFAAgF;AAChF,iEAAgE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AAM,IAAA,oBAAK,EAC1B,GAAG,EACH;gBACE,MAAM,EAAE,QAAQ;gBAChB,OAAO,kBACL,aAAa,EAAE,iBAAiB,EAChC,cAAc,EAAE,kBAAkB,IAC/B,kBAAkB,CACtB;gBACD,OAAO,EAAE,6DAA4B,CAAC,iBAAiB,EAAE;gBACzD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;aAC9C,EACD,6DAA4B,CAAC,sBAAsB,EAAE,CACtD,CAAC;YAEF,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC3C,6DAA4B,CAAC,wBAAwB,CAAC,QAAQ,EAAE,8BAA8B,CAAC,CAAC;YAEhG,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC;QACpD,CAAC;KAAA;IAEO,MAAM,CAAC,wBAAwB,CAAC,SAAiB;QACvD,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,eAAe,SAAS,WAAW,CAAC;IAC7E,CAAC;CACF;AA9ED,wEA8EC"}
1
+ {"version":3,"file":"authorization-attributes-service.js","sourceRoot":"","sources":["../../lib/authorization-attributes-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yDAAiC;AAOjC,gEAAsD;AACtD,qFAAwF;AACxF,iEAAgE;AAChE,8EAA2D;AAC3D,4DAA4E;AAE5E,yCAIyB;AAEzB,MAAa,8BAA8B;IAEzC;;;;;;;OAOG;IACH,MAAM,CAAO,wBAAwB,CACnC,SAAiB,EACjB,MAAc,EACd,4BAA2D;;YAE3D,MAAM,iBAAiB,GAAG,6DAA4B,CAAC,yBAAyB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YACpG,MAAM,kBAAkB,GAAG,IAAA,6CAAsB,GAAE,CAAC;YACpD,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAC1B,IAAI,CAAC,wBAAwB,CAAC,SAAS,C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AG,EAAE,IAAI,CAAC,OAAO,EAAC,EACpF,yDAAyD,CAAC,CAAA;gBAC9D,CAAC;gBACD,OAAO,SAAS,CAAA;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,uCAAM,CAAC,KAAK,CAAC,EAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAC,EACrC,gEAAgE,CAAC,CAAA;gBACnE,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;KAAA;;AA3JH,wEA4JC;AA3JgB,sCAAO,GAAG,0BAA0B,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const RESOURCE_ATTRIBUTES_SNS_ARN_SECRET_NAME = "AUTHORIZATION_RESOURCE_ATTRIBUTES_SNS_TOPIC";
2
+ export declare const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "resourceAttributeModification";
3
+ export declare const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = exports.RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = exports.RESOURCE_ATTRIBUTES_SNS_ARN_SECRET_NAME = void 0;
4
+ exports.RESOURCE_ATTRIBUTES_SNS_ARN_SECRET_NAME = 'AUTHORIZATION_RESOURCE_ATTRIBUTES_SNS_TOPIC';
5
+ exports.RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'resourceAttributeModification';
6
+ exports.ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
7
+ //# sourceMappingURL=sns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sns.js","sourceRoot":"","sources":["../../../lib/constants/sns.ts"],"names":[],"mappings":";;;AAAa,QAAA,uCAAuC,GAAG,6CAA6C,CAAA;AACvF,QAAA,qDAAqD,GAAG,+BAA+B,CAAC;AACxF,QAAA,oDAAoD,GAAG,GAAG,CAAC"}
@@ -8,3 +8,20 @@ export interface ResourceAttributeAssignment {
8
8
  export interface ResourceAttributeResponse {
9
9
  attributes: ResourceAttributeAssignment[];
10
10
  }
11
+ export interface ResourceAttributeDelete {
12
+ resourceType: Resource['type'];
13
+ resourceId: Resource['id'];
14
+ key: string;
15
+ }
16
+ export declare enum ResourceAttributeOperationEnum {
17
+ UPSERT = "upsert",
18
+ DELETE = "delete"
19
+ }
20
+ interface UpsertResourceAttributeOperation extends ResourceAttributeAssignment {
21
+ operationType: ResourceAttributeOperationEnum.UPSERT;
22
+ }
23
+ interface DeleteResourceAttributeOperation extends ResourceAttributeDelete {
24
+ operationType: ResourceAttributeOperationEnum.DELETE;
25
+ }
26
+ export type ResourceAttributesOperation = UpsertResourceAttributeOperation | DeleteResourceAttributeOperation;
27
+ export {};
@@ -1,3 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResourceAttributeOperationEnum = void 0;
4
+ var ResourceAttributeOperationEnum;
5
+ (function (ResourceAttributeOperationEnum) {
6
+ ResourceAttributeOperationEnum["UPSERT"] = "upsert";
7
+ ResourceAttributeOperationEnum["DELETE"] = "delete";
8
+ })(ResourceAttributeOperationEnum || (exports.ResourceAttributeOperationEnum = ResourceAttributeOperationEnum = {}));
3
9
  //# sourceMappingURL=authorization-attributes-contracts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"authorization-attributes-contracts.js","sourceRoot":"","sources":["../../../lib/types/authorization-attributes-contracts.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"authorization-attributes-contracts.js","sourceRoot":"","sources":["../../../lib/types/authorization-attributes-contracts.ts"],"names":[],"mappings":";;;AAoBA,IAAY,8BAGX;AAHD,WAAY,8BAA8B;IACxC,mDAAiB,CAAA;IACjB,mDAAiB,CAAA;AACnB,CAAC,EAHW,8BAA8B,8CAA9B,8BAA8B,QAGzC"}
@@ -1 +1 @@
1
- {"root":["../index.ts","../lib/attributions-service.ts","../lib/authorization-attributes-service.ts","../lib/authorization-internal-service.ts","../lib/authorization-middleware.ts","../lib/authorization-service.ts","../lib/prometheus-service.ts","../lib/testKit/index.ts","../lib/types/authorization-attributes-contracts.ts","../lib/types/express.ts","../lib/types/general.ts","../lib/types/scoped-actions-contracts.ts"],"version":"5.6.2"}
1
+ {"root":["../index.ts","../lib/attributions-service.ts","../lib/authorization-attributes-service.ts","../lib/authorization-internal-service.ts","../lib/authorization-middleware.ts","../lib/authorization-service.ts","../lib/prometheus-service.ts","../lib/constants/sns.ts","../lib/testKit/index.ts","../lib/types/authorization-attributes-contracts.ts","../lib/types/express.ts","../lib/types/general.ts","../lib/types/scoped-actions-contracts.ts"],"version":"5.6.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/monday-authorization",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "BSD-3-Clause",
@@ -29,7 +29,10 @@
29
29
  "@mondaydotcomorg/monday-fetch": "^0.0.7",
30
30
  "@mondaydotcomorg/monday-jwt": "^3.0.14",
31
31
  "@mondaydotcomorg/monday-logger": "^4.0.11",
32
+ "@mondaydotcomorg/monday-sns": "^1.0.6",
32
33
  "@mondaydotcomorg/trident-backend-api": "^0.23.10",
34
+ "@types/lodash": "^4.17.10",
35
+ "lodash": "^4.17.21",
33
36
  "node-fetch": "^2.6.7",
34
37
  "on-headers": "^1.0.2",
35
38
  "ts-node": "^10.0.0"
@@ -53,5 +56,5 @@
53
56
  "files": [
54
57
  "dist/"
55
58
  ],
56
- "gitHead": "8085d4ad6f7dc73997b7b73a03bb1460b93ceffc"
59
+ "gitHead": "4db8fcacd3fe976b0e3fbc8e76d556f20f757d41"
57
60
  }