@mondaydotcomorg/monday-authorization 1.2.10 → 1.2.12
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/README.md +25 -0
- package/dist/{lib/attributions-service.js → attributions-service.js} +11 -10
- package/dist/authorization-attributes-service.js +144 -0
- package/dist/{lib/authorization-internal-service.d.ts → authorization-internal-service.d.ts} +1 -1
- package/dist/authorization-internal-service.js +80 -0
- package/dist/{lib/authorization-middleware.d.ts → authorization-middleware.d.ts} +1 -1
- package/dist/authorization-middleware.js +48 -0
- package/dist/authorization-service.js +176 -0
- package/dist/constants/sns.js +9 -0
- package/dist/esm/attributions-service.d.ts +3 -0
- package/dist/esm/attributions-service.mjs +53 -0
- package/dist/esm/authorization-attributes-service.d.ts +44 -0
- package/dist/esm/authorization-attributes-service.mjs +138 -0
- package/dist/esm/authorization-internal-service.d.ts +13 -0
- package/dist/esm/authorization-internal-service.mjs +57 -0
- package/dist/esm/authorization-middleware.d.ts +6 -0
- package/dist/esm/authorization-middleware.mjs +39 -0
- package/dist/esm/authorization-service.d.ts +29 -0
- package/dist/esm/authorization-service.mjs +172 -0
- package/dist/esm/constants/sns.d.ts +3 -0
- package/dist/esm/constants/sns.mjs +5 -0
- package/dist/esm/index.d.ts +13 -0
- package/dist/esm/index.mjs +21 -0
- package/dist/esm/prometheus-service.mjs +49 -0
- package/dist/{lib → esm}/testKit/index.d.ts +2 -2
- package/dist/esm/testKit/index.mjs +44 -0
- package/dist/esm/types/authorization-attributes-contracts.mjs +7 -0
- package/dist/esm/types/express.mjs +1 -0
- package/dist/{lib → esm}/types/general.d.ts +6 -4
- package/dist/esm/types/general.mjs +1 -0
- package/dist/esm/types/scoped-actions-contracts.mjs +8 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +19 -43
- package/dist/prometheus-service.d.ts +10 -0
- package/dist/{lib/prometheus-service.js → prometheus-service.js} +18 -14
- package/dist/testKit/index.d.ts +11 -0
- package/dist/testKit/index.js +48 -0
- package/dist/types/authorization-attributes-contracts.d.ts +27 -0
- package/dist/types/authorization-attributes-contracts.js +7 -0
- package/dist/types/express.d.ts +10 -0
- package/dist/types/express.js +1 -0
- package/dist/types/general.d.ts +32 -0
- package/dist/types/general.js +1 -0
- package/dist/types/scoped-actions-contracts.d.ts +38 -0
- package/dist/{lib/types → types}/scoped-actions-contracts.js +3 -5
- package/package.json +25 -28
- package/dist/index.js.map +0 -1
- package/dist/lib/attributions-service.js.map +0 -1
- package/dist/lib/authorization-attributes-service.js +0 -155
- package/dist/lib/authorization-attributes-service.js.map +0 -1
- package/dist/lib/authorization-internal-service.js +0 -79
- package/dist/lib/authorization-internal-service.js.map +0 -1
- package/dist/lib/authorization-middleware.js +0 -57
- package/dist/lib/authorization-middleware.js.map +0 -1
- package/dist/lib/authorization-service.js +0 -186
- package/dist/lib/authorization-service.js.map +0 -1
- package/dist/lib/constants/sns.js +0 -7
- package/dist/lib/constants/sns.js.map +0 -1
- package/dist/lib/prometheus-service.js.map +0 -1
- package/dist/lib/testKit/index.js +0 -59
- package/dist/lib/testKit/index.js.map +0 -1
- 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.js +0 -2
- package/dist/lib/types/express.js.map +0 -1
- package/dist/lib/types/general.js +0 -3
- package/dist/lib/types/general.js.map +0 -1
- package/dist/lib/types/scoped-actions-contracts.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/{lib/attributions-service.d.ts → attributions-service.d.ts} +0 -0
- package/dist/{lib/authorization-attributes-service.d.ts → authorization-attributes-service.d.ts} +0 -0
- package/dist/{lib/authorization-service.d.ts → authorization-service.d.ts} +1 -1
- /package/dist/{lib/constants → constants}/sns.d.ts +0 -0
- /package/dist/{lib → esm}/prometheus-service.d.ts +0 -0
- /package/dist/{lib → esm}/types/authorization-attributes-contracts.d.ts +0 -0
- /package/dist/{lib → esm}/types/express.d.ts +0 -0
- /package/dist/{lib → esm}/types/scoped-actions-contracts.d.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var ResourceAttributeOperationEnum;
|
|
2
|
+
(function (ResourceAttributeOperationEnum) {
|
|
3
|
+
ResourceAttributeOperationEnum["UPSERT"] = "upsert";
|
|
4
|
+
ResourceAttributeOperationEnum["DELETE"] = "delete";
|
|
5
|
+
})(ResourceAttributeOperationEnum || (ResourceAttributeOperationEnum = {}));
|
|
6
|
+
|
|
7
|
+
export { ResourceAttributeOperationEnum };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
1
|
+
import type { Request, Response } from 'express';
|
|
2
2
|
export interface Resource {
|
|
3
3
|
id?: number;
|
|
4
4
|
type: string;
|
|
5
5
|
wrapperData?: object;
|
|
6
6
|
}
|
|
7
7
|
export type Action = string;
|
|
8
|
-
export type ResourceGetter = (request: BaseRequest) => Resource[];
|
|
9
8
|
export interface Context {
|
|
10
9
|
accountId: number;
|
|
11
10
|
userId: number;
|
|
12
11
|
}
|
|
13
|
-
export type ContextGetter = (request: BaseRequest) => Context;
|
|
14
12
|
export interface AuthorizationObject {
|
|
15
13
|
resource_id?: Resource['id'];
|
|
16
14
|
resource_type: Resource['type'];
|
|
@@ -20,11 +18,15 @@ export interface AuthorizationObject {
|
|
|
20
18
|
export interface AuthorizationParams {
|
|
21
19
|
authorizationObjects: AuthorizationObject[];
|
|
22
20
|
}
|
|
23
|
-
type BasicObject = {
|
|
21
|
+
type BasicObject = {
|
|
22
|
+
[key: string]: string;
|
|
23
|
+
};
|
|
24
24
|
export type BaseParameters = BasicObject;
|
|
25
25
|
export type BaseResponseBody = BasicObject;
|
|
26
26
|
export type BaseBodyParameters = BasicObject;
|
|
27
27
|
export type BaseQueryParameters = BasicObject;
|
|
28
28
|
export type BaseRequest = Request<BaseParameters, BaseResponseBody, BaseBodyParameters, BaseQueryParameters>;
|
|
29
29
|
export type BaseResponse = Response<BaseResponseBody>;
|
|
30
|
+
export type ResourceGetter = (request: BaseRequest) => Resource[];
|
|
31
|
+
export type ContextGetter = (request: BaseRequest) => Context;
|
|
30
32
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var PermitTechnicalReason;
|
|
2
|
+
(function (PermitTechnicalReason) {
|
|
3
|
+
PermitTechnicalReason[PermitTechnicalReason["NO_REASON"] = 0] = "NO_REASON";
|
|
4
|
+
PermitTechnicalReason[PermitTechnicalReason["NOT_ELIGIBLE"] = 1] = "NOT_ELIGIBLE";
|
|
5
|
+
PermitTechnicalReason[PermitTechnicalReason["BY_ROLE_IN_SCOPE"] = 2] = "BY_ROLE_IN_SCOPE";
|
|
6
|
+
})(PermitTechnicalReason || (PermitTechnicalReason = {}));
|
|
7
|
+
|
|
8
|
+
export { PermitTechnicalReason };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
|
|
2
|
-
import * as TestKit from './
|
|
2
|
+
import * as TestKit from './testKit';
|
|
3
3
|
export interface InitOptions {
|
|
4
4
|
prometheus?: any;
|
|
5
5
|
mondayFetchOptions?: MondayFetchOptions;
|
|
@@ -7,7 +7,7 @@ export interface InitOptions {
|
|
|
7
7
|
grantedFeatureRedisExpirationInSeconds?: number;
|
|
8
8
|
}
|
|
9
9
|
export declare function init(options?: InitOptions): void;
|
|
10
|
-
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './
|
|
11
|
-
export { AuthorizationService } from './
|
|
12
|
-
export { AuthorizationAttributesService } from './
|
|
10
|
+
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './authorization-middleware';
|
|
11
|
+
export { AuthorizationService } from './authorization-service';
|
|
12
|
+
export { AuthorizationAttributesService } from './authorization-attributes-service';
|
|
13
13
|
export { TestKit };
|
package/dist/index.js
CHANGED
|
@@ -1,51 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const prometheusService = require('./prometheus-service.js');
|
|
4
|
+
const authorizationService = require('./authorization-service.js');
|
|
5
|
+
const testKit_index = require('./testKit/index.js');
|
|
6
|
+
const authorizationMiddleware = require('./authorization-middleware.js');
|
|
7
|
+
const authorizationAttributesService = require('./authorization-attributes-service.js');
|
|
8
|
+
|
|
32
9
|
function init(options = {}) {
|
|
33
10
|
if (options.prometheus) {
|
|
34
|
-
|
|
11
|
+
prometheusService.setPrometheus(options.prometheus);
|
|
35
12
|
}
|
|
36
13
|
if (options.mondayFetchOptions) {
|
|
37
|
-
|
|
14
|
+
authorizationService.setRequestFetchOptions(options.mondayFetchOptions);
|
|
38
15
|
}
|
|
39
16
|
if (options.redisClient) {
|
|
40
|
-
|
|
17
|
+
authorizationService.setRedisClient(options.redisClient, options.grantedFeatureRedisExpirationInSeconds);
|
|
41
18
|
}
|
|
42
19
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=index.js.map
|
|
20
|
+
|
|
21
|
+
exports.AuthorizationService = authorizationService.AuthorizationService;
|
|
22
|
+
exports.TestKit = testKit_index;
|
|
23
|
+
exports.authorizationCheckMiddleware = authorizationMiddleware.authorizationCheckMiddleware;
|
|
24
|
+
exports.getAuthorizationMiddleware = authorizationMiddleware.getAuthorizationMiddleware;
|
|
25
|
+
exports.skipAuthorizationMiddleware = authorizationMiddleware.skipAuthorizationMiddleware;
|
|
26
|
+
exports.AuthorizationAttributesService = authorizationAttributesService.AuthorizationAttributesService;
|
|
27
|
+
exports.init = init;
|
|
@@ -0,0 +1,10 @@
|
|
|
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,25 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.METRICS = void 0;
|
|
4
|
-
exports.setPrometheus = setPrometheus;
|
|
5
|
-
exports.getMetricsManager = getMetricsManager;
|
|
6
|
-
exports.sendAuthorizationChecksPerRequestMetric = sendAuthorizationChecksPerRequestMetric;
|
|
7
|
-
exports.sendAuthorizationCheckResponseTimeMetric = sendAuthorizationCheckResponseTimeMetric;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
8
3
|
let prometheus = null;
|
|
9
4
|
let authorizationChecksPerRequestMetric = null;
|
|
10
5
|
let authorizationCheckResponseTimeMetric = null;
|
|
11
|
-
|
|
6
|
+
const METRICS = {
|
|
12
7
|
AUTHORIZATION_CHECK: 'authorization_check',
|
|
13
8
|
AUTHORIZATION_CHECKS_PER_REQUEST: 'authorization_checks_per_request',
|
|
14
9
|
AUTHORIZATION_CHECK_RESPONSE_TIME: 'authorization_check_response_time',
|
|
15
10
|
};
|
|
16
11
|
const authorizationChecksPerRequestMetricConfig = {
|
|
17
|
-
name:
|
|
12
|
+
name: METRICS.AUTHORIZATION_CHECKS_PER_REQUEST,
|
|
18
13
|
labels: ['responseStatus'],
|
|
19
14
|
description: 'Authorization checks per request summary',
|
|
20
15
|
};
|
|
21
16
|
const authorizationCheckResponseTimeMetricConfig = {
|
|
22
|
-
name:
|
|
17
|
+
name: METRICS.AUTHORIZATION_CHECK_RESPONSE_TIME,
|
|
23
18
|
labels: ['resourceType', 'action', 'isAuthorized', 'responseStatus'],
|
|
24
19
|
description: 'Authorization check response time summary',
|
|
25
20
|
};
|
|
@@ -30,7 +25,7 @@ function setPrometheus(customPrometheus) {
|
|
|
30
25
|
authorizationCheckResponseTimeMetric = getMetricsManager().addMetric(METRICS_TYPES.SUMMARY, authorizationCheckResponseTimeMetricConfig.name, authorizationCheckResponseTimeMetricConfig.labels, authorizationCheckResponseTimeMetricConfig.description);
|
|
31
26
|
}
|
|
32
27
|
function getMetricsManager() {
|
|
33
|
-
return prometheus
|
|
28
|
+
return prometheus?.metricsManager;
|
|
34
29
|
}
|
|
35
30
|
function sendAuthorizationChecksPerRequestMetric(responseStatus, amountOfAuthorizationObjects) {
|
|
36
31
|
try {
|
|
@@ -38,7 +33,9 @@ function sendAuthorizationChecksPerRequestMetric(responseStatus, amountOfAuthori
|
|
|
38
33
|
authorizationChecksPerRequestMetric.labels(responseStatus).observe(amountOfAuthorizationObjects);
|
|
39
34
|
}
|
|
40
35
|
}
|
|
41
|
-
catch (e) {
|
|
36
|
+
catch (e) {
|
|
37
|
+
// ignore
|
|
38
|
+
}
|
|
42
39
|
}
|
|
43
40
|
function sendAuthorizationCheckResponseTimeMetric(resourceType, action, isAuthorized, responseStatus, time) {
|
|
44
41
|
try {
|
|
@@ -46,6 +43,13 @@ function sendAuthorizationCheckResponseTimeMetric(resourceType, action, isAuthor
|
|
|
46
43
|
authorizationCheckResponseTimeMetric.labels(resourceType, action, isAuthorized, responseStatus).observe(time);
|
|
47
44
|
}
|
|
48
45
|
}
|
|
49
|
-
catch (e) {
|
|
46
|
+
catch (e) {
|
|
47
|
+
// ignore
|
|
48
|
+
}
|
|
50
49
|
}
|
|
51
|
-
|
|
50
|
+
|
|
51
|
+
exports.METRICS = METRICS;
|
|
52
|
+
exports.getMetricsManager = getMetricsManager;
|
|
53
|
+
exports.sendAuthorizationCheckResponseTimeMetric = sendAuthorizationCheckResponseTimeMetric;
|
|
54
|
+
exports.sendAuthorizationChecksPerRequestMetric = sendAuthorizationChecksPerRequestMetric;
|
|
55
|
+
exports.setPrometheus = setPrometheus;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Action, BaseRequest, BaseResponse, ContextGetter, Resource, ResourceGetter } from '../types/general';
|
|
2
|
+
import type { NextFunction } from 'express';
|
|
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>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const authorizationMiddleware = require('../authorization-middleware.js');
|
|
4
|
+
const authorizationInternalService = require('../authorization-internal-service.js');
|
|
5
|
+
|
|
6
|
+
let testPermittedActions = [];
|
|
7
|
+
const addTestPermittedAction = (accountId, userId, resources, action) => {
|
|
8
|
+
testPermittedActions.push({ accountId, userId, resources, action });
|
|
9
|
+
};
|
|
10
|
+
const clearTestPermittedActions = () => {
|
|
11
|
+
testPermittedActions = [];
|
|
12
|
+
};
|
|
13
|
+
const isActionAuthorized = (accountId, userId, resources, action) => {
|
|
14
|
+
return {
|
|
15
|
+
isAuthorized: resources.every(_ => {
|
|
16
|
+
return testPermittedActions.some(combination => {
|
|
17
|
+
return (combination.accountId === accountId &&
|
|
18
|
+
combination.userId === userId &&
|
|
19
|
+
combination.action === action &&
|
|
20
|
+
combination.resources.some(combinationResource => {
|
|
21
|
+
return resources.some(resource => {
|
|
22
|
+
return (combinationResource.id === resource.id &&
|
|
23
|
+
combinationResource.type === resource.type &&
|
|
24
|
+
JSON.stringify(combinationResource.wrapperData) === JSON.stringify(resource.wrapperData));
|
|
25
|
+
});
|
|
26
|
+
}));
|
|
27
|
+
});
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
const getTestAuthorizationMiddleware = (action, resourceGetter, contextGetter) => {
|
|
32
|
+
return async function authorizationMiddleware$1(request, response, next) {
|
|
33
|
+
contextGetter ||= authorizationMiddleware.defaultContextGetter;
|
|
34
|
+
const { userId, accountId } = contextGetter(request);
|
|
35
|
+
const resources = resourceGetter(request);
|
|
36
|
+
const { isAuthorized } = isActionAuthorized(accountId, userId, resources, action);
|
|
37
|
+
authorizationInternalService.AuthorizationInternalService.markAuthorized(request);
|
|
38
|
+
if (!isAuthorized) {
|
|
39
|
+
response.status(403).json({ message: 'Access denied' });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
next();
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.addTestPermittedAction = addTestPermittedAction;
|
|
47
|
+
exports.clearTestPermittedActions = clearTestPermittedActions;
|
|
48
|
+
exports.getTestAuthorizationMiddleware = getTestAuthorizationMiddleware;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
exports.ResourceAttributeOperationEnum = void 0;
|
|
4
|
+
(function (ResourceAttributeOperationEnum) {
|
|
5
|
+
ResourceAttributeOperationEnum["UPSERT"] = "upsert";
|
|
6
|
+
ResourceAttributeOperationEnum["DELETE"] = "delete";
|
|
7
|
+
})(exports.ResourceAttributeOperationEnum || (exports.ResourceAttributeOperationEnum = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { 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 interface Context {
|
|
9
|
+
accountId: number;
|
|
10
|
+
userId: number;
|
|
11
|
+
}
|
|
12
|
+
export interface AuthorizationObject {
|
|
13
|
+
resource_id?: Resource['id'];
|
|
14
|
+
resource_type: Resource['type'];
|
|
15
|
+
wrapper_data?: Resource['wrapperData'];
|
|
16
|
+
action: Action;
|
|
17
|
+
}
|
|
18
|
+
export interface AuthorizationParams {
|
|
19
|
+
authorizationObjects: AuthorizationObject[];
|
|
20
|
+
}
|
|
21
|
+
type BasicObject = {
|
|
22
|
+
[key: string]: string;
|
|
23
|
+
};
|
|
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 type ResourceGetter = (request: BaseRequest) => Resource[];
|
|
31
|
+
export type ContextGetter = (request: BaseRequest) => Context;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
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 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
3
|
exports.PermitTechnicalReason = void 0;
|
|
4
|
-
var PermitTechnicalReason;
|
|
5
4
|
(function (PermitTechnicalReason) {
|
|
6
5
|
PermitTechnicalReason[PermitTechnicalReason["NO_REASON"] = 0] = "NO_REASON";
|
|
7
6
|
PermitTechnicalReason[PermitTechnicalReason["NOT_ELIGIBLE"] = 1] = "NOT_ELIGIBLE";
|
|
8
7
|
PermitTechnicalReason[PermitTechnicalReason["BY_ROLE_IN_SCOPE"] = 2] = "BY_ROLE_IN_SCOPE";
|
|
9
|
-
})(PermitTechnicalReason || (exports.PermitTechnicalReason =
|
|
10
|
-
//# sourceMappingURL=scoped-actions-contracts.js.map
|
|
8
|
+
})(exports.PermitTechnicalReason || (exports.PermitTechnicalReason = {}));
|
package/package.json
CHANGED
|
@@ -1,60 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondaydotcomorg/monday-authorization",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.12",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
"transform": {
|
|
13
|
-
"^.+\\.(ts|js|html)$": "ts-jest"
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/esm/index.mjs",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
14
12
|
},
|
|
15
|
-
"
|
|
16
|
-
"ts",
|
|
17
|
-
"js",
|
|
18
|
-
"html"
|
|
19
|
-
],
|
|
20
|
-
"coverageReporters": [
|
|
21
|
-
"html"
|
|
22
|
-
]
|
|
13
|
+
"./package.json": "./package.json"
|
|
23
14
|
},
|
|
24
15
|
"scripts": {
|
|
25
|
-
"test": "
|
|
26
|
-
"
|
|
16
|
+
"test": "trident-library test",
|
|
17
|
+
"lint": "trident-library lint",
|
|
18
|
+
"build": "trident-library build",
|
|
19
|
+
"watch": "trident-library build -w"
|
|
27
20
|
},
|
|
28
21
|
"dependencies": {
|
|
29
22
|
"@mondaydotcomorg/monday-fetch": "^0.0.7",
|
|
30
23
|
"@mondaydotcomorg/monday-jwt": "^3.0.14",
|
|
31
24
|
"@mondaydotcomorg/monday-logger": "^4.0.11",
|
|
32
25
|
"@mondaydotcomorg/monday-sns": "^1.0.6",
|
|
33
|
-
"@mondaydotcomorg/trident-backend-api": "^0.
|
|
34
|
-
"@types/lodash": "^4.17.10",
|
|
26
|
+
"@mondaydotcomorg/trident-backend-api": "^0.24.3",
|
|
35
27
|
"lodash": "^4.17.21",
|
|
36
28
|
"node-fetch": "^2.6.7",
|
|
37
29
|
"on-headers": "^1.0.2",
|
|
38
30
|
"ts-node": "^10.0.0"
|
|
39
31
|
},
|
|
40
32
|
"devDependencies": {
|
|
33
|
+
"@mondaydotcomorg/trident-library": "^0.6.53",
|
|
41
34
|
"@types/express": "^4.17.20",
|
|
42
|
-
"@types/
|
|
43
|
-
"@types/mocha": "^8.2.2",
|
|
35
|
+
"@types/lodash": "^4.17.10",
|
|
44
36
|
"@types/on-headers": "^1.0.0",
|
|
45
37
|
"@types/supertest": "^2.0.11",
|
|
46
38
|
"express": "^4.17.1",
|
|
47
39
|
"ioredis": "^5.2.4",
|
|
48
40
|
"ioredis-mock": "^8.2.2",
|
|
49
|
-
"jest": "^27.5.1",
|
|
50
|
-
"mocha": "^9.0.1",
|
|
51
41
|
"supertest": "^6.1.3",
|
|
52
|
-
"
|
|
53
|
-
"tsconfig-paths": "^3.9.0",
|
|
54
|
-
"typescript": "^5.1.6"
|
|
42
|
+
"typescript": "^5.2.2"
|
|
55
43
|
},
|
|
56
44
|
"files": [
|
|
57
45
|
"dist/"
|
|
58
46
|
],
|
|
59
|
-
"
|
|
47
|
+
"eslintConfig": {
|
|
48
|
+
"extends": "@mondaydotcomorg/trident-library",
|
|
49
|
+
"root": true
|
|
50
|
+
},
|
|
51
|
+
"trident": {
|
|
52
|
+
"build": {
|
|
53
|
+
"esmMjsRename": true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"gitHead": "6f9d0cc11ed13226cff1358f3782e314bb7d1248"
|
|
60
57
|
}
|
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 +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,IAAI,CAAC;QACH,MAAM,cAAc,GAAG,yBAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAE9C,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,oBAAoB,CAAC;QAC9B,CAAC;QAED,MAAM,EAAE,mBAAmB,EAAE,GAAG,cAAc,CAAC;QAC/C,IAAI,kCAAkC,GAAG,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;QAEpG,IAAI,CAAC,kCAAkC,EAAE,CAAC;YACxC,OAAO,oBAAoB,CAAC;QAC9B,CAAC;QAED,MAAM,mBAAmB,GAAG,MAAM,CAAC,WAAW,CAAC,kCAAkC,CAAC,CAAC;QAEnF,MAAM,yBAAyB,GAAG,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,UAAU,GAAG;YACpD,yBAAyB,CAAC,GAAG,GAAG,GAAG,sBAAsB,EAAE,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;QAC1F,CAAC,CAAC,CAAC;QAEH,OAAO,yBAAyB,CAAC;IACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC3B,uCAAM,CAAC,IAAI,CACT,EAAE,GAAG,EAAE,uBAAuB,EAAE,KAAK,EAAE,EACvC,mJAAmJ,CACpJ,CAAC;YACF,qBAAqB,GAAG,IAAI,CAAC;QAC/B,CAAC;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,GAAW;IACjC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IACpG,OAAO,MAAM,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"}
|