@mondaydotcomorg/monday-authorization 1.1.9-authzbashanyeasync-resource-attributes-support.3214 → 1.1.9-bugmoshefixhourcolumn.385
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 +0 -15
- package/README.md +0 -32
- package/package.json +6 -30
- package/dist/index.d.ts +0 -13
- package/dist/index.js +0 -51
- package/dist/index.js.map +0 -1
- package/dist/lib/attributions-service.d.ts +0 -3
- package/dist/lib/attributions-service.js +0 -54
- package/dist/lib/attributions-service.js.map +0 -1
- package/dist/lib/authorization-attributes-service.d.ts +0 -44
- package/dist/lib/authorization-attributes-service.js +0 -142
- package/dist/lib/authorization-attributes-service.js.map +0 -1
- package/dist/lib/authorization-internal-service.d.ts +0 -13
- package/dist/lib/authorization-internal-service.js +0 -79
- package/dist/lib/authorization-internal-service.js.map +0 -1
- package/dist/lib/authorization-middleware.d.ts +0 -6
- package/dist/lib/authorization-middleware.js +0 -57
- package/dist/lib/authorization-middleware.js.map +0 -1
- package/dist/lib/authorization-service.d.ts +0 -29
- package/dist/lib/authorization-service.js +0 -186
- package/dist/lib/authorization-service.js.map +0 -1
- package/dist/lib/constants/sns.d.ts +0 -3
- package/dist/lib/constants/sns.js +0 -7
- package/dist/lib/constants/sns.js.map +0 -1
- package/dist/lib/prometheus-service.d.ts +0 -10
- package/dist/lib/prometheus-service.js +0 -51
- package/dist/lib/prometheus-service.js.map +0 -1
- package/dist/lib/testKit/index.d.ts +0 -11
- package/dist/lib/testKit/index.js +0 -59
- package/dist/lib/testKit/index.js.map +0 -1
- package/dist/lib/types/authorization-attributes-contracts.d.ts +0 -27
- package/dist/lib/types/authorization-attributes-contracts.js +0 -9
- package/dist/lib/types/authorization-attributes-contracts.js.map +0 -1
- package/dist/lib/types/express.d.ts +0 -10
- package/dist/lib/types/express.js +0 -2
- package/dist/lib/types/express.js.map +0 -1
- package/dist/lib/types/general.d.ts +0 -30
- package/dist/lib/types/general.js +0 -3
- package/dist/lib/types/general.js.map +0 -1
- package/dist/lib/types/scoped-actions-contracts.d.ts +0 -38
- package/dist/lib/types/scoped-actions-contracts.js +0 -10
- package/dist/lib/types/scoped-actions-contracts.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,21 +5,6 @@ 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
|
-
|
|
13
|
-
## [1.2.3] - 2024-06-10
|
|
14
|
-
### Added
|
|
15
|
-
|
|
16
|
-
- [`feature/yarden/resource-attributes-api-support-authz-sdk (#5826)`](https://github.com/DaPulse/monday-npm-packages/pull/5826)
|
|
17
|
-
- `AuthorizationAttributesService` - now supports upsert (`upsertResourceAttributesSync`) and delete (`deleteResourceAttributesSync`) resource attributes in the authorization MS
|
|
18
|
-
|
|
19
|
-
## [1.2.0] - 2024-01-05
|
|
20
|
-
### Added
|
|
21
|
-
- `isAuthorized` now return the unauthorized objects - regardless to the unauthorized ids (which may be missing resource ids if resource has no id, like `feature` e.g.)
|
|
22
|
-
|
|
23
8
|
## [1.1.0] - 2023-08-09
|
|
24
9
|
|
|
25
10
|
### ⚠ BREAKING CHANGES
|
package/README.md
CHANGED
|
@@ -136,35 +136,3 @@ const canActionInScopeMultipleResponse: ScopedActionResponseObject[] =
|
|
|
136
136
|
* ]
|
|
137
137
|
* /
|
|
138
138
|
```
|
|
139
|
-
|
|
140
|
-
### Authorization Attributes API
|
|
141
|
-
|
|
142
|
-
Use `AuthorizationAttributesService.upsertResourceAttributesSync` to upsert multiple resource attributes in the authorization MS synchronously.
|
|
143
|
-
|
|
144
|
-
```ts
|
|
145
|
-
import { AuthorizationAttributesService, ResourceAttributeAssignment, ResourceAttributeResponse } from '@mondaydotcomorg/monday-authorization';
|
|
146
|
-
|
|
147
|
-
const accountId = 739630;
|
|
148
|
-
const userId = 4;
|
|
149
|
-
const resourceAttributesAssignments: ResourceAttributeAssignment[] = [
|
|
150
|
-
{ resourceId: 18, resourceType: 'workspace', key: 'is_default_workspace', value: 'true' },
|
|
151
|
-
{ resourceId: 23, resourceType: 'board', key: 'board_kind', value: 'private' }
|
|
152
|
-
];
|
|
153
|
-
|
|
154
|
-
const response: ResourceAttributeResponse = await AuthorizationAttributesService.upsertResourceAttributesSync(accountId, userId, resourceAttributesAssignments);
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
Use `AuthorizationAttributesService.deleteResourceAttributesSync` to delete single resource's attributes in the authorization MS synchronously.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
```ts
|
|
161
|
-
import { AuthorizationAttributesService, ResourceAttributeResponse, Resource } from '@mondaydotcomorg/monday-authorization';
|
|
162
|
-
|
|
163
|
-
const accountId = 739630;
|
|
164
|
-
const userId = 4;
|
|
165
|
-
const resource: Resource = { type: 'workspace', id: 18 };
|
|
166
|
-
const attributeKeys: string[] = ['is_default_workspace', 'workspace_kind'];
|
|
167
|
-
|
|
168
|
-
const response: ResourceAttributeResponse = await AuthorizationAttributesService.deleteResourceAttributesSync(accountId, userId, resource, attributeKeys);
|
|
169
|
-
```
|
|
170
|
-
|
package/package.json
CHANGED
|
@@ -1,60 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondaydotcomorg/monday-authorization",
|
|
3
|
-
"version": "1.1.9-
|
|
3
|
+
"version": "1.1.9-bugmoshefixhourcolumn.385+615c92e7d",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
|
-
"jest": {
|
|
8
|
-
"testEnvironment": "node",
|
|
9
|
-
"testMatch": [
|
|
10
|
-
"**/+(*.)+(spec|test).+(ts|js)?(x)"
|
|
11
|
-
],
|
|
12
|
-
"transform": {
|
|
13
|
-
"^.+\\.(ts|js|html)$": "ts-jest"
|
|
14
|
-
},
|
|
15
|
-
"moduleFileExtensions": [
|
|
16
|
-
"ts",
|
|
17
|
-
"js",
|
|
18
|
-
"html"
|
|
19
|
-
],
|
|
20
|
-
"coverageReporters": [
|
|
21
|
-
"html"
|
|
22
|
-
]
|
|
23
|
-
},
|
|
24
7
|
"scripts": {
|
|
25
|
-
"test": "
|
|
8
|
+
"test": "mocha -r ts-node/register -r tsconfig-paths/register './tests/*.test.ts' --timeout 5000 --exit",
|
|
26
9
|
"build": "tsc --build"
|
|
27
10
|
},
|
|
28
11
|
"dependencies": {
|
|
29
12
|
"@mondaydotcomorg/monday-fetch": "^0.0.7",
|
|
30
|
-
"@mondaydotcomorg/monday-jwt": "^3.0.
|
|
31
|
-
"@mondaydotcomorg/monday-logger": "^
|
|
32
|
-
"@mondaydotcomorg/monday-sns": "^1.0.6",
|
|
33
|
-
"@mondaydotcomorg/trident-backend-api": "^0.23.10",
|
|
34
|
-
"@types/lodash": "^4.17.10",
|
|
35
|
-
"lodash": "^4.17.21",
|
|
13
|
+
"@mondaydotcomorg/monday-jwt": "^3.0.10",
|
|
14
|
+
"@mondaydotcomorg/monday-logger": "^3.0.10",
|
|
36
15
|
"node-fetch": "^2.6.7",
|
|
37
|
-
"on-headers": "^1.0.2",
|
|
38
16
|
"ts-node": "^10.0.0"
|
|
39
17
|
},
|
|
40
18
|
"devDependencies": {
|
|
41
19
|
"@types/express": "^4.17.20",
|
|
42
|
-
"@types/jest": "^27.4.1",
|
|
43
20
|
"@types/mocha": "^8.2.2",
|
|
44
21
|
"@types/on-headers": "^1.0.0",
|
|
45
22
|
"@types/supertest": "^2.0.11",
|
|
46
23
|
"express": "^4.17.1",
|
|
47
24
|
"ioredis": "^5.2.4",
|
|
48
25
|
"ioredis-mock": "^8.2.2",
|
|
49
|
-
"jest": "^27.5.1",
|
|
50
26
|
"mocha": "^9.0.1",
|
|
27
|
+
"on-headers": "^1.0.2",
|
|
51
28
|
"supertest": "^6.1.3",
|
|
52
|
-
"ts-jest": "^27.1.3",
|
|
53
29
|
"tsconfig-paths": "^3.9.0",
|
|
54
30
|
"typescript": "^5.1.6"
|
|
55
31
|
},
|
|
56
32
|
"files": [
|
|
57
33
|
"dist/"
|
|
58
34
|
],
|
|
59
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "615c92e7dc78def059faf333b5443ae643730929"
|
|
60
36
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
|
|
2
|
-
import * as TestKit from './lib/testKit';
|
|
3
|
-
export interface InitOptions {
|
|
4
|
-
prometheus?: any;
|
|
5
|
-
mondayFetchOptions?: MondayFetchOptions;
|
|
6
|
-
redisClient?: any;
|
|
7
|
-
grantedFeatureRedisExpirationInSeconds?: number;
|
|
8
|
-
}
|
|
9
|
-
export declare function init(options?: InitOptions): void;
|
|
10
|
-
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './lib/authorization-middleware';
|
|
11
|
-
export { AuthorizationService } from './lib/authorization-service';
|
|
12
|
-
export { AuthorizationAttributesService } from './lib/authorization-attributes-service';
|
|
13
|
-
export { TestKit };
|
package/dist/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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.TestKit = exports.AuthorizationAttributesService = exports.AuthorizationService = exports.skipAuthorizationMiddleware = exports.getAuthorizationMiddleware = exports.authorizationCheckMiddleware = void 0;
|
|
27
|
-
exports.init = init;
|
|
28
|
-
const prometheus_service_1 = require("./lib/prometheus-service");
|
|
29
|
-
const authorization_service_1 = require("./lib/authorization-service");
|
|
30
|
-
const TestKit = __importStar(require("./lib/testKit"));
|
|
31
|
-
exports.TestKit = TestKit;
|
|
32
|
-
function init(options = {}) {
|
|
33
|
-
if (options.prometheus) {
|
|
34
|
-
(0, prometheus_service_1.setPrometheus)(options.prometheus);
|
|
35
|
-
}
|
|
36
|
-
if (options.mondayFetchOptions) {
|
|
37
|
-
(0, authorization_service_1.setRequestFetchOptions)(options.mondayFetchOptions);
|
|
38
|
-
}
|
|
39
|
-
if (options.redisClient) {
|
|
40
|
-
(0, authorization_service_1.setRedisClient)(options.redisClient, options.grantedFeatureRedisExpirationInSeconds);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
var authorization_middleware_1 = require("./lib/authorization-middleware");
|
|
44
|
-
Object.defineProperty(exports, "authorizationCheckMiddleware", { enumerable: true, get: function () { return authorization_middleware_1.authorizationCheckMiddleware; } });
|
|
45
|
-
Object.defineProperty(exports, "getAuthorizationMiddleware", { enumerable: true, get: function () { return authorization_middleware_1.getAuthorizationMiddleware; } });
|
|
46
|
-
Object.defineProperty(exports, "skipAuthorizationMiddleware", { enumerable: true, get: function () { return authorization_middleware_1.skipAuthorizationMiddleware; } });
|
|
47
|
-
var authorization_service_2 = require("./lib/authorization-service");
|
|
48
|
-
Object.defineProperty(exports, "AuthorizationService", { enumerable: true, get: function () { return authorization_service_2.AuthorizationService; } });
|
|
49
|
-
var authorization_attributes_service_1 = require("./lib/authorization-attributes-service");
|
|
50
|
-
Object.defineProperty(exports, "AuthorizationAttributesService", { enumerable: true, get: function () { return authorization_attributes_service_1.AuthorizationAttributesService; } });
|
|
51
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,oBAWC;AArBD,iEAAyD;AACzD,uEAAqF;AACrF,uDAAyC;AA6BhC,0BAAO;AArBhB,SAAgB,IAAI,CAAC,UAAuB,EAAE;IAC5C,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,IAAA,kCAAa,EAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC/B,IAAA,8CAAsB,EAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,IAAA,sCAAc,EAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,sCAAsC,CAAC,CAAC;IACtF,CAAC;AACH,CAAC;AAED,2EAIwC;AAHtC,wIAAA,4BAA4B,OAAA;AAC5B,sIAAA,0BAA0B,OAAA;AAC1B,uIAAA,2BAA2B,OAAA;AAE7B,qEAAmE;AAA1D,6HAAA,oBAAoB,OAAA;AAC7B,2FAAwF;AAA/E,kJAAA,8BAA8B,OAAA"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAttributionsFromApi = getAttributionsFromApi;
|
|
4
|
-
const trident_backend_api_1 = require("@mondaydotcomorg/trident-backend-api");
|
|
5
|
-
const authorization_internal_service_1 = require("./authorization-internal-service");
|
|
6
|
-
const APP_NAME_VARIABLE_KEY = 'APP_NAME';
|
|
7
|
-
const APP_NAME_HEADER_NAME = 'x-caller-app-name-from-sdk';
|
|
8
|
-
const FROM_SDK_HEADER_SUFFIX = `-from-sdk`;
|
|
9
|
-
let didSendFailureLogOnce = false;
|
|
10
|
-
function getAttributionsFromApi() {
|
|
11
|
-
let callerAppNameFromSdk = {
|
|
12
|
-
[APP_NAME_HEADER_NAME]: tryJsonParse(getEnvVariable(APP_NAME_VARIABLE_KEY)),
|
|
13
|
-
};
|
|
14
|
-
try {
|
|
15
|
-
const tridentContext = trident_backend_api_1.Api.getPart('context');
|
|
16
|
-
if (!tridentContext) {
|
|
17
|
-
return callerAppNameFromSdk;
|
|
18
|
-
}
|
|
19
|
-
const { runtimeAttributions } = tridentContext;
|
|
20
|
-
let runtimeAttributionsOutgoingHeaders = runtimeAttributions === null || runtimeAttributions === void 0 ? void 0 : runtimeAttributions.buildOutgoingHeaders('HTTP_INTERNAL');
|
|
21
|
-
if (!runtimeAttributionsOutgoingHeaders) {
|
|
22
|
-
return callerAppNameFromSdk;
|
|
23
|
-
}
|
|
24
|
-
const attributionsHeaders = Object.fromEntries(runtimeAttributionsOutgoingHeaders);
|
|
25
|
-
const attributionHeadersFromSdk = {};
|
|
26
|
-
Object.keys(attributionsHeaders).forEach(function (key) {
|
|
27
|
-
attributionHeadersFromSdk[`${key}${FROM_SDK_HEADER_SUFFIX}`] = attributionsHeaders[key];
|
|
28
|
-
});
|
|
29
|
-
return attributionHeadersFromSdk;
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
if (!didSendFailureLogOnce) {
|
|
33
|
-
authorization_internal_service_1.logger.warn({ tag: 'authorization-service', error }, 'Failed to generate attributions headers from the API. Unexpected error while extracting headers. It may be caused by out of date Trident version.');
|
|
34
|
-
didSendFailureLogOnce = true;
|
|
35
|
-
}
|
|
36
|
-
return callerAppNameFromSdk;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function getEnvVariable(key) {
|
|
40
|
-
const envVar = process.env[key] || process.env[key.toUpperCase()] || process.env[key.toLowerCase()];
|
|
41
|
-
return envVar;
|
|
42
|
-
}
|
|
43
|
-
function tryJsonParse(value) {
|
|
44
|
-
if (!value) {
|
|
45
|
-
return value;
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
return JSON.parse(value);
|
|
49
|
-
}
|
|
50
|
-
catch (_err) {
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=attributions-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attributions-service.js","sourceRoot":"","sources":["../../lib/attributions-service.ts"],"names":[],"mappings":";;AASA,wDAqCC;AA9CD,8EAA2D;AAC3D,qFAA0D;AAE1D,MAAM,qBAAqB,GAAG,UAAU,CAAC;AACzC,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAC1D,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAE3C,IAAI,qBAAqB,GAAG,KAAK,CAAC;AAElC,SAAgB,sBAAsB;IACpC,IAAI,oBAAoB,GAAG;QACzB,CAAC,oBAAoB,CAAC,EAAE,YAAY,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC;KAC5E,CAAC;IAEF,I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M,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,KAAyB;IAC7C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,IAAI,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ResourceAttributeAssignment, ResourceAttributeResponse, ResourceAttributesOperation } from './types/authorization-attributes-contracts';
|
|
2
|
-
import { Resource } from './types/general';
|
|
3
|
-
export declare class AuthorizationAttributesService {
|
|
4
|
-
private static LOG_TAG;
|
|
5
|
-
/**
|
|
6
|
-
* Upsert resource attributes synchronously, performing http call to the authorization MS to assign the given attributes to the given resource.
|
|
7
|
-
* @param accountId
|
|
8
|
-
* @param userId
|
|
9
|
-
* @param resourceAttributeAssignments - Array of resource (resourceType, resourceId) and attribute (key, value) pairs to upsert in the authorization MS.
|
|
10
|
-
* e.g. [{ resourceType: 'board', resourceId: 123, key: 'board_kind', value: 'private' }]
|
|
11
|
-
* @returns ResourceAttributeResponse - The affected (created and updated_ resource attributes assignments in the `attributes` field.
|
|
12
|
-
*/
|
|
13
|
-
static upsertResourceAttributes(accountId: number, userId: number, resourceAttributeAssignments: ResourceAttributeAssignment[]): Promise<ResourceAttributeResponse>;
|
|
14
|
-
/**
|
|
15
|
-
* Delete resource attributes assignments synchronously, performing http call to the authorization MS to delete the given attributes from the given singular resource.
|
|
16
|
-
* @param accountId
|
|
17
|
-
* @param userId
|
|
18
|
-
* @param resource - The resource (resourceType, resourceId) to delete the attributes for.
|
|
19
|
-
* @param attributeKeys - Array of attribute keys to delete for the resource.
|
|
20
|
-
* @returns ResourceAttributeResponse - The affected (deleted) resource attributes assignments in the `attributes` field.
|
|
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;
|
|
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>;
|
|
44
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.AuthorizationAttributesService = void 0;
|
|
16
|
-
const chunk_1 = __importDefault(require("lodash/chunk"));
|
|
17
|
-
const monday_fetch_1 = require("@mondaydotcomorg/monday-fetch");
|
|
18
|
-
const authorization_internal_service_1 = require("./authorization-internal-service");
|
|
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");
|
|
23
|
-
class AuthorizationAttributesService {
|
|
24
|
-
/**
|
|
25
|
-
* Upsert resource attributes synchronously, performing http call to the authorization MS to assign the given attributes to the given resource.
|
|
26
|
-
* @param accountId
|
|
27
|
-
* @param userId
|
|
28
|
-
* @param resourceAttributeAssignments - Array of resource (resourceType, resourceId) and attribute (key, value) pairs to upsert in the authorization MS.
|
|
29
|
-
* e.g. [{ resourceType: 'board', resourceId: 123, key: 'board_kind', value: 'private' }]
|
|
30
|
-
* @returns ResourceAttributeResponse - The affected (created and updated_ resource attributes assignments in the `attributes` field.
|
|
31
|
-
*/
|
|
32
|
-
static upsertResourceAttributes(accountId, userId, resourceAttributeAssignments) {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const internalAuthToken = authorization_internal_service_1.AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
35
|
-
const attributionHeaders = (0, attributions_service_1.getAttributionsFromApi)();
|
|
36
|
-
const response = yield (0, monday_fetch_1.fetch)(this.getResourceAttributesUrl(accountId), {
|
|
37
|
-
method: 'POST',
|
|
38
|
-
headers: Object.assign({ Authorization: internalAuthToken, 'Content-Type': 'application/json' }, attributionHeaders),
|
|
39
|
-
timeout: authorization_internal_service_1.AuthorizationInternalService.getRequestTimeout(),
|
|
40
|
-
body: JSON.stringify({ resourceAttributeAssignments }),
|
|
41
|
-
}, authorization_internal_service_1.AuthorizationInternalService.getRequestFetchOptions());
|
|
42
|
-
const responseBody = yield response.json();
|
|
43
|
-
authorization_internal_service_1.AuthorizationInternalService.throwOnHttpErrorIfNeeded(response, 'upsertResourceAttributesSync');
|
|
44
|
-
return { attributes: responseBody['attributes'] };
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Delete resource attributes assignments synchronously, performing http call to the authorization MS to delete the given attributes from the given singular resource.
|
|
49
|
-
* @param accountId
|
|
50
|
-
* @param userId
|
|
51
|
-
* @param resource - The resource (resourceType, resourceId) to delete the attributes for.
|
|
52
|
-
* @param attributeKeys - Array of attribute keys to delete for the resource.
|
|
53
|
-
* @returns ResourceAttributeResponse - The affected (deleted) resource attributes assignments in the `attributes` field.
|
|
54
|
-
*/
|
|
55
|
-
static deleteResourceAttributes(accountId, userId, resource, attributeKeys) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const internalAuthToken = authorization_internal_service_1.AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
58
|
-
const url = `${this.getResourceAttributesUrl(accountId)}/${resource.type}/${resource.id}`;
|
|
59
|
-
const attributionHeaders = (0, attributions_service_1.getAttributionsFromApi)();
|
|
60
|
-
const response = yield (0, monday_fetch_1.fetch)(url, {
|
|
61
|
-
method: 'DELETE',
|
|
62
|
-
headers: Object.assign({ Authorization: internalAuthToken, 'Content-Type': 'application/json' }, attributionHeaders),
|
|
63
|
-
timeout: authorization_internal_service_1.AuthorizationInternalService.getRequestTimeout(),
|
|
64
|
-
body: JSON.stringify({ keys: attributeKeys }),
|
|
65
|
-
}, authorization_internal_service_1.AuthorizationInternalService.getRequestFetchOptions());
|
|
66
|
-
const responseBody = yield response.json();
|
|
67
|
-
authorization_internal_service_1.AuthorizationInternalService.throwOnHttpErrorIfNeeded(response, 'deleteResourceAttributesSync');
|
|
68
|
-
return { attributes: responseBody['attributes'] };
|
|
69
|
-
});
|
|
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_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_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
|
-
return ((_a = trident_backend_api_1.Api.getPart('configurationVariables')) === null || _a === void 0 ? void 0 : _a.get(sns_1.RESOURCE_ATTRIBUTES_SECRET_NAME).arn) ||
|
|
114
|
-
JSON.parse(process.env[sns_1.RESOURCE_ATTRIBUTES_SECRET_NAME]).arn;
|
|
115
|
-
}
|
|
116
|
-
static getResourceAttributesUrl(accountId) {
|
|
117
|
-
return `${process.env.AUTHORIZATION_URL}/attributes/${accountId}/resource`;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
|
|
121
|
-
* This function can be used as health check for services that updating resource attributes in async is crucial.
|
|
122
|
-
* Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
|
|
123
|
-
* errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
|
|
124
|
-
* However, this is the best we can do without actually push dummy messages to the SNS.
|
|
125
|
-
* @return {Promise<boolean>} - true if succeeded
|
|
126
|
-
*/
|
|
127
|
-
static asyncResourceAttributesHealthCheck() {
|
|
128
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
try {
|
|
130
|
-
const requestedTopicArn = this.getSnsTopicArn();
|
|
131
|
-
const attributes = yield (0, monday_sns_1.getTopicAttributes)(requestedTopicArn);
|
|
132
|
-
return !(!attributes || !("TopicArn" in attributes) || attributes.TopicArn !== requestedTopicArn);
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.AuthorizationAttributesService = AuthorizationAttributesService;
|
|
141
|
-
AuthorizationAttributesService.LOG_TAG = "authorization_attributes";
|
|
142
|
-
//# sourceMappingURL=authorization-attributes-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-service.js","sourceRoot":"","sources":["../../lib/authorization-attributes-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yDAAkC;AAOlC,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,CAAC,EACxC;gBACE,MAAM,EAAE,MAAM;gBACd,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,4BAA4B,EAAE,CAAC;aACvD,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,UA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QACvD,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,eAAe,SAAS,WAAW,CAAC;IAC7E,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAO,kCAAkC;;YAC7C,IAAI,CAAC;gBACH,MAAM,iBAAiB,GAAW,IAAI,CAAC,cAAc,EAAE,CAAC;gBACxD,MAAM,UAAU,GAAuB,MAAM,IAAA,+BAAkB,EAAC,iBAAiB,CAAC,CAAC;gBACnF,OAAO,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,KAAK,iBAAiB,CAAC,CAAC;YACpG,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;KAAA;;AA5IH,wEA6IC;AA5IgB,sCAAO,GAAG,0BAA0B,CAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Request } from 'express';
|
|
2
|
-
import { fetch, MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
|
|
3
|
-
export declare const logger: import("bunyan");
|
|
4
|
-
export declare class AuthorizationInternalService {
|
|
5
|
-
static skipAuthorization(requset: Request): void;
|
|
6
|
-
static markAuthorized(request: Request): void;
|
|
7
|
-
static failIfNotCoveredByAuthorization(request: Request): void;
|
|
8
|
-
static throwOnHttpErrorIfNeeded(response: Awaited<ReturnType<typeof fetch>>, placement: string): void;
|
|
9
|
-
static generateInternalAuthToken(accountId: number, userId: number): string;
|
|
10
|
-
static setRequestFetchOptions(customMondayFetchOptions: MondayFetchOptions): void;
|
|
11
|
-
static getRequestFetchOptions(): MondayFetchOptions;
|
|
12
|
-
static getRequestTimeout(): 60000 | 2000;
|
|
13
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
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.AuthorizationInternalService = exports.logger = void 0;
|
|
27
|
-
const monday_jwt_1 = require("@mondaydotcomorg/monday-jwt");
|
|
28
|
-
const MondayLogger = __importStar(require("@mondaydotcomorg/monday-logger"));
|
|
29
|
-
const INTERNAL_APP_NAME = 'internal_ms';
|
|
30
|
-
const defaultMondayFetchOptions = {
|
|
31
|
-
retries: 3,
|
|
32
|
-
callback: logOnFetchFail,
|
|
33
|
-
};
|
|
34
|
-
function logOnFetchFail(retriesLeft, error) {
|
|
35
|
-
if (retriesLeft == 0) {
|
|
36
|
-
exports.logger.error({ retriesLeft, error }, 'Authorization attempt failed due to network issues');
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
exports.logger.info({ retriesLeft, error }, 'Authorization attempt failed due to network issues, trying again');
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
let mondayFetchOptions = defaultMondayFetchOptions;
|
|
43
|
-
exports.logger = MondayLogger.getLogger();
|
|
44
|
-
class AuthorizationInternalService {
|
|
45
|
-
static skipAuthorization(requset) {
|
|
46
|
-
requset.authorizationSkipPerformed = true;
|
|
47
|
-
}
|
|
48
|
-
static markAuthorized(request) {
|
|
49
|
-
request.authorizationCheckPerformed = true;
|
|
50
|
-
}
|
|
51
|
-
static failIfNotCoveredByAuthorization(request) {
|
|
52
|
-
if (!request.authorizationCheckPerformed && !request.authorizationSkipPerformed) {
|
|
53
|
-
throw 'Endpoint is not covered by authorization check';
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
static throwOnHttpErrorIfNeeded(response, placement) {
|
|
57
|
-
if (response.ok) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const status = response.status;
|
|
61
|
-
exports.logger.error({ tag: 'authorization-service', placement, status }, 'AuthorizationService: authorization request failed');
|
|
62
|
-
throw new Error(`AuthorizationService: [${placement}] authorization request failed with status ${status}`);
|
|
63
|
-
}
|
|
64
|
-
static generateInternalAuthToken(accountId, userId) {
|
|
65
|
-
return (0, monday_jwt_1.signAuthorizationHeader)({ appName: INTERNAL_APP_NAME, accountId, userId });
|
|
66
|
-
}
|
|
67
|
-
static setRequestFetchOptions(customMondayFetchOptions) {
|
|
68
|
-
mondayFetchOptions = Object.assign(Object.assign({}, defaultMondayFetchOptions), customMondayFetchOptions);
|
|
69
|
-
}
|
|
70
|
-
static getRequestFetchOptions() {
|
|
71
|
-
return mondayFetchOptions;
|
|
72
|
-
}
|
|
73
|
-
static getRequestTimeout() {
|
|
74
|
-
const isDevEnv = process.env.NODE_ENV === 'development';
|
|
75
|
-
return isDevEnv ? 60000 : 2000;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.AuthorizationInternalService = AuthorizationInternalService;
|
|
79
|
-
//# sourceMappingURL=authorization-internal-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-internal-service.js","sourceRoot":"","sources":["../../lib/authorization-internal-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4DAAsE;AAEtE,6EAA+D;AAE/D,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAExC,MAAM,yBAAyB,GAAuB;IACpD,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,cAAc;CACzB,CAAC;AAEF,SAAS,cAAc,CAAC,WAAmB,EAAE,KAAY;IACvD,IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;QACrB,cAAM,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,oDAAoD,CAAC,CAAC;IAC7F,CAAC;SAAM,CAAC;QACN,cAAM,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,kEAAkE,CAAC,CAAC;IAC1G,CAAC;AACH,CAAC;AAED,IAAI,kBAAkB,GAAuB,yBAAyB,CAAC;AAE1D,QAAA,MAAM,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC;AAE/C,MAAa,4BAA4B;IACvC,MAAM,CAAC,iBAAiB,CAAC,OAAgB;QACvC,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,OAAgB;QACpC,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,+BAA+B,CAAC,OAAgB;QACrD,IAAI,CAAC,OAAO,CAAC,2BAA2B,IAAI,CAAC,OAAO,CAAC,0BAA0B,EAAE,CAAC;YAChF,MAAM,gDAAgD,CAAC;QACzD,CAAC;IACH,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,QAA2C,EAAE,SAAiB;QAC5F,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;QAC/B,cAAM,CAAC,KAAK,CACV,EAAE,GAAG,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,EAAE,EACnD,oDAAoD,CACrD,CAAC;QAEF,MAAM,IAAI,KAAK,CAAC,0BAA0B,SAAS,8CAA8C,MAAM,EAAE,CAAC,CAAC;IAC7G,CAAC;IAED,MAAM,CAAC,yBAAyB,CAAC,SAAiB,EAAE,MAAc;QAChE,OAAO,IAAA,oCAAuB,EAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;IACpF,CAAC;IAED,MAAM,CAAC,sBAAsB,CAAC,wBAA4C;QACxE,kBAAkB,mCACb,yBAAyB,GACzB,wBAAwB,CAC5B,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,sBAAsB;QAC3B,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,iBAAiB;QACtB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;QACxD,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACjC,CAAC;CACF;AAhDD,oEAgDC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { NextFunction } from 'express';
|
|
2
|
-
import { Action, BaseRequest, BaseResponse, Context, ContextGetter, ResourceGetter } from './types/general';
|
|
3
|
-
export declare function getAuthorizationMiddleware(action: Action, resourceGetter: ResourceGetter, contextGetter?: ContextGetter): (request: BaseRequest, response: BaseResponse, next: NextFunction) => Promise<void>;
|
|
4
|
-
export declare function skipAuthorizationMiddleware(request: BaseRequest, response: BaseResponse, next: NextFunction): void;
|
|
5
|
-
export declare function authorizationCheckMiddleware(request: BaseRequest, response: BaseResponse, next: NextFunction): void;
|
|
6
|
-
export declare function defaultContextGetter(request: BaseRequest): Context;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getAuthorizationMiddleware = getAuthorizationMiddleware;
|
|
16
|
-
exports.skipAuthorizationMiddleware = skipAuthorizationMiddleware;
|
|
17
|
-
exports.authorizationCheckMiddleware = authorizationCheckMiddleware;
|
|
18
|
-
exports.defaultContextGetter = defaultContextGetter;
|
|
19
|
-
const on_headers_1 = __importDefault(require("on-headers"));
|
|
20
|
-
const authorization_internal_service_1 = require("./authorization-internal-service");
|
|
21
|
-
const authorization_service_1 = require("./authorization-service");
|
|
22
|
-
// getAuthorizationMiddleware is duplicated in testKit/index.ts
|
|
23
|
-
// If you are making changes to this function, please make sure to update the other file as well
|
|
24
|
-
function getAuthorizationMiddleware(action, resourceGetter, contextGetter) {
|
|
25
|
-
return function authorizationMiddleware(request, response, next) {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
contextGetter || (contextGetter = defaultContextGetter);
|
|
28
|
-
const { userId, accountId } = contextGetter(request);
|
|
29
|
-
const resources = resourceGetter(request);
|
|
30
|
-
const { isAuthorized } = yield authorization_service_1.AuthorizationService.isAuthorized(accountId, userId, resources, action);
|
|
31
|
-
authorization_internal_service_1.AuthorizationInternalService.markAuthorized(request);
|
|
32
|
-
if (!isAuthorized) {
|
|
33
|
-
response.status(403).json({ message: 'Access denied' });
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
next();
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function skipAuthorizationMiddleware(request, response, next) {
|
|
41
|
-
authorization_internal_service_1.AuthorizationInternalService.skipAuthorization(request);
|
|
42
|
-
next();
|
|
43
|
-
}
|
|
44
|
-
function authorizationCheckMiddleware(request, response, next) {
|
|
45
|
-
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
46
|
-
(0, on_headers_1.default)(response, function () {
|
|
47
|
-
if (response.statusCode < 400) {
|
|
48
|
-
authorization_internal_service_1.AuthorizationInternalService.failIfNotCoveredByAuthorization(request);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
next();
|
|
53
|
-
}
|
|
54
|
-
function defaultContextGetter(request) {
|
|
55
|
-
return request.payload;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=authorization-middleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-middleware.js","sourceRoot":"","sources":["../../lib/authorization-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAQA,gEAqBC;AAED,kEAGC;AAED,oEASC;AAED,oDAEC;AAhDD,4DAAmC;AACnC,qFAAgF;AAChF,mEAA+D;AAG/D,+DAA+D;AAC/D,gGAAgG;AAChG,SAAgB,0BAA0B,CACxC,MAAc,EACd,cAA8B,EAC9B,aAA6B;IAE7B,OAAO,SAAe,uBAAuB,CAC3C,OAAoB,EACpB,QAAsB,EACtB,IAAkB;;YAElB,aAAa,KAAb,aAAa,GAAK,oBAAoB,EAAC;YACvC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,OAAO,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|
-
import { ScopedAction, ScopedActionPermit, ScopedActionResponseObject, ScopeOptions } from './types/scoped-actions-contracts';
|
|
4
|
-
export interface AuthorizeResponse {
|
|
5
|
-
isAuthorized: boolean;
|
|
6
|
-
unauthorizedIds?: number[];
|
|
7
|
-
unauthorizedObjects?: AuthorizationObject[];
|
|
8
|
-
}
|
|
9
|
-
export declare function setRequestFetchOptions(customMondayFetchOptions: MondayFetchOptions): void;
|
|
10
|
-
export declare function setRedisClient(client: any, grantedFeatureRedisExpirationInSeconds?: number): void;
|
|
11
|
-
export declare class AuthorizationService {
|
|
12
|
-
static redisClient?: any;
|
|
13
|
-
static grantedFeatureRedisExpirationInSeconds?: number;
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated use the second form with authorizationRequestObjects instead,
|
|
16
|
-
* support of this function will be dropped gradually
|
|
17
|
-
*/
|
|
18
|
-
static isAuthorized(accountId: number, userId: number, resources: Resource[], action: Action): Promise<AuthorizeResponse>;
|
|
19
|
-
static isAuthorized(accountId: number, userId: number, authorizationRequestObjects: AuthorizationObject[]): Promise<AuthorizeResponse>;
|
|
20
|
-
static isUserGrantedWithFeature(accountId: number, userId: number, featureName: string, options?: {
|
|
21
|
-
shouldSkipCache?: boolean;
|
|
22
|
-
}): Promise<boolean>;
|
|
23
|
-
private static fetchIsUserGrantedWithFeature;
|
|
24
|
-
private static getCachedKeyName;
|
|
25
|
-
static canActionInScope(accountId: number, userId: number, action: string, scope: ScopeOptions): Promise<ScopedActionPermit>;
|
|
26
|
-
static canActionInScopeMultiple(accountId: number, userId: number, scopedActions: ScopedAction[]): Promise<ScopedActionResponseObject[]>;
|
|
27
|
-
private static isAuthorizedSingular;
|
|
28
|
-
private static isAuthorizedMultiple;
|
|
29
|
-
}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AuthorizationService = void 0;
|
|
13
|
-
exports.setRequestFetchOptions = setRequestFetchOptions;
|
|
14
|
-
exports.setRedisClient = setRedisClient;
|
|
15
|
-
const lodash_1 = require("lodash");
|
|
16
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
17
|
-
const monday_fetch_1 = require("@mondaydotcomorg/monday-fetch");
|
|
18
|
-
const prometheus_service_1 = require("./prometheus-service");
|
|
19
|
-
const authorization_internal_service_1 = require("./authorization-internal-service");
|
|
20
|
-
const attributions_service_1 = require("./attributions-service");
|
|
21
|
-
const GRANTED_FEATURE_CACHE_EXPIRATION_SECONDS = 5 * 60;
|
|
22
|
-
function setRequestFetchOptions(customMondayFetchOptions) {
|
|
23
|
-
authorization_internal_service_1.AuthorizationInternalService.setRequestFetchOptions(customMondayFetchOptions);
|
|
24
|
-
}
|
|
25
|
-
function setRedisClient(client, grantedFeatureRedisExpirationInSeconds = GRANTED_FEATURE_CACHE_EXPIRATION_SECONDS) {
|
|
26
|
-
AuthorizationService.redisClient = client;
|
|
27
|
-
if (grantedFeatureRedisExpirationInSeconds && grantedFeatureRedisExpirationInSeconds > 0) {
|
|
28
|
-
AuthorizationService.grantedFeatureRedisExpirationInSeconds = grantedFeatureRedisExpirationInSeconds;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
authorization_internal_service_1.logger.warn({ grantedFeatureRedisExpirationInSeconds }, 'Invalid input for grantedFeatureRedisExpirationInSeconds, must be positive number. using default ttl.');
|
|
32
|
-
AuthorizationService.grantedFeatureRedisExpirationInSeconds = GRANTED_FEATURE_CACHE_EXPIRATION_SECONDS;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
class AuthorizationService {
|
|
36
|
-
static isAuthorized(...args) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
if (args.length === 3) {
|
|
39
|
-
return this.isAuthorizedMultiple(args[0], args[1], args[2]);
|
|
40
|
-
}
|
|
41
|
-
else if (args.length == 4) {
|
|
42
|
-
return this.isAuthorizedSingular(args[0], args[1], args[2], args[3]);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
throw new Error('isAuthorized accepts either 3 or 4 arguments');
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
static isUserGrantedWithFeature(accountId_1, userId_1, featureName_1) {
|
|
50
|
-
return __awaiter(this, arguments, void 0, function* (accountId, userId, featureName, options = {}) {
|
|
51
|
-
var _a;
|
|
52
|
-
let cachedKey = this.getCachedKeyName(userId, featureName);
|
|
53
|
-
const shouldSkipCache = (_a = options.shouldSkipCache) !== null && _a !== void 0 ? _a : false;
|
|
54
|
-
if (this.redisClient && !shouldSkipCache) {
|
|
55
|
-
let grantedFeatureValue = yield this.redisClient.get(cachedKey);
|
|
56
|
-
if (!(grantedFeatureValue === undefined || grantedFeatureValue === null)) {
|
|
57
|
-
// redis returns the value as string
|
|
58
|
-
return grantedFeatureValue === 'true';
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
let grantedFeatureValue = yield this.fetchIsUserGrantedWithFeature(featureName, accountId, userId);
|
|
62
|
-
if (this.redisClient) {
|
|
63
|
-
yield this.redisClient.set(cachedKey, grantedFeatureValue, 'EX', this.grantedFeatureRedisExpirationInSeconds);
|
|
64
|
-
}
|
|
65
|
-
return grantedFeatureValue;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
static fetchIsUserGrantedWithFeature(featureName, accountId, userId) {
|
|
69
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
let authorizationObject = {
|
|
71
|
-
action: featureName,
|
|
72
|
-
resource_type: 'feature',
|
|
73
|
-
};
|
|
74
|
-
let authorizeResponsePromise = yield this.isAuthorized(accountId, userId, [authorizationObject]);
|
|
75
|
-
return authorizeResponsePromise.isAuthorized;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
static getCachedKeyName(userId, featureName) {
|
|
79
|
-
return `granted-feature-${featureName}-${userId}`;
|
|
80
|
-
}
|
|
81
|
-
static canActionInScope(accountId, userId, action, scope) {
|
|
82
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
const scopedActions = [{ action, scope }];
|
|
84
|
-
const scopedActionResponseObjects = yield this.canActionInScopeMultiple(accountId, userId, scopedActions);
|
|
85
|
-
return scopedActionResponseObjects[0].permit;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
static canActionInScopeMultiple(accountId, userId, scopedActions) {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
const internalAuthToken = authorization_internal_service_1.AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
91
|
-
const scopedActionsPayload = scopedActions.map(scopedAction => {
|
|
92
|
-
return Object.assign(Object.assign({}, scopedAction), { scope: (0, lodash_1.mapKeys)(scopedAction.scope, (_, key) => (0, lodash_1.snakeCase)(key)) }); // for example: { workspaceId: 1 } => { workspace_id: 1 }
|
|
93
|
-
});
|
|
94
|
-
const attributionHeaders = (0, attributions_service_1.getAttributionsFromApi)();
|
|
95
|
-
const response = yield (0, monday_fetch_1.fetch)(getCanActionsInScopesUrl(), {
|
|
96
|
-
method: 'POST',
|
|
97
|
-
headers: Object.assign({ Authorization: internalAuthToken, 'Content-Type': 'application/json' }, attributionHeaders),
|
|
98
|
-
timeout: authorization_internal_service_1.AuthorizationInternalService.getRequestTimeout(),
|
|
99
|
-
body: JSON.stringify({
|
|
100
|
-
user_id: userId,
|
|
101
|
-
scoped_actions: scopedActionsPayload,
|
|
102
|
-
}),
|
|
103
|
-
}, authorization_internal_service_1.AuthorizationInternalService.getRequestFetchOptions());
|
|
104
|
-
authorization_internal_service_1.AuthorizationInternalService.throwOnHttpErrorIfNeeded(response, 'canActionInScopeMultiple');
|
|
105
|
-
const responseBody = yield response.json();
|
|
106
|
-
const camelCaseKeys = obj => Object.fromEntries(Object.entries(obj).map(([key, value]) => [(0, lodash_1.camelCase)(key), value]));
|
|
107
|
-
const scopedActionsResponseObjects = responseBody.result.map(responseObject => {
|
|
108
|
-
const { scopedAction, permit } = responseObject;
|
|
109
|
-
const { scope } = scopedAction;
|
|
110
|
-
const transformKeys = obj => camelCaseKeys(obj);
|
|
111
|
-
return Object.assign(Object.assign({}, responseObject), { scopedAction: Object.assign(Object.assign({}, scopedAction), { scope: transformKeys(scope) }), permit: transformKeys(permit) });
|
|
112
|
-
});
|
|
113
|
-
return scopedActionsResponseObjects;
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
static isAuthorizedSingular(accountId, userId, resources, action) {
|
|
117
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
const { authorizationObjects } = createAuthorizationParams(resources, action);
|
|
119
|
-
return this.isAuthorizedMultiple(accountId, userId, authorizationObjects);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
static isAuthorizedMultiple(accountId, userId, authorizationRequestObjects) {
|
|
123
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
const internalAuthToken = authorization_internal_service_1.AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
125
|
-
const startTime = perf_hooks_1.performance.now();
|
|
126
|
-
const attributionHeaders = (0, attributions_service_1.getAttributionsFromApi)();
|
|
127
|
-
const response = yield (0, monday_fetch_1.fetch)(getAuthorizeUrl(), {
|
|
128
|
-
method: 'POST',
|
|
129
|
-
headers: Object.assign({ Authorization: internalAuthToken, 'Content-Type': 'application/json' }, attributionHeaders),
|
|
130
|
-
timeout: authorization_internal_service_1.AuthorizationInternalService.getRequestTimeout(),
|
|
131
|
-
body: JSON.stringify({
|
|
132
|
-
user_id: userId,
|
|
133
|
-
authorize_request_objects: authorizationRequestObjects,
|
|
134
|
-
}),
|
|
135
|
-
}, authorization_internal_service_1.AuthorizationInternalService.getRequestFetchOptions());
|
|
136
|
-
const endTime = perf_hooks_1.performance.now();
|
|
137
|
-
const time = endTime - startTime;
|
|
138
|
-
const responseStatus = response.status;
|
|
139
|
-
(0, prometheus_service_1.sendAuthorizationChecksPerRequestMetric)(responseStatus, authorizationRequestObjects.length);
|
|
140
|
-
authorization_internal_service_1.AuthorizationInternalService.throwOnHttpErrorIfNeeded(response, 'isAuthorizedMultiple');
|
|
141
|
-
const responseBody = yield response.json();
|
|
142
|
-
const unauthorizedObjects = [];
|
|
143
|
-
responseBody.result.forEach(function (isAuthorized, index) {
|
|
144
|
-
const authorizationObject = authorizationRequestObjects[index];
|
|
145
|
-
if (!isAuthorized) {
|
|
146
|
-
unauthorizedObjects.push(authorizationObject);
|
|
147
|
-
}
|
|
148
|
-
(0, prometheus_service_1.sendAuthorizationCheckResponseTimeMetric)(authorizationObject.resource_type, authorizationObject.action, isAuthorized, responseStatus, time);
|
|
149
|
-
});
|
|
150
|
-
if (unauthorizedObjects.length > 0) {
|
|
151
|
-
authorization_internal_service_1.logger.info({
|
|
152
|
-
resources: JSON.stringify(unauthorizedObjects),
|
|
153
|
-
}, 'AuthorizationService: resource is unauthorized');
|
|
154
|
-
const unauthorizedIds = unauthorizedObjects
|
|
155
|
-
.filter(obj => !!obj.resource_id)
|
|
156
|
-
.map(obj => obj.resource_id);
|
|
157
|
-
return { isAuthorized: false, unauthorizedIds, unauthorizedObjects };
|
|
158
|
-
}
|
|
159
|
-
return { isAuthorized: true };
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
exports.AuthorizationService = AuthorizationService;
|
|
164
|
-
function createAuthorizationParams(resources, action) {
|
|
165
|
-
const params = {
|
|
166
|
-
authorizationObjects: resources.map((resource) => {
|
|
167
|
-
const authorizationObject = {
|
|
168
|
-
resource_id: resource.id,
|
|
169
|
-
resource_type: resource.type,
|
|
170
|
-
action,
|
|
171
|
-
};
|
|
172
|
-
if (resource.wrapperData) {
|
|
173
|
-
authorizationObject.wrapper_data = resource.wrapperData;
|
|
174
|
-
}
|
|
175
|
-
return authorizationObject;
|
|
176
|
-
}),
|
|
177
|
-
};
|
|
178
|
-
return params;
|
|
179
|
-
}
|
|
180
|
-
function getAuthorizeUrl() {
|
|
181
|
-
return `${process.env.MONDAY_INTERNAL_URL}/internal_ms/authorization/authorize`;
|
|
182
|
-
}
|
|
183
|
-
function getCanActionsInScopesUrl() {
|
|
184
|
-
return `${process.env.MONDAY_INTERNAL_URL}/internal_ms/authorization/can_actions_in_scopes`;
|
|
185
|
-
}
|
|
186
|
-
//# sourceMappingURL=authorization-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-service.js","sourceRoot":"","sources":["../../lib/authorization-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAyBA,wDAEC;AAED,wCAcC;AA3CD,mCAAuD;AACvD,2CAAyC;AACzC,gEAA0E;AAE1E,6DAG8B;AAO9B,qFAAwF;AACxF,iEAAgE;AAEhE,MAAM,wCAAwC,GAAG,CAAC,GAAG,EAAE,CAAC;AAQxD,SAAgB,sBAAsB,CAAC,wBAA4C;IACjF,6DAA4B,CAAC,sBAAsB,CAAC,wBAAwB,CAAC,CAAC;AAChF,CAAC;AAED,SAAgB,cAAc,CAC5B,MAAM,EACN,yCAAiD,wCAAwC;IAEzF,oBAAoB,CAAC,WAAW,GAAG,MAAM,CAAC;IAC1C,IAAI,sCAAsC,IAAI,sCAAsC,GAAG,CAAC,EAAE,CAAC;QACzF,oBAAoB,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;IACvG,CAAC;SAAM,CAAC;QACN,uC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AC;gBAC3C,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,CAAC;YACvE,CAAC;YAED,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QAChC,CAAC;KAAA;CACF;AA9MD,oDA8MC;AAED,SAAS,yBAAyB,CAAC,SAAqB,EAAE,MAAc;IACtE,MAAM,MAAM,GAAG;QACb,oBAAoB,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,QAAkB,EAAE,EAAE;YACzD,MAAM,mBAAmB,GAAwB;gBAC/C,WAAW,EAAE,QAAQ,CAAC,EAAE;gBACxB,aAAa,EAAE,QAAQ,CAAC,IAAI;gBAC5B,MAAM;aACP,CAAC;YACF,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;gBACzB,mBAAmB,CAAC,YAAY,GAAG,QAAQ,CAAC,WAAW,CAAC;YAC1D,CAAC;YACD,OAAO,mBAAmB,CAAC;QAC7B,CAAC,CAAC;KACH,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,sCAAsC,CAAC;AAClF,CAAC;AAED,SAAS,wBAAwB;IAC/B,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,kDAAkD,CAAC;AAC9F,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ASYNC_MAX_OPERATIONS_PER_MESSAGE = exports.RESOURCE_ATTRIBUTES_SNS_MESSAGE_KIND = exports.RESOURCE_ATTRIBUTES_SECRET_NAME = void 0;
|
|
4
|
-
exports.RESOURCE_ATTRIBUTES_SECRET_NAME = 'AUTHORIZATION_RESOURCE_ATTRIBUTES_SNS_TOPIC';
|
|
5
|
-
exports.RESOURCE_ATTRIBUTES_SNS_MESSAGE_KIND = 'resourceAttributeModification';
|
|
6
|
-
exports.ASYNC_MAX_OPERATIONS_PER_MESSAGE = 100;
|
|
7
|
-
//# sourceMappingURL=sns.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sns.js","sourceRoot":"","sources":["../../../lib/constants/sns.ts"],"names":[],"mappings":";;;AAAa,QAAA,+BAA+B,GAAG,6CAA6C,CAAA;AAC/E,QAAA,oCAAoC,GAAG,+BAA+B,CAAC;AACvE,QAAA,gCAAgC,GAAG,GAAG,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Action } from './types/general';
|
|
2
|
-
export declare const METRICS: {
|
|
3
|
-
AUTHORIZATION_CHECK: string;
|
|
4
|
-
AUTHORIZATION_CHECKS_PER_REQUEST: string;
|
|
5
|
-
AUTHORIZATION_CHECK_RESPONSE_TIME: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function setPrometheus(customPrometheus: any): void;
|
|
8
|
-
export declare function getMetricsManager(): any;
|
|
9
|
-
export declare function sendAuthorizationChecksPerRequestMetric(responseStatus: any, amountOfAuthorizationObjects: any): void;
|
|
10
|
-
export declare function sendAuthorizationCheckResponseTimeMetric(resourceType: string, action: Action, isAuthorized: boolean, responseStatus: number, time: number): void;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.METRICS = void 0;
|
|
4
|
-
exports.setPrometheus = setPrometheus;
|
|
5
|
-
exports.getMetricsManager = getMetricsManager;
|
|
6
|
-
exports.sendAuthorizationChecksPerRequestMetric = sendAuthorizationChecksPerRequestMetric;
|
|
7
|
-
exports.sendAuthorizationCheckResponseTimeMetric = sendAuthorizationCheckResponseTimeMetric;
|
|
8
|
-
let prometheus = null;
|
|
9
|
-
let authorizationChecksPerRequestMetric = null;
|
|
10
|
-
let authorizationCheckResponseTimeMetric = null;
|
|
11
|
-
exports.METRICS = {
|
|
12
|
-
AUTHORIZATION_CHECK: 'authorization_check',
|
|
13
|
-
AUTHORIZATION_CHECKS_PER_REQUEST: 'authorization_checks_per_request',
|
|
14
|
-
AUTHORIZATION_CHECK_RESPONSE_TIME: 'authorization_check_response_time',
|
|
15
|
-
};
|
|
16
|
-
const authorizationChecksPerRequestMetricConfig = {
|
|
17
|
-
name: exports.METRICS.AUTHORIZATION_CHECKS_PER_REQUEST,
|
|
18
|
-
labels: ['responseStatus'],
|
|
19
|
-
description: 'Authorization checks per request summary',
|
|
20
|
-
};
|
|
21
|
-
const authorizationCheckResponseTimeMetricConfig = {
|
|
22
|
-
name: exports.METRICS.AUTHORIZATION_CHECK_RESPONSE_TIME,
|
|
23
|
-
labels: ['resourceType', 'action', 'isAuthorized', 'responseStatus'],
|
|
24
|
-
description: 'Authorization check response time summary',
|
|
25
|
-
};
|
|
26
|
-
function setPrometheus(customPrometheus) {
|
|
27
|
-
prometheus = customPrometheus;
|
|
28
|
-
const { METRICS_TYPES } = prometheus;
|
|
29
|
-
authorizationChecksPerRequestMetric = getMetricsManager().addMetric(METRICS_TYPES.SUMMARY, authorizationChecksPerRequestMetricConfig.name, authorizationChecksPerRequestMetricConfig.labels, authorizationChecksPerRequestMetricConfig.description);
|
|
30
|
-
authorizationCheckResponseTimeMetric = getMetricsManager().addMetric(METRICS_TYPES.SUMMARY, authorizationCheckResponseTimeMetricConfig.name, authorizationCheckResponseTimeMetricConfig.labels, authorizationCheckResponseTimeMetricConfig.description);
|
|
31
|
-
}
|
|
32
|
-
function getMetricsManager() {
|
|
33
|
-
return prometheus === null || prometheus === void 0 ? void 0 : prometheus.metricsManager;
|
|
34
|
-
}
|
|
35
|
-
function sendAuthorizationChecksPerRequestMetric(responseStatus, amountOfAuthorizationObjects) {
|
|
36
|
-
try {
|
|
37
|
-
if (authorizationChecksPerRequestMetric) {
|
|
38
|
-
authorizationChecksPerRequestMetric.labels(responseStatus).observe(amountOfAuthorizationObjects);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch (e) { }
|
|
42
|
-
}
|
|
43
|
-
function sendAuthorizationCheckResponseTimeMetric(resourceType, action, isAuthorized, responseStatus, time) {
|
|
44
|
-
try {
|
|
45
|
-
if (authorizationCheckResponseTimeMetric) {
|
|
46
|
-
authorizationCheckResponseTimeMetric.labels(resourceType, action, isAuthorized, responseStatus).observe(time);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch (e) { }
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=prometheus-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-service.js","sourceRoot":"","sources":["../../lib/prometheus-service.ts"],"names":[],"mappings":";;;AAwBA,sCAiBC;AAED,8CAEC;AAED,0FAMC;AAED,4FAYC;AAjED,IAAI,UAAU,GAAQ,IAAI,CAAC;AAC3B,IAAI,mCAAmC,GAAQ,IAAI,CAAC;AACpD,IAAI,oCAAoC,GAAQ,IAAI,CAAC;AAExC,QAAA,OAAO,GAAG;IACrB,mBAAmB,EAAE,qBAAqB;IAC1C,gCAAgC,EAAE,kCAAkC;IACpE,iCAAiC,EAAE,mCAAmC;CACvE,CAAC;AAEF,MAAM,yCAAyC,GAAG;IAChD,IAAI,EAAE,eAAO,CAAC,gCAAgC;IAC9C,MAAM,EAAE,CAAC,gBAAgB,CAAC;IAC1B,WAAW,EAAE,0CAA0C;CACxD,CAAC;AAEF,MAAM,0CAA0C,GAAG;IACjD,IAAI,EAAE,eAAO,CAAC,iCAAiC;IAC/C,MAAM,EAAE,CAAC,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,CAAC;IACpE,WAAW,EAAE,2CAA2C;CACzD,CAAC;AAEF,SAAgB,aAAa,CAAC,gBAAgB;IAC5C,UAAU,GAAG,gBAAgB,CAAC;IAC9B,MAAM,EAAE,aAAa,EAAE,GAAG,UAAU,CAAC;IAErC,mCAAmC,GAAG,iBAAiB,EAAE,CAAC,SAAS,CACjE,aAAa,CAAC,OAAO,EACrB,yCAAyC,CAAC,IAAI,EAC9C,yCAAyC,CAAC,MAAM,EAChD,yCAAyC,CAAC,WAAW,CACtD,CAAC;IAEF,oCAAoC,GAAG,iBAAiB,EAAE,CAAC,SAAS,CAClE,aAAa,CAAC,OAAO,EACrB,0CAA0C,CAAC,IAAI,EAC/C,0CAA0C,CAAC,MAAM,EACjD,0CAA0C,CAAC,WAAW,CACvD,CAAC;AACJ,CAAC;AAED,SAAgB,iBAAiB;IAC/B,OAAO,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,cAAc,CAAC;AACpC,CAAC;AAED,SAAgB,uCAAuC,CAAC,cAAc,EAAE,4BAA4B;IAClG,IAAI,CAAC;QACH,IAAI,mCAAmC,EAAE,CAAC;YACxC,mCAAmC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAC;QACnG,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;AAChB,CAAC;AAED,SAAgB,wCAAwC,CACtD,YAAoB,EACpB,MAAc,EACd,YAAqB,EACrB,cAAsB,EACtB,IAAY;IAEZ,IAAI,CAAC;QACH,IAAI,oCAAoC,EAAE,CAAC;YACzC,oCAAoC,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChH,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;AAChB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { NextFunction } from "express";
|
|
2
|
-
import { Action, BaseRequest, BaseResponse, ContextGetter, Resource, ResourceGetter } from "../types/general";
|
|
3
|
-
export type TestPermittedAction = {
|
|
4
|
-
accountId: number;
|
|
5
|
-
userId: number;
|
|
6
|
-
resources: Resource[];
|
|
7
|
-
action: Action;
|
|
8
|
-
};
|
|
9
|
-
export declare const addTestPermittedAction: (accountId: number, userId: number, resources: Resource[], action: Action) => void;
|
|
10
|
-
export declare const clearTestPermittedActions: () => void;
|
|
11
|
-
export declare const getTestAuthorizationMiddleware: (action: Action, resourceGetter: ResourceGetter, contextGetter?: ContextGetter) => (request: BaseRequest, response: BaseResponse, next: NextFunction) => Promise<void>;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getTestAuthorizationMiddleware = exports.clearTestPermittedActions = exports.addTestPermittedAction = void 0;
|
|
13
|
-
const authorization_middleware_1 = require("../authorization-middleware");
|
|
14
|
-
const authorization_internal_service_1 = require("../authorization-internal-service");
|
|
15
|
-
let testPermittedActions = [];
|
|
16
|
-
const addTestPermittedAction = (accountId, userId, resources, action) => {
|
|
17
|
-
testPermittedActions.push({ accountId, userId, resources, action });
|
|
18
|
-
};
|
|
19
|
-
exports.addTestPermittedAction = addTestPermittedAction;
|
|
20
|
-
const clearTestPermittedActions = () => {
|
|
21
|
-
testPermittedActions = [];
|
|
22
|
-
};
|
|
23
|
-
exports.clearTestPermittedActions = clearTestPermittedActions;
|
|
24
|
-
const isActionAuthorized = (accountId, userId, resources, action) => {
|
|
25
|
-
return {
|
|
26
|
-
isAuthorized: resources.every(resource => {
|
|
27
|
-
return testPermittedActions.some(combination => {
|
|
28
|
-
return combination.accountId === accountId &&
|
|
29
|
-
combination.userId === userId &&
|
|
30
|
-
combination.action === action &&
|
|
31
|
-
combination.resources.some(combinationResource => {
|
|
32
|
-
return resources.some(resource => {
|
|
33
|
-
return combinationResource.id === resource.id &&
|
|
34
|
-
combinationResource.type === resource.type &&
|
|
35
|
-
JSON.stringify(combinationResource.wrapperData) === JSON.stringify(resource.wrapperData);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
})
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
const getTestAuthorizationMiddleware = (action, resourceGetter, contextGetter) => {
|
|
43
|
-
return function authorizationMiddleware(request, response, next) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
contextGetter || (contextGetter = authorization_middleware_1.defaultContextGetter);
|
|
46
|
-
const { userId, accountId } = contextGetter(request);
|
|
47
|
-
const resources = resourceGetter(request);
|
|
48
|
-
const { isAuthorized } = isActionAuthorized(accountId, userId, resources, action);
|
|
49
|
-
authorization_internal_service_1.AuthorizationInternalService.markAuthorized(request);
|
|
50
|
-
if (!isAuthorized) {
|
|
51
|
-
response.status(403).json({ message: 'Access denied' });
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
next();
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
exports.getTestAuthorizationMiddleware = getTestAuthorizationMiddleware;
|
|
59
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/testKit/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,0EAAiE;AACjE,sFAA+E;AAS/E,IAAI,oBAAoB,GAA0B,EAAE,CAAC;AAC9C,MAAM,sBAAsB,GAAG,CAAC,SAAiB,EAAE,MAAc,EAAE,SAAqB,EAAE,MAAc,EAAE,EAAE;IACjH,oBAAoB,CAAC,IAAI,CAAC,EAAE,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vC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;YACrD,MAAM,SAAS,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;YAC1C,MAAM,EAAE,YAAY,EAAE,GAAG,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YAClF,6DAA4B,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YACrD,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;gBACxD,OAAO;YACT,CAAC;YACD,IAAI,EAAE,CAAC;QACT,CAAC;KAAA,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,8BAA8B,kCAqBzC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Resource } from './general';
|
|
2
|
-
export interface ResourceAttributeAssignment {
|
|
3
|
-
resourceType: Resource['type'];
|
|
4
|
-
resourceId: Resource['id'];
|
|
5
|
-
key: string;
|
|
6
|
-
value: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ResourceAttributeResponse {
|
|
9
|
-
attributes: ResourceAttributeAssignment[];
|
|
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,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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 = {}));
|
|
9
|
-
//# sourceMappingURL=authorization-attributes-contracts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../../lib/types/express.ts"],"names":[],"mappings":""}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
2
|
-
export interface Resource {
|
|
3
|
-
id?: number;
|
|
4
|
-
type: string;
|
|
5
|
-
wrapperData?: object;
|
|
6
|
-
}
|
|
7
|
-
export type Action = string;
|
|
8
|
-
export type ResourceGetter = (request: BaseRequest) => Resource[];
|
|
9
|
-
export interface Context {
|
|
10
|
-
accountId: number;
|
|
11
|
-
userId: number;
|
|
12
|
-
}
|
|
13
|
-
export type ContextGetter = (request: BaseRequest) => Context;
|
|
14
|
-
export interface AuthorizationObject {
|
|
15
|
-
resource_id?: Resource['id'];
|
|
16
|
-
resource_type: Resource['type'];
|
|
17
|
-
wrapper_data?: Resource['wrapperData'];
|
|
18
|
-
action: Action;
|
|
19
|
-
}
|
|
20
|
-
export interface AuthorizationParams {
|
|
21
|
-
authorizationObjects: AuthorizationObject[];
|
|
22
|
-
}
|
|
23
|
-
type BasicObject = {};
|
|
24
|
-
export type BaseParameters = BasicObject;
|
|
25
|
-
export type BaseResponseBody = BasicObject;
|
|
26
|
-
export type BaseBodyParameters = BasicObject;
|
|
27
|
-
export type BaseQueryParameters = BasicObject;
|
|
28
|
-
export type BaseRequest = Request<BaseParameters, BaseResponseBody, BaseBodyParameters, BaseQueryParameters>;
|
|
29
|
-
export type BaseResponse = Response<BaseResponseBody>;
|
|
30
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"general.js","sourceRoot":"","sources":["../../../lib/types/general.ts"],"names":[],"mappings":""}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export interface WorkspaceScope {
|
|
2
|
-
workspaceId: number;
|
|
3
|
-
}
|
|
4
|
-
export interface BoardScope {
|
|
5
|
-
boardId: number;
|
|
6
|
-
}
|
|
7
|
-
export interface PulseScope {
|
|
8
|
-
pulseId: number;
|
|
9
|
-
}
|
|
10
|
-
export interface AccountProductScope {
|
|
11
|
-
accountProductId: number;
|
|
12
|
-
}
|
|
13
|
-
export interface AccountScope {
|
|
14
|
-
accountId: number;
|
|
15
|
-
}
|
|
16
|
-
export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope;
|
|
17
|
-
export interface Translation {
|
|
18
|
-
key: string;
|
|
19
|
-
[option: string]: string;
|
|
20
|
-
}
|
|
21
|
-
export declare enum PermitTechnicalReason {
|
|
22
|
-
NO_REASON = 0,
|
|
23
|
-
NOT_ELIGIBLE = 1,
|
|
24
|
-
BY_ROLE_IN_SCOPE = 2
|
|
25
|
-
}
|
|
26
|
-
export interface ScopedActionPermit {
|
|
27
|
-
can: boolean;
|
|
28
|
-
reason: Translation;
|
|
29
|
-
technicalReason: PermitTechnicalReason;
|
|
30
|
-
}
|
|
31
|
-
export interface ScopedAction {
|
|
32
|
-
action: string;
|
|
33
|
-
scope: ScopeOptions;
|
|
34
|
-
}
|
|
35
|
-
export interface ScopedActionResponseObject {
|
|
36
|
-
scopedAction: ScopedAction;
|
|
37
|
-
permit: ScopedActionPermit;
|
|
38
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PermitTechnicalReason = void 0;
|
|
4
|
-
var PermitTechnicalReason;
|
|
5
|
-
(function (PermitTechnicalReason) {
|
|
6
|
-
PermitTechnicalReason[PermitTechnicalReason["NO_REASON"] = 0] = "NO_REASON";
|
|
7
|
-
PermitTechnicalReason[PermitTechnicalReason["NOT_ELIGIBLE"] = 1] = "NOT_ELIGIBLE";
|
|
8
|
-
PermitTechnicalReason[PermitTechnicalReason["BY_ROLE_IN_SCOPE"] = 2] = "BY_ROLE_IN_SCOPE";
|
|
9
|
-
})(PermitTechnicalReason || (exports.PermitTechnicalReason = PermitTechnicalReason = {}));
|
|
10
|
-
//# sourceMappingURL=scoped-actions-contracts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scoped-actions-contracts.js","sourceRoot":"","sources":["../../../lib/types/scoped-actions-contracts.ts"],"names":[],"mappings":";;;AA2BA,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,2EAAa,CAAA;IACb,iFAAgB,CAAA;IAChB,yFAAoB,CAAA;AACtB,CAAC,EAJW,qBAAqB,qCAArB,qBAAqB,QAIhC"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|