@mondaydotcomorg/monday-authorization 3.2.3-feature-bashanye-navigate-can-action-in-scope-to-graph-af77c6b → 3.2.4
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/dist/attributions-service.d.ts +3 -2
- package/dist/attributions-service.d.ts.map +1 -1
- package/dist/attributions-service.js +1 -0
- package/dist/authorization-service.d.ts +0 -8
- package/dist/authorization-service.d.ts.map +1 -1
- package/dist/authorization-service.js +20 -114
- package/dist/esm/attributions-service.d.ts +3 -2
- package/dist/esm/attributions-service.d.ts.map +1 -1
- package/dist/esm/attributions-service.mjs +1 -0
- package/dist/esm/authorization-service.d.ts +0 -8
- package/dist/esm/authorization-service.d.ts.map +1 -1
- package/dist/esm/authorization-service.mjs +20 -114
- package/package.json +5 -3
- package/src/attributions-service.ts +93 -0
- package/src/authorization-attributes-service.ts +234 -0
- package/src/authorization-internal-service.ts +129 -0
- package/src/authorization-middleware.ts +51 -0
- package/src/authorization-service.ts +365 -0
- package/src/constants/sns.ts +5 -0
- package/src/constants.ts +22 -0
- package/src/index.ts +46 -0
- package/src/prometheus-service.ts +48 -0
- package/src/roles-service.ts +125 -0
- package/src/testKit/index.ts +66 -0
- package/src/types/authorization-attributes-contracts.ts +33 -0
- package/src/types/express.ts +8 -0
- package/src/types/general.ts +32 -0
- package/src/types/roles.ts +42 -0
- package/src/types/scoped-actions-contracts.ts +48 -0
- package/CHANGELOG.md +0 -46
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Resource } from './general';
|
|
2
|
+
|
|
3
|
+
export interface ResourceAttributeAssignment {
|
|
4
|
+
resourceType: Resource['type'];
|
|
5
|
+
resourceId: Resource['id'];
|
|
6
|
+
key: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ResourceAttributeResponse {
|
|
11
|
+
attributes: ResourceAttributeAssignment[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ResourceAttributeDelete {
|
|
15
|
+
resourceType: Resource['type'];
|
|
16
|
+
resourceId: Resource['id'];
|
|
17
|
+
key: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export enum ResourceAttributeOperationEnum {
|
|
21
|
+
UPSERT = 'upsert',
|
|
22
|
+
DELETE = 'delete',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface UpsertResourceAttributeOperation extends ResourceAttributeAssignment {
|
|
26
|
+
operationType: ResourceAttributeOperationEnum.UPSERT;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface DeleteResourceAttributeOperation extends ResourceAttributeDelete {
|
|
30
|
+
operationType: ResourceAttributeOperationEnum.DELETE;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type ResourceAttributesOperation = UpsertResourceAttributeOperation | DeleteResourceAttributeOperation;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace, @typescript-eslint/no-unused-vars
|
|
2
|
+
declare namespace Express {
|
|
3
|
+
export interface Request {
|
|
4
|
+
payload: { accountId: number; userId: number };
|
|
5
|
+
authorizationCheckPerformed: boolean;
|
|
6
|
+
authorizationSkipPerformed: boolean;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Request, Response } from 'express';
|
|
2
|
+
|
|
3
|
+
export interface Resource {
|
|
4
|
+
id?: number;
|
|
5
|
+
type: string;
|
|
6
|
+
wrapperData?: object;
|
|
7
|
+
}
|
|
8
|
+
export type Action = string;
|
|
9
|
+
export interface Context {
|
|
10
|
+
accountId: number;
|
|
11
|
+
userId: number;
|
|
12
|
+
}
|
|
13
|
+
export interface AuthorizationObject {
|
|
14
|
+
resource_id?: Resource['id'];
|
|
15
|
+
resource_type: Resource['type'];
|
|
16
|
+
wrapper_data?: Resource['wrapperData'];
|
|
17
|
+
action: Action;
|
|
18
|
+
}
|
|
19
|
+
export interface AuthorizationParams {
|
|
20
|
+
authorizationObjects: AuthorizationObject[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type BasicObject = { [key: string]: unknown };
|
|
24
|
+
|
|
25
|
+
export type BaseParameters = BasicObject;
|
|
26
|
+
export type BaseResponseBody = BasicObject;
|
|
27
|
+
export type BaseBodyParameters = BasicObject;
|
|
28
|
+
export type BaseQueryParameters = BasicObject;
|
|
29
|
+
export type BaseRequest = Request<BaseParameters, BaseResponseBody, BaseBodyParameters, BaseQueryParameters>;
|
|
30
|
+
export type BaseResponse = Response<BaseResponseBody>;
|
|
31
|
+
export type ResourceGetter = (request: BaseRequest) => Resource[];
|
|
32
|
+
export type ContextGetter = (request: BaseRequest) => Context;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export enum RoleType {
|
|
2
|
+
CUSTOM = 'custom_role',
|
|
3
|
+
BASIC = 'basic_role',
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface CustomRole {
|
|
7
|
+
id?: number;
|
|
8
|
+
name: string;
|
|
9
|
+
resourceType: string;
|
|
10
|
+
resourceId: number;
|
|
11
|
+
basicRoleId: number;
|
|
12
|
+
basicRoleType: RoleType;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface BasicRole {
|
|
16
|
+
id: number;
|
|
17
|
+
resourceType: string;
|
|
18
|
+
roleType: string;
|
|
19
|
+
name: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface RolesResponse {
|
|
23
|
+
customRoles: CustomRole[];
|
|
24
|
+
basicRoles?: BasicRole[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface RoleCreateRequest {
|
|
28
|
+
name: string;
|
|
29
|
+
resourceType: string;
|
|
30
|
+
resourceId: number;
|
|
31
|
+
sourceRole: {
|
|
32
|
+
id: number;
|
|
33
|
+
type: RoleType;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface RoleUpdateRequest {
|
|
38
|
+
id: number;
|
|
39
|
+
updateAttributes: {
|
|
40
|
+
name: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface WorkspaceScope {
|
|
2
|
+
workspaceId: number;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface BoardScope {
|
|
6
|
+
boardId: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface PulseScope {
|
|
10
|
+
pulseId: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface AccountProductScope {
|
|
14
|
+
accountProductId: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AccountScope {
|
|
18
|
+
accountId: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope;
|
|
22
|
+
|
|
23
|
+
export interface Translation {
|
|
24
|
+
key: string;
|
|
25
|
+
[option: string]: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export enum PermitTechnicalReason {
|
|
29
|
+
NO_REASON = 0,
|
|
30
|
+
NOT_ELIGIBLE = 1,
|
|
31
|
+
BY_ROLE_IN_SCOPE = 2,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ScopedActionPermit {
|
|
35
|
+
can: boolean;
|
|
36
|
+
reason: Translation;
|
|
37
|
+
technicalReason: PermitTechnicalReason;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ScopedAction {
|
|
41
|
+
action: string;
|
|
42
|
+
scope: ScopeOptions;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ScopedActionResponseObject {
|
|
46
|
+
scopedAction: ScopedAction;
|
|
47
|
+
permit: ScopedActionPermit;
|
|
48
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
6
|
-
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
7
|
-
|
|
8
|
-
## [2.0.0] - 2025-04-07
|
|
9
|
-
|
|
10
|
-
### ⚠ MAJOR CHANGE - PLEASE READ
|
|
11
|
-
|
|
12
|
-
### Fixed
|
|
13
|
-
|
|
14
|
-
- Calls to the monolith will be spread across the different profiles - `api-internal`, `slow` and `internal` (originally, all the calls to the platform went directly to `monday-app`)
|
|
15
|
-
|
|
16
|
-
## [1.2.9] - 2024-10-06
|
|
17
|
-
|
|
18
|
-
### Added
|
|
19
|
-
|
|
20
|
-
- [`authz/bashanye/add-async-resource-attributes-support`](https://github.com/DaPulse/monday-npm-packages/pull/6859)
|
|
21
|
-
- `AuthorizationAttributesService` - now supports async upsert and delete - requests sent through SNS-SQS).
|
|
22
|
-
|
|
23
|
-
## [1.2.3] - 2024-06-10
|
|
24
|
-
|
|
25
|
-
### Added
|
|
26
|
-
|
|
27
|
-
- [`feature/yarden/resource-attributes-api-support-authz-sdk (#5826)`](https://github.com/DaPulse/monday-npm-packages/pull/5826)
|
|
28
|
-
- `AuthorizationAttributesService` - now supports upsert (`upsertResourceAttributesSync`) and delete (`deleteResourceAttributesSync`) resource attributes in the authorization MS
|
|
29
|
-
|
|
30
|
-
## [1.2.0] - 2024-01-05
|
|
31
|
-
|
|
32
|
-
### Added
|
|
33
|
-
|
|
34
|
-
- `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.)
|
|
35
|
-
|
|
36
|
-
## [1.1.0] - 2023-08-09
|
|
37
|
-
|
|
38
|
-
### ⚠ BREAKING CHANGES
|
|
39
|
-
|
|
40
|
-
- `canActionInScope` now returns an object of type `{ can: boolean; reason: string; }` instead of `boolean`.
|
|
41
|
-
This version is considered minor because no one uses this function yet.
|
|
42
|
-
|
|
43
|
-
### Changed
|
|
44
|
-
|
|
45
|
-
- [`feature/idan/can-action-in-scope/change-behavior-on-error (#3689)`](https://github.com/DaPulse/monday-npm-packages/pull/3689)
|
|
46
|
-
- `canActionInScope`, `canActionInScopeMultiple` and `isAuthorized` are now throwing an error instead of returning `false` when an error occurs as part of the authorization http request (status code is not 2XX)
|