easywork-common-lib 1.0.1022 → 1.0.1024
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/common/enums/common.enum.d.ts +14 -0
- package/dist/common/enums/common.enum.js +17 -1
- package/dist/common/enums/common.enum.js.map +1 -1
- package/dist/entities/all-activities.entity.d.ts +38 -0
- package/dist/entities/all-activities.entity.js +261 -0
- package/dist/entities/all-activities.entity.js.map +1 -0
- package/dist/entities/index.d.ts +1 -0
- package/dist/entities/index.js +1 -0
- package/dist/entities/index.js.map +1 -1
- package/dist/modules/authorization/authorization.module.d.ts +26 -0
- package/dist/modules/authorization/authorization.module.js +105 -0
- package/dist/modules/authorization/authorization.module.js.map +1 -0
- package/dist/modules/authorization/config/resource-configurations.d.ts +12 -0
- package/dist/modules/authorization/config/resource-configurations.js +124 -0
- package/dist/modules/authorization/config/resource-configurations.js.map +1 -0
- package/dist/modules/authorization/decorators/contact-permissions.decorator.d.ts +13 -0
- package/dist/modules/authorization/decorators/contact-permissions.decorator.js +101 -0
- package/dist/modules/authorization/decorators/contact-permissions.decorator.js.map +1 -0
- package/dist/modules/authorization/decorators/permissions.decorator.d.ts +51 -0
- package/dist/modules/authorization/decorators/permissions.decorator.js +144 -0
- package/dist/modules/authorization/decorators/permissions.decorator.js.map +1 -0
- package/dist/modules/authorization/factories/resource-authorization.factory.d.ts +55 -0
- package/dist/modules/authorization/factories/resource-authorization.factory.js +184 -0
- package/dist/modules/authorization/factories/resource-authorization.factory.js.map +1 -0
- package/dist/modules/authorization/index.d.ts +7 -0
- package/dist/modules/authorization/index.js +24 -0
- package/dist/modules/authorization/index.js.map +1 -0
- package/dist/modules/authorization/interfaces/authorization.interface.d.ts +23 -0
- package/dist/modules/authorization/interfaces/authorization.interface.js +3 -0
- package/dist/modules/authorization/interfaces/authorization.interface.js.map +1 -0
- package/dist/modules/authorization/services/authorization.service.d.ts +25 -0
- package/dist/modules/authorization/services/authorization.service.js +139 -0
- package/dist/modules/authorization/services/authorization.service.js.map +1 -0
- package/dist/modules/authorization/services/dynamic-filter.service.d.ts +9 -0
- package/dist/modules/authorization/services/dynamic-filter.service.js +238 -0
- package/dist/modules/authorization/services/dynamic-filter.service.js.map +1 -0
- package/dist/modules/authorization/services/index.d.ts +7 -0
- package/dist/modules/authorization/services/index.js +24 -0
- package/dist/modules/authorization/services/index.js.map +1 -0
- package/dist/modules/authorization/services/modules/contact-authorization.service.d.ts +29 -0
- package/dist/modules/authorization/services/modules/contact-authorization.service.js +105 -0
- package/dist/modules/authorization/services/modules/contact-authorization.service.js.map +1 -0
- package/dist/modules/authorization/services/modules/index.d.ts +4 -0
- package/dist/modules/authorization/services/modules/index.js +21 -0
- package/dist/modules/authorization/services/modules/index.js.map +1 -0
- package/dist/modules/authorization/services/modules/lead-authorization.service.d.ts +27 -0
- package/dist/modules/authorization/services/modules/lead-authorization.service.js +96 -0
- package/dist/modules/authorization/services/modules/lead-authorization.service.js.map +1 -0
- package/dist/modules/authorization/services/modules/policy-authorization.service.d.ts +28 -0
- package/dist/modules/authorization/services/modules/policy-authorization.service.js +100 -0
- package/dist/modules/authorization/services/modules/policy-authorization.service.js.map +1 -0
- package/dist/modules/authorization/services/modules/task-authorization.service.d.ts +28 -0
- package/dist/modules/authorization/services/modules/task-authorization.service.js +100 -0
- package/dist/modules/authorization/services/modules/task-authorization.service.js.map +1 -0
- package/dist/modules/authorization/services/permission-cache.service.d.ts +10 -0
- package/dist/modules/authorization/services/permission-cache.service.js +48 -0
- package/dist/modules/authorization/services/permission-cache.service.js.map +1 -0
- package/dist/modules/authorization/services/permission-evaluator.service.d.ts +26 -0
- package/dist/modules/authorization/services/permission-evaluator.service.js +349 -0
- package/dist/modules/authorization/services/permission-evaluator.service.js.map +1 -0
- package/dist/modules/authorization/services/resource-access-filter.service.d.ts +20 -0
- package/dist/modules/authorization/services/resource-access-filter.service.js +406 -0
- package/dist/modules/authorization/services/resource-access-filter.service.js.map +1 -0
- package/dist/modules/authorization/services/resource-authorization.service.d.ts +47 -0
- package/dist/modules/authorization/services/resource-authorization.service.js +192 -0
- package/dist/modules/authorization/services/resource-authorization.service.js.map +1 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/modules/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-authorization.service.js","sourceRoot":"","sources":["../../../../../src/modules/authorization/services/modules/contact-authorization.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AAIpD,mGAGwD;AAUjD,IAAM,2BAA2B,mCAAjC,MAAM,2BAA2B;IAIT;IAHZ,MAAM,GAAG,IAAI,eAAM,CAAC,6BAA2B,CAAC,IAAI,CAAC,CAAC;IAC/D,WAAW,CAAmC;IAEtD,YAA6B,WAAyC;QAAzC,gBAAW,GAAX,WAAW,CAA8B;IAAG,CAAC;IAKlE,cAAc,CACpB,kBAAyC;QAEzC,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,kBAAkB,EAAE,CAAC;YAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,CACL,IAAI,CAAC,WAAW;YAChB,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,CAChE,CAAC;IACJ,CAAC;IAMD,KAAK,CAAC,6BAA6B,CACjC,YAAqC,EACrC,IAAU,EACV,UAII,EAAE;QAEN,MAAM,EAAE,kBAAkB,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC;QAEvD,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;YAC5D,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAChE,OAAO,MAAM,WA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I,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,IAAS,EACT,kBAAyC;QAEzC,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;QAC5D,OAAO,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,iBAAiB,CACrB,IAAS,EACT,kBAAyC;QAEzC,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;QAC5D,OAAO,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,iBAAiB,CACrB,IAAS,EACT,kBAAyC;QAEzC,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;QAC5D,OAAO,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;CACF,CAAA;AAvLY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,mBAAU,GAAE;qCAK+B,6DAA4B;GAJ3D,2BAA2B,CAuLvC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./contact-authorization.service"), exports);
|
|
18
|
+
__exportStar(require("./lead-authorization.service"), exports);
|
|
19
|
+
__exportStar(require("./policy-authorization.service"), exports);
|
|
20
|
+
__exportStar(require("./task-authorization.service"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/authorization/services/modules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAA+C;AAC/C,+DAA4C;AAC5C,iEAA8C;AAC9C,+DAA4C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Repository, SelectQueryBuilder } from "typeorm";
|
|
2
|
+
import { PermissionAction, PermissionResult } from "../../../../common/";
|
|
3
|
+
import { SubGroup, User } from "../../../../entities";
|
|
4
|
+
import { ResourceAuthorizationFactory } from "../../factories/resource-authorization.factory";
|
|
5
|
+
export declare class LeadAuthorizationService {
|
|
6
|
+
private readonly authFactory;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
private leadAuth?;
|
|
9
|
+
constructor(authFactory: ResourceAuthorizationFactory);
|
|
10
|
+
private getLeadAuth;
|
|
11
|
+
applyLeadPermissionFilters(queryBuilder: SelectQueryBuilder<any>, user: User, options?: {
|
|
12
|
+
getAll?: boolean;
|
|
13
|
+
action?: PermissionAction;
|
|
14
|
+
subGroupRepository?: Repository<SubGroup>;
|
|
15
|
+
}): Promise<SelectQueryBuilder<any>>;
|
|
16
|
+
canPerformLeadAction(user: any, action: PermissionAction, targetLead?: any, subGroupRepository?: Repository<SubGroup>): Promise<PermissionResult>;
|
|
17
|
+
validateLeadAccess(user: any, action: PermissionAction, targetLead: any, subGroupRepository?: Repository<SubGroup>): Promise<void>;
|
|
18
|
+
getAssistantIds(user: User, subGroupRepository: Repository<SubGroup>): Promise<string[]>;
|
|
19
|
+
getUserSubGroupMembers(user: User, subGroupRepository: Repository<SubGroup>): Promise<string[]>;
|
|
20
|
+
canCreateLead(user: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
21
|
+
canReadLead(user: any, lead?: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
22
|
+
canUpdateLead(user: any, lead: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
23
|
+
canDeleteLead(user: any, lead: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
24
|
+
canConvertLead(user: any, lead: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
25
|
+
canExportLeads(user: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
26
|
+
canImportLeads(user: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var LeadAuthorizationService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.LeadAuthorizationService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const resource_authorization_factory_1 = require("../../factories/resource-authorization.factory");
|
|
16
|
+
let LeadAuthorizationService = LeadAuthorizationService_1 = class LeadAuthorizationService {
|
|
17
|
+
authFactory;
|
|
18
|
+
logger = new common_1.Logger(LeadAuthorizationService_1.name);
|
|
19
|
+
leadAuth;
|
|
20
|
+
constructor(authFactory) {
|
|
21
|
+
this.authFactory = authFactory;
|
|
22
|
+
}
|
|
23
|
+
getLeadAuth(subGroupRepository) {
|
|
24
|
+
if (!this.leadAuth && subGroupRepository) {
|
|
25
|
+
this.leadAuth = this.authFactory.forLead(subGroupRepository);
|
|
26
|
+
}
|
|
27
|
+
return (this.leadAuth ||
|
|
28
|
+
this.authFactory.createBuilder().forResource("lead").build());
|
|
29
|
+
}
|
|
30
|
+
async applyLeadPermissionFilters(queryBuilder, user, options = {}) {
|
|
31
|
+
const { subGroupRepository, ...restOptions } = options;
|
|
32
|
+
try {
|
|
33
|
+
const leadAuth = this.getLeadAuth(subGroupRepository);
|
|
34
|
+
const assistantIds = await leadAuth.getSubGroupMembers(user);
|
|
35
|
+
return await leadAuth.applyPermissionFilters(queryBuilder, user, {
|
|
36
|
+
...restOptions,
|
|
37
|
+
assistantIds,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
this.logger.error(`Error applying lead permission filters: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
42
|
+
queryBuilder.where("1 = 0");
|
|
43
|
+
return queryBuilder;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async canPerformLeadAction(user, action, targetLead, subGroupRepository) {
|
|
47
|
+
const leadAuth = this.getLeadAuth(subGroupRepository);
|
|
48
|
+
return leadAuth.canPerformAction(user, action, targetLead);
|
|
49
|
+
}
|
|
50
|
+
async validateLeadAccess(user, action, targetLead, subGroupRepository) {
|
|
51
|
+
const leadAuth = this.getLeadAuth(subGroupRepository);
|
|
52
|
+
return leadAuth.validateAccess(user, action, targetLead);
|
|
53
|
+
}
|
|
54
|
+
async getAssistantIds(user, subGroupRepository) {
|
|
55
|
+
const leadAuth = this.getLeadAuth(subGroupRepository);
|
|
56
|
+
return leadAuth.getAssistantIds(user);
|
|
57
|
+
}
|
|
58
|
+
async getUserSubGroupMembers(user, subGroupRepository) {
|
|
59
|
+
const leadAuth = this.getLeadAuth(subGroupRepository);
|
|
60
|
+
return leadAuth.getSubGroupMembers(user);
|
|
61
|
+
}
|
|
62
|
+
async canCreateLead(user, subGroupRepository) {
|
|
63
|
+
const leadAuth = this.getLeadAuth(subGroupRepository);
|
|
64
|
+
return leadAuth.canCreate(user);
|
|
65
|
+
}
|
|
66
|
+
async canReadLead(user, lead, subGroupRepository) {
|
|
67
|
+
const leadAuth = this.getLeadAuth(subGroupRepository);
|
|
68
|
+
return leadAuth.canRead(user, lead);
|
|
69
|
+
}
|
|
70
|
+
async canUpdateLead(user, lead, subGroupRepository) {
|
|
71
|
+
const leadAuth = this.getLeadAuth(subGroupRepository);
|
|
72
|
+
return leadAuth.canUpdate(user, lead);
|
|
73
|
+
}
|
|
74
|
+
async canDeleteLead(user, lead, subGroupRepository) {
|
|
75
|
+
const leadAuth = this.getLeadAuth(subGroupRepository);
|
|
76
|
+
return leadAuth.canDelete(user, lead);
|
|
77
|
+
}
|
|
78
|
+
async canConvertLead(user, lead, subGroupRepository) {
|
|
79
|
+
const leadAuth = this.getLeadAuth(subGroupRepository);
|
|
80
|
+
return leadAuth.canUpdate(user, lead);
|
|
81
|
+
}
|
|
82
|
+
async canExportLeads(user, subGroupRepository) {
|
|
83
|
+
const leadAuth = this.getLeadAuth(subGroupRepository);
|
|
84
|
+
return leadAuth.canExport(user);
|
|
85
|
+
}
|
|
86
|
+
async canImportLeads(user, subGroupRepository) {
|
|
87
|
+
const leadAuth = this.getLeadAuth(subGroupRepository);
|
|
88
|
+
return leadAuth.canImport(user);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
exports.LeadAuthorizationService = LeadAuthorizationService;
|
|
92
|
+
exports.LeadAuthorizationService = LeadAuthorizationService = LeadAuthorizationService_1 = __decorate([
|
|
93
|
+
(0, common_1.Injectable)(),
|
|
94
|
+
__metadata("design:paramtypes", [resource_authorization_factory_1.ResourceAuthorizationFactory])
|
|
95
|
+
], LeadAuthorizationService);
|
|
96
|
+
//# sourceMappingURL=lead-authorization.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lead-authorization.service.js","sourceRoot":"","sources":["../../../../../src/modules/authorization/services/modules/lead-authorization.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AAIpD,mGAGwD;AAOjD,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAIN;IAHZ,MAAM,GAAG,IAAI,eAAM,CAAC,0BAAwB,CAAC,IAAI,CAAC,CAAC;IAC5D,QAAQ,CAAmC;IAEnD,YAA6B,WAAyC;QAAzC,gBAAW,GAAX,WAAW,CAA8B;IAAG,CAAC;IAKlE,WAAW,CACjB,kBAAyC;QAEzC,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,kBAAkB,EAAE,CAAC;YACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,CACL,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAC7D,CAAC;IACJ,CAAC;IAKD,KAAK,CAAC,0BAA0B,CAC9B,YAAqC,EACrC,IAAU,EACV,UAII,EAAE;QAEN,MAAM,EAAE,kBAAkB,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC;QAEvD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;YACtD,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,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AAS,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,IAAS,EACT,kBAAyC;QAEzC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;QACtD,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF,CAAA;AApKY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;qCAK+B,6DAA4B;GAJ3D,wBAAwB,CAoKpC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Repository, SelectQueryBuilder } from "typeorm";
|
|
2
|
+
import { PermissionAction, PermissionResult } from "../../../../common/";
|
|
3
|
+
import { Policy, SubGroup, User } from "../../../../entities";
|
|
4
|
+
import { ResourceAuthorizationFactory } from "../../factories/resource-authorization.factory";
|
|
5
|
+
export declare class PolicyAuthorizationService {
|
|
6
|
+
private readonly authFactory;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
private policyAuth?;
|
|
9
|
+
constructor(authFactory: ResourceAuthorizationFactory);
|
|
10
|
+
private getPolicyAuth;
|
|
11
|
+
applyPolicyPermissionFilters(queryBuilder: SelectQueryBuilder<any>, user: User, options?: {
|
|
12
|
+
getAll?: boolean;
|
|
13
|
+
action?: PermissionAction;
|
|
14
|
+
subGroupRepository?: Repository<SubGroup>;
|
|
15
|
+
}): Promise<SelectQueryBuilder<any>>;
|
|
16
|
+
canPerformPolicyAction(user: any, action: PermissionAction, targetPolicy?: any, subGroupRepository?: Repository<SubGroup>): Promise<PermissionResult>;
|
|
17
|
+
validatePolicyAccess(user: any, action: PermissionAction, targetPolicy: any, subGroupRepository?: Repository<SubGroup>): Promise<void>;
|
|
18
|
+
getAssistantIds(user: User, subGroupRepository: Repository<SubGroup>): Promise<string[]>;
|
|
19
|
+
getUserSubGroupMembers(user: User, subGroupRepository: Repository<SubGroup>): Promise<string[]>;
|
|
20
|
+
canCreatePolicy(user: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
21
|
+
canReadPolicy(user: any, policy?: Policy, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
22
|
+
canUpdatePolicy(user: any, policy: Policy, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
23
|
+
canDeletePolicy(user: any, policy: Policy, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
24
|
+
canCancelPolicy(user: any, policy: Policy, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
25
|
+
canApprovePolicy(user: any, _policy: Policy, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
26
|
+
canExportPolicies(user: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
27
|
+
canImportPolicies(user: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var PolicyAuthorizationService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.PolicyAuthorizationService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const resource_authorization_factory_1 = require("../../factories/resource-authorization.factory");
|
|
16
|
+
let PolicyAuthorizationService = PolicyAuthorizationService_1 = class PolicyAuthorizationService {
|
|
17
|
+
authFactory;
|
|
18
|
+
logger = new common_1.Logger(PolicyAuthorizationService_1.name);
|
|
19
|
+
policyAuth;
|
|
20
|
+
constructor(authFactory) {
|
|
21
|
+
this.authFactory = authFactory;
|
|
22
|
+
}
|
|
23
|
+
getPolicyAuth(subGroupRepository) {
|
|
24
|
+
if (!this.policyAuth && subGroupRepository) {
|
|
25
|
+
this.policyAuth = this.authFactory.forPolicy(subGroupRepository);
|
|
26
|
+
}
|
|
27
|
+
return (this.policyAuth ||
|
|
28
|
+
this.authFactory.createBuilder().forResource("policy").build());
|
|
29
|
+
}
|
|
30
|
+
async applyPolicyPermissionFilters(queryBuilder, user, options = {}) {
|
|
31
|
+
const { subGroupRepository, ...restOptions } = options;
|
|
32
|
+
try {
|
|
33
|
+
const policyAuth = this.getPolicyAuth(subGroupRepository);
|
|
34
|
+
const assistantIds = await policyAuth.getSubGroupMembers(user);
|
|
35
|
+
return await policyAuth.applyPermissionFilters(queryBuilder, user, {
|
|
36
|
+
...restOptions,
|
|
37
|
+
assistantIds,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
this.logger.error(`Error applying policy permission filters: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
42
|
+
queryBuilder.where("1 = 0");
|
|
43
|
+
return queryBuilder;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async canPerformPolicyAction(user, action, targetPolicy, subGroupRepository) {
|
|
47
|
+
const policyAuth = this.getPolicyAuth(subGroupRepository);
|
|
48
|
+
return policyAuth.canPerformAction(user, action, targetPolicy);
|
|
49
|
+
}
|
|
50
|
+
async validatePolicyAccess(user, action, targetPolicy, subGroupRepository) {
|
|
51
|
+
const policyAuth = this.getPolicyAuth(subGroupRepository);
|
|
52
|
+
return policyAuth.validateAccess(user, action, targetPolicy);
|
|
53
|
+
}
|
|
54
|
+
async getAssistantIds(user, subGroupRepository) {
|
|
55
|
+
const policyAuth = this.getPolicyAuth(subGroupRepository);
|
|
56
|
+
return policyAuth.getAssistantIds(user);
|
|
57
|
+
}
|
|
58
|
+
async getUserSubGroupMembers(user, subGroupRepository) {
|
|
59
|
+
const policyAuth = this.getPolicyAuth(subGroupRepository);
|
|
60
|
+
return policyAuth.getSubGroupMembers(user);
|
|
61
|
+
}
|
|
62
|
+
async canCreatePolicy(user, subGroupRepository) {
|
|
63
|
+
const policyAuth = this.getPolicyAuth(subGroupRepository);
|
|
64
|
+
return policyAuth.canCreate(user);
|
|
65
|
+
}
|
|
66
|
+
async canReadPolicy(user, policy, subGroupRepository) {
|
|
67
|
+
const policyAuth = this.getPolicyAuth(subGroupRepository);
|
|
68
|
+
return policyAuth.canRead(user, policy);
|
|
69
|
+
}
|
|
70
|
+
async canUpdatePolicy(user, policy, subGroupRepository) {
|
|
71
|
+
const policyAuth = this.getPolicyAuth(subGroupRepository);
|
|
72
|
+
return policyAuth.canUpdate(user, policy);
|
|
73
|
+
}
|
|
74
|
+
async canDeletePolicy(user, policy, subGroupRepository) {
|
|
75
|
+
const policyAuth = this.getPolicyAuth(subGroupRepository);
|
|
76
|
+
return policyAuth.canDelete(user, policy);
|
|
77
|
+
}
|
|
78
|
+
async canCancelPolicy(user, policy, subGroupRepository) {
|
|
79
|
+
const policyAuth = this.getPolicyAuth(subGroupRepository);
|
|
80
|
+
return policyAuth.canUpdate(user, policy);
|
|
81
|
+
}
|
|
82
|
+
async canApprovePolicy(user, _policy, subGroupRepository) {
|
|
83
|
+
const policyAuth = this.getPolicyAuth(subGroupRepository);
|
|
84
|
+
return policyAuth.canManage(user);
|
|
85
|
+
}
|
|
86
|
+
async canExportPolicies(user, subGroupRepository) {
|
|
87
|
+
const policyAuth = this.getPolicyAuth(subGroupRepository);
|
|
88
|
+
return policyAuth.canExport(user);
|
|
89
|
+
}
|
|
90
|
+
async canImportPolicies(user, subGroupRepository) {
|
|
91
|
+
const policyAuth = this.getPolicyAuth(subGroupRepository);
|
|
92
|
+
return policyAuth.canImport(user);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
exports.PolicyAuthorizationService = PolicyAuthorizationService;
|
|
96
|
+
exports.PolicyAuthorizationService = PolicyAuthorizationService = PolicyAuthorizationService_1 = __decorate([
|
|
97
|
+
(0, common_1.Injectable)(),
|
|
98
|
+
__metadata("design:paramtypes", [resource_authorization_factory_1.ResourceAuthorizationFactory])
|
|
99
|
+
], PolicyAuthorizationService);
|
|
100
|
+
//# sourceMappingURL=policy-authorization.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-authorization.service.js","sourceRoot":"","sources":["../../../../../src/modules/authorization/services/modules/policy-authorization.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AAIpD,mGAGwD;AAOjD,IAAM,0BAA0B,kCAAhC,MAAM,0BAA0B;IAIR;IAHZ,MAAM,GAAG,IAAI,eAAM,CAAC,4BAA0B,CAAC,IAAI,CAAC,CAAC;IAC9D,UAAU,CAAmC;IAErD,YAA6B,WAAyC;QAAzC,gBAAW,GAAX,WAAW,CAA8B;IAAG,CAAC;IAKlE,aAAa,CACnB,kBAAyC;QAEzC,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,kBAAkB,EAAE,CAAC;YAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,CACL,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,CAC/D,CAAC;IACJ,CAAC;IAKD,KAAK,CAAC,4BAA4B,CAChC,YAAqC,EACrC,IAAU,EACV,UAII,EAAE;QAEN,MAAM,EAAE,kBAAkB,EAAE,GAAG,WAAW,EAA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;IAED,KAAK,CAAC,gBAAgB,CACpB,IAAS,EACT,OAAe,EACf,kBAAyC;QAGzC,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;QAC1D,OAAO,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,iBAAiB,CACrB,IAAS,EACT,kBAAyC;QAEzC,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;QAC1D,OAAO,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,iBAAiB,CACrB,IAAS,EACT,kBAAyC;QAEzC,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;QAC1D,OAAO,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AA9KY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;qCAK+B,6DAA4B;GAJ3D,0BAA0B,CA8KtC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Repository, SelectQueryBuilder } from "typeorm";
|
|
2
|
+
import { PermissionAction, PermissionResult } from "../../../../common/";
|
|
3
|
+
import { SubGroup, User } from "../../../../entities";
|
|
4
|
+
import { ResourceAuthorizationFactory } from "../../factories/resource-authorization.factory";
|
|
5
|
+
export declare class TaskAuthorizationService {
|
|
6
|
+
private readonly authFactory;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
private taskAuth?;
|
|
9
|
+
constructor(authFactory: ResourceAuthorizationFactory);
|
|
10
|
+
private getTaskAuth;
|
|
11
|
+
applyTaskPermissionFilters(queryBuilder: SelectQueryBuilder<any>, user: User, options?: {
|
|
12
|
+
getAll?: boolean;
|
|
13
|
+
action?: PermissionAction;
|
|
14
|
+
subGroupRepository?: Repository<SubGroup>;
|
|
15
|
+
}): Promise<SelectQueryBuilder<any>>;
|
|
16
|
+
canPerformTaskAction(user: any, action: PermissionAction, targetTask?: any, subGroupRepository?: Repository<SubGroup>): Promise<PermissionResult>;
|
|
17
|
+
validateTaskAccess(user: any, action: PermissionAction, targetTask: any, subGroupRepository?: Repository<SubGroup>): Promise<void>;
|
|
18
|
+
getAssistantIds(user: User, subGroupRepository: Repository<SubGroup>): Promise<string[]>;
|
|
19
|
+
getUserSubGroupMembers(user: User, subGroupRepository: Repository<SubGroup>): Promise<string[]>;
|
|
20
|
+
canCreateTask(user: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
21
|
+
canReadTask(user: any, task?: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
22
|
+
canUpdateTask(user: any, task: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
23
|
+
canDeleteTask(user: any, task: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
24
|
+
canCompleteTask(user: any, task: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
25
|
+
canAssignTask(user: any, _task: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
26
|
+
canExportTasks(user: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
27
|
+
canImportTasks(user: any, subGroupRepository?: Repository<SubGroup>): Promise<boolean>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var TaskAuthorizationService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.TaskAuthorizationService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const resource_authorization_factory_1 = require("../../factories/resource-authorization.factory");
|
|
16
|
+
let TaskAuthorizationService = TaskAuthorizationService_1 = class TaskAuthorizationService {
|
|
17
|
+
authFactory;
|
|
18
|
+
logger = new common_1.Logger(TaskAuthorizationService_1.name);
|
|
19
|
+
taskAuth;
|
|
20
|
+
constructor(authFactory) {
|
|
21
|
+
this.authFactory = authFactory;
|
|
22
|
+
}
|
|
23
|
+
getTaskAuth(subGroupRepository) {
|
|
24
|
+
if (!this.taskAuth && subGroupRepository) {
|
|
25
|
+
this.taskAuth = this.authFactory.forTask(subGroupRepository);
|
|
26
|
+
}
|
|
27
|
+
return (this.taskAuth ||
|
|
28
|
+
this.authFactory.createBuilder().forResource("task").build());
|
|
29
|
+
}
|
|
30
|
+
async applyTaskPermissionFilters(queryBuilder, user, options = {}) {
|
|
31
|
+
const { subGroupRepository, ...restOptions } = options;
|
|
32
|
+
try {
|
|
33
|
+
const taskAuth = this.getTaskAuth(subGroupRepository);
|
|
34
|
+
const assistantIds = await taskAuth.getSubGroupMembers(user);
|
|
35
|
+
return await taskAuth.applyPermissionFilters(queryBuilder, user, {
|
|
36
|
+
...restOptions,
|
|
37
|
+
assistantIds,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
this.logger.error(`Error applying task permission filters: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
42
|
+
queryBuilder.where("1 = 0");
|
|
43
|
+
return queryBuilder;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async canPerformTaskAction(user, action, targetTask, subGroupRepository) {
|
|
47
|
+
const taskAuth = this.getTaskAuth(subGroupRepository);
|
|
48
|
+
return taskAuth.canPerformAction(user, action, targetTask);
|
|
49
|
+
}
|
|
50
|
+
async validateTaskAccess(user, action, targetTask, subGroupRepository) {
|
|
51
|
+
const taskAuth = this.getTaskAuth(subGroupRepository);
|
|
52
|
+
return taskAuth.validateAccess(user, action, targetTask);
|
|
53
|
+
}
|
|
54
|
+
async getAssistantIds(user, subGroupRepository) {
|
|
55
|
+
const taskAuth = this.getTaskAuth(subGroupRepository);
|
|
56
|
+
return taskAuth.getAssistantIds(user);
|
|
57
|
+
}
|
|
58
|
+
async getUserSubGroupMembers(user, subGroupRepository) {
|
|
59
|
+
const taskAuth = this.getTaskAuth(subGroupRepository);
|
|
60
|
+
return taskAuth.getSubGroupMembers(user);
|
|
61
|
+
}
|
|
62
|
+
async canCreateTask(user, subGroupRepository) {
|
|
63
|
+
const taskAuth = this.getTaskAuth(subGroupRepository);
|
|
64
|
+
return taskAuth.canCreate(user);
|
|
65
|
+
}
|
|
66
|
+
async canReadTask(user, task, subGroupRepository) {
|
|
67
|
+
const taskAuth = this.getTaskAuth(subGroupRepository);
|
|
68
|
+
return taskAuth.canRead(user, task);
|
|
69
|
+
}
|
|
70
|
+
async canUpdateTask(user, task, subGroupRepository) {
|
|
71
|
+
const taskAuth = this.getTaskAuth(subGroupRepository);
|
|
72
|
+
return taskAuth.canUpdate(user, task);
|
|
73
|
+
}
|
|
74
|
+
async canDeleteTask(user, task, subGroupRepository) {
|
|
75
|
+
const taskAuth = this.getTaskAuth(subGroupRepository);
|
|
76
|
+
return taskAuth.canDelete(user, task);
|
|
77
|
+
}
|
|
78
|
+
async canCompleteTask(user, task, subGroupRepository) {
|
|
79
|
+
const taskAuth = this.getTaskAuth(subGroupRepository);
|
|
80
|
+
return taskAuth.canUpdate(user, task);
|
|
81
|
+
}
|
|
82
|
+
async canAssignTask(user, _task, subGroupRepository) {
|
|
83
|
+
const taskAuth = this.getTaskAuth(subGroupRepository);
|
|
84
|
+
return taskAuth.canManage(user);
|
|
85
|
+
}
|
|
86
|
+
async canExportTasks(user, subGroupRepository) {
|
|
87
|
+
const taskAuth = this.getTaskAuth(subGroupRepository);
|
|
88
|
+
return taskAuth.canExport(user);
|
|
89
|
+
}
|
|
90
|
+
async canImportTasks(user, subGroupRepository) {
|
|
91
|
+
const taskAuth = this.getTaskAuth(subGroupRepository);
|
|
92
|
+
return taskAuth.canImport(user);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
exports.TaskAuthorizationService = TaskAuthorizationService;
|
|
96
|
+
exports.TaskAuthorizationService = TaskAuthorizationService = TaskAuthorizationService_1 = __decorate([
|
|
97
|
+
(0, common_1.Injectable)(),
|
|
98
|
+
__metadata("design:paramtypes", [resource_authorization_factory_1.ResourceAuthorizationFactory])
|
|
99
|
+
], TaskAuthorizationService);
|
|
100
|
+
//# sourceMappingURL=task-authorization.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-authorization.service.js","sourceRoot":"","sources":["../../../../../src/modules/authorization/services/modules/task-authorization.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AAIpD,mGAGwD;AAOjD,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAIN;IAHZ,MAAM,GAAG,IAAI,eAAM,CAAC,0BAAwB,CAAC,IAAI,CAAC,CAAC;IAC5D,QAAQ,CAAmC;IAEnD,YAA6B,WAAyC;QAAzC,gBAAW,GAAX,WAAW,CAA8B;IAAG,CAAC;IAKlE,WAAW,CACjB,kBAAyC;QAEzC,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,kBAAkB,EAAE,CAAC;YACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,CACL,IAAI,CAAC,QAAQ;YAC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,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,IAAS,EACT,IAAS,EACT,kBAAyC;QAGzC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;QACtD,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,IAAS,EACT,KAAU,EACV,kBAAyC;QAGzC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;QACtD,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,IAAS,EACT,kBAAyC;QAEzC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;QACtD,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,IAAS,EACT,kBAAyC;QAEzC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;QACtD,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF,CAAA;AA9KY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;qCAK+B,6DAA4B;GAJ3D,wBAAwB,CA8KpC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Cache } from "cache-manager";
|
|
2
|
+
import { IPermissionCache } from "../interfaces/authorization.interface";
|
|
3
|
+
export declare class PermissionCacheService implements IPermissionCache {
|
|
4
|
+
private cacheManager;
|
|
5
|
+
constructor(cacheManager: Cache);
|
|
6
|
+
get(key: string): Promise<any>;
|
|
7
|
+
set(key: string, value: any, ttl?: number): Promise<void>;
|
|
8
|
+
delete(key: string): Promise<void>;
|
|
9
|
+
clear(pattern: string): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PermissionCacheService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const cache_manager_1 = require("@nestjs/cache-manager");
|
|
18
|
+
let PermissionCacheService = class PermissionCacheService {
|
|
19
|
+
cacheManager;
|
|
20
|
+
constructor(cacheManager) {
|
|
21
|
+
this.cacheManager = cacheManager;
|
|
22
|
+
}
|
|
23
|
+
async get(key) {
|
|
24
|
+
return await this.cacheManager.get(key);
|
|
25
|
+
}
|
|
26
|
+
async set(key, value, ttl) {
|
|
27
|
+
await this.cacheManager.set(key, value, ttl ? ttl * 1000 : undefined);
|
|
28
|
+
}
|
|
29
|
+
async delete(key) {
|
|
30
|
+
await this.cacheManager.del(key);
|
|
31
|
+
}
|
|
32
|
+
async clear(pattern) {
|
|
33
|
+
const store = this.cacheManager.stores[0];
|
|
34
|
+
if (store.keys) {
|
|
35
|
+
const keys = await store.keys(pattern);
|
|
36
|
+
if (keys && keys.length > 0) {
|
|
37
|
+
await Promise.all(keys.map((key) => this.cacheManager.del(key)));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.PermissionCacheService = PermissionCacheService;
|
|
43
|
+
exports.PermissionCacheService = PermissionCacheService = __decorate([
|
|
44
|
+
(0, common_1.Injectable)(),
|
|
45
|
+
__param(0, (0, common_1.Inject)(cache_manager_1.CACHE_MANAGER)),
|
|
46
|
+
__metadata("design:paramtypes", [Object])
|
|
47
|
+
], PermissionCacheService);
|
|
48
|
+
//# sourceMappingURL=permission-cache.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-cache.service.js","sourceRoot":"","sources":["../../../../src/modules/authorization/services/permission-cache.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,yDAAsD;AAK/C,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACU;IAA3C,YAA2C,YAAmB;QAAnB,iBAAY,GAAZ,YAAY,CAAO;IAAG,CAAC;IAElE,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,GAAY;QAC7C,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACxE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAe;QAGzB,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAQ,CAAC;QACjD,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACvC,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC5B,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,GAAG,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CACtD,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AA5BY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,6BAAa,CAAC,CAAA;;GADvB,sBAAsB,CA4BlC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Repository } from "typeorm";
|
|
2
|
+
import { Permission } from "../../../entities/";
|
|
3
|
+
import { PermissionContextType, PermissionResult } from "../../../common/";
|
|
4
|
+
import { IPermissionEvaluator } from "../interfaces/authorization.interface";
|
|
5
|
+
import { DynamicFilterService } from "./dynamic-filter.service";
|
|
6
|
+
export declare class PermissionEvaluatorService implements IPermissionEvaluator {
|
|
7
|
+
private readonly permissionRepository;
|
|
8
|
+
private readonly dynamicFilterService;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
constructor(permissionRepository: Repository<Permission>, dynamicFilterService: DynamicFilterService);
|
|
11
|
+
evaluate(context: PermissionContextType): Promise<PermissionResult>;
|
|
12
|
+
private getUserPermissionRules;
|
|
13
|
+
private evaluateRules;
|
|
14
|
+
private evaluateRule;
|
|
15
|
+
private checkConditions;
|
|
16
|
+
private checkCondition;
|
|
17
|
+
private checkTimeRestrictions;
|
|
18
|
+
private checkStatusRestrictions;
|
|
19
|
+
private buildFiltersFromCriteria;
|
|
20
|
+
private buildLegacyFilters;
|
|
21
|
+
private getSupervisedUserIds;
|
|
22
|
+
private sortRulesByPermissiveness;
|
|
23
|
+
private combineResults;
|
|
24
|
+
private checkIsSubGroupSupervisor;
|
|
25
|
+
private checkIsSubGroupMember;
|
|
26
|
+
}
|