@elsikora/nestjs-crud-automator 1.19.0-dev.1 → 1.20.0-dev.1

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.
Files changed (58) hide show
  1. package/README.md +5 -3
  2. package/dist/cjs/class/api/authorization/engine.class.js +1 -0
  3. package/dist/cjs/class/api/authorization/engine.class.js.map +1 -1
  4. package/dist/cjs/class/api/authorization/guard.class.js +7 -3
  5. package/dist/cjs/class/api/authorization/guard.class.js.map +1 -1
  6. package/dist/cjs/class/api/authorization/policy/base.class.d.ts +15 -4
  7. package/dist/cjs/class/api/authorization/policy/base.class.js +8 -3
  8. package/dist/cjs/class/api/authorization/policy/base.class.js.map +1 -1
  9. package/dist/cjs/class/api/authorization/policy/discovery-service.class.js +1 -0
  10. package/dist/cjs/class/api/authorization/policy/discovery-service.class.js.map +1 -1
  11. package/dist/cjs/class/api/authorization/policy/registry.class.d.ts +13 -5
  12. package/dist/cjs/class/api/authorization/policy/registry.class.js +82 -26
  13. package/dist/cjs/class/api/authorization/policy/registry.class.js.map +1 -1
  14. package/dist/cjs/decorator/api/authorization/policy.decorator.js +1 -0
  15. package/dist/cjs/decorator/api/authorization/policy.decorator.js.map +1 -1
  16. package/dist/cjs/interface/class/api/authorization/decision.interface.d.ts +1 -0
  17. package/dist/cjs/interface/class/api/authorization/policy/build-options.interface.d.ts +10 -0
  18. package/dist/cjs/interface/class/api/authorization/policy/cache-options.interface.d.ts +8 -0
  19. package/dist/cjs/interface/class/api/authorization/policy/index.d.ts +2 -0
  20. package/dist/cjs/interface/class/api/authorization/policy/interface.d.ts +1 -0
  21. package/dist/cjs/interface/class/api/authorization/policy/registry.interface.d.ts +4 -1
  22. package/dist/cjs/interface/class/api/authorization/policy/subscriber/context/data.interface.d.ts +17 -0
  23. package/dist/cjs/interface/class/api/authorization/policy/subscriber/context/index.d.ts +2 -0
  24. package/dist/cjs/interface/class/api/authorization/policy/subscriber/context/interface.d.ts +19 -0
  25. package/dist/cjs/interface/class/api/authorization/policy/subscriber/index.d.ts +1 -1
  26. package/dist/cjs/interface/class/api/authorization/policy/subscriber/interface.d.ts +3 -2
  27. package/dist/cjs/interface/class/api/authorization/policy/subscriber/properties.interface.d.ts +2 -0
  28. package/dist/cjs/interface/class/api/authorization/policy/subscriber/registration.interface.d.ts +2 -0
  29. package/dist/esm/class/api/authorization/engine.class.js +1 -0
  30. package/dist/esm/class/api/authorization/engine.class.js.map +1 -1
  31. package/dist/esm/class/api/authorization/guard.class.js +7 -3
  32. package/dist/esm/class/api/authorization/guard.class.js.map +1 -1
  33. package/dist/esm/class/api/authorization/policy/base.class.d.ts +15 -4
  34. package/dist/esm/class/api/authorization/policy/base.class.js +8 -3
  35. package/dist/esm/class/api/authorization/policy/base.class.js.map +1 -1
  36. package/dist/esm/class/api/authorization/policy/discovery-service.class.js +1 -0
  37. package/dist/esm/class/api/authorization/policy/discovery-service.class.js.map +1 -1
  38. package/dist/esm/class/api/authorization/policy/registry.class.d.ts +13 -5
  39. package/dist/esm/class/api/authorization/policy/registry.class.js +82 -26
  40. package/dist/esm/class/api/authorization/policy/registry.class.js.map +1 -1
  41. package/dist/esm/decorator/api/authorization/policy.decorator.js +1 -0
  42. package/dist/esm/decorator/api/authorization/policy.decorator.js.map +1 -1
  43. package/dist/esm/interface/class/api/authorization/decision.interface.d.ts +1 -0
  44. package/dist/esm/interface/class/api/authorization/policy/build-options.interface.d.ts +10 -0
  45. package/dist/esm/interface/class/api/authorization/policy/cache-options.interface.d.ts +8 -0
  46. package/dist/esm/interface/class/api/authorization/policy/index.d.ts +2 -0
  47. package/dist/esm/interface/class/api/authorization/policy/interface.d.ts +1 -0
  48. package/dist/esm/interface/class/api/authorization/policy/registry.interface.d.ts +4 -1
  49. package/dist/esm/interface/class/api/authorization/policy/subscriber/context/data.interface.d.ts +17 -0
  50. package/dist/esm/interface/class/api/authorization/policy/subscriber/context/index.d.ts +2 -0
  51. package/dist/esm/interface/class/api/authorization/policy/subscriber/context/interface.d.ts +19 -0
  52. package/dist/esm/interface/class/api/authorization/policy/subscriber/index.d.ts +1 -1
  53. package/dist/esm/interface/class/api/authorization/policy/subscriber/interface.d.ts +3 -2
  54. package/dist/esm/interface/class/api/authorization/policy/subscriber/properties.interface.d.ts +2 -0
  55. package/dist/esm/interface/class/api/authorization/policy/subscriber/registration.interface.d.ts +2 -0
  56. package/package.json +1 -1
  57. package/dist/cjs/interface/class/api/authorization/policy/subscriber/context.interface.d.ts +0 -9
  58. package/dist/esm/interface/class/api/authorization/policy/subscriber/context.interface.d.ts +0 -9
package/README.md CHANGED
@@ -378,9 +378,11 @@ import { UserEntity } from "../user.entity";
378
378
 
379
379
  @ApiAuthorizationPolicy<UserEntity>({ entity: UserEntity, priority: 200 })
380
380
  export class UserAccessPolicy extends ApiAuthorizationPolicyBase<UserEntity> {
381
- onBeforeGet() {
381
+ onBeforeGet(context) {
382
+ const { subject } = context.DATA;
383
+
382
384
  return this.allow({
383
- scope: ({ subject }) => ({ where: { id: subject.id } }),
385
+ scope: () => ({ where: { id: subject.id } }),
384
386
  });
385
387
  }
386
388
 
@@ -393,7 +395,7 @@ export class UserAccessPolicy extends ApiAuthorizationPolicyBase<UserEntity> {
393
395
  }
394
396
  ```
395
397
 
396
- Policies can return allow/deny rules, merge scope conditions into generated queries, and transform responses before they are sent back to the client.
398
+ Policies can return allow/deny rules, merge scope conditions into generated queries, and transform responses before they are sent back to the client. `authorizationDecision.policyIds` lists all policy IDs contributing rules for the request. You can optionally enable policy caching globally via `ApiAuthorizationPolicyRegistry.configureCache()` or per policy via the `cache` option when policies are static.
397
399
 
398
400
  ### `CorrelationIDResponseBodyInterceptor`: Request Tracing
399
401
 
@@ -54,6 +54,7 @@ exports.ApiAuthorizationEngine = class ApiAuthorizationEngine {
54
54
  appliedRules: payload.appliedRules,
55
55
  effect: payload.effect,
56
56
  policyId: options.policy.policyId,
57
+ policyIds: options.policy.policyIds,
57
58
  resource: options.resource,
58
59
  resourceType: options.policy.entity.name ?? "UnknownResource",
59
60
  scope: payload.scope,
@@ -1 +1 @@
1
- {"version":3,"file":"engine.class.js","sources":["../../../../../../src/class/api/authorization/engine.class.ts"],"sourcesContent":[null],"names":["ApiAuthorizationEngine","EAuthorizationEffect","AuthorizationScopeMergeWhere","__decorate","Injectable"],"mappings":";;;;;;;AAWaA,8BAAsB,GAA5B,MAAM,sBAAsB,CAAA;IAC3B,MAAM,QAAQ,CAA8B,OAAqD,EAAA;AACvG,QAAA,MAAM,OAAO,GAAoC;YAChD,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;SACxB;QAED,MAAM,YAAY,GAAuC,EAAE;AAC3D,QAAA,IAAI,KAA4C;QAChD,MAAM,UAAU,GAAuE,EAAE;QAEzF,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE;YACxC,MAAM,iBAAiB,GAAY,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC;YAE9E,IAAI,CAAC,iBAAiB,EAAE;gBACvB;YACD;YAEA,IAAI,IAAI,CAAC,MAAM,KAAKC,gCAAoB,CAAC,IAAI,EAAE;AAC9C,gBAAA,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;oBAClC,YAAY,EAAE,CAAC,IAAI,CAAC;oBACpB,MAAM,EAAEA,gCAAoB,CAAC,IAAI;AACjC,oBAAA,KAAK,EAAE,SAAS;AAChB,oBAAA,UAAU,EAAE,EAAE;AACd,iBAAA,CAAC;YACH;AAEA,YAAA,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;AACvB,YAAA,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC;AAEnD,YAAA,IAAI,IAAI,CAAC,eAAe,EAAE;AACzB,gBAAA,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC;YACtC;QACD;AAEA,QAAA,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K,EAAE;AAChB,YAAA,OAAO,YAAY;QACpB;QAEA,MAAM,UAAU,GAA0C,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QAEnF,IAAI,CAAC,UAAU,EAAE;AAChB,YAAA,OAAO,YAAY;QACpB;QAEA,IAAI,CAAC,YAAY,EAAE;AAClB,YAAA,OAAO,UAAU;QAClB;QAEA,OAAO;AACN,YAAA,GAAG,YAAY;AACf,YAAA,GAAG,UAAU;YACb,KAAK,EAAEC,0CAA4B,CAAC,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC;SACzE;IACF;;AAxGYF,8BAAsB,GAAAG,oBAAA,CAAA;AADlC,IAAAC,iBAAU;AACE,CAAA,EAAAJ,8BAAsB,CAyGlC;;"}
1
+ {"version":3,"file":"engine.class.js","sources":["../../../../../../src/class/api/authorization/engine.class.ts"],"sourcesContent":[null],"names":["ApiAuthorizationEngine","EAuthorizationEffect","AuthorizationScopeMergeWhere","__decorate","Injectable"],"mappings":";;;;;;;AAWaA,8BAAsB,GAA5B,MAAM,sBAAsB,CAAA;IAC3B,MAAM,QAAQ,CAA8B,OAAqD,EAAA;AACvG,QAAA,MAAM,OAAO,GAAoC;YAChD,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;SACxB;QAED,MAAM,YAAY,GAAuC,EAAE;AAC3D,QAAA,IAAI,KAA4C;QAChD,MAAM,UAAU,GAAuE,EAAE;QAEzF,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE;YACxC,MAAM,iBAAiB,GAAY,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC;YAE9E,IAAI,CAAC,iBAAiB,EAAE;gBACvB;YACD;YAEA,IAAI,IAAI,CAAC,MAAM,KAAKC,gCAAoB,CAAC,IAAI,EAAE;AAC9C,gBAAA,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;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iBAAiB;YAC7D,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,UAAU,EAAE,OAAO,CAAC,UAAU;SAC9B;IACF;AAEQ,IAAA,MAAM,iBAAiB,CAA8B,IAAiC,EAAE,OAAwC,EAAA;AACvI,QAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;AACpB,YAAA,OAAO,IAAI;QACZ;QAEA,MAAM,MAAM,GAAY,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAErD,OAAO,MAAM,KAAK,IAAI;IACvB;AAEQ,IAAA,MAAM,UAAU,CAA8B,YAAmD,EAAE,IAAiC,EAAE,OAAwC,EAAA;AACrL,QAAA,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;AAChB,YAAA,OAAO,YAAY;QACpB;QAEA,MAAM,UAAU,GAA0C,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QAEnF,IAAI,CAAC,UAAU,EAAE;AAChB,YAAA,OAAO,YAAY;QACpB;QAEA,IAAI,CAAC,YAAY,EAAE;AAClB,YAAA,OAAO,UAAU;QAClB;QAEA,OAAO;AACN,YAAA,GAAG,YAAY;AACf,YAAA,GAAG,UAAU;YACb,KAAK,EAAEC,0CAA4B,CAAC,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC;SACzE;IACF;;AAzGYF,8BAAsB,GAAAG,oBAAA,CAAA;AADlC,IAAAC,iBAAU;AACE,CAAA,EAAAJ,8BAAsB,CA0GlC;;"}
@@ -30,14 +30,18 @@ exports.ApiAuthorizationGuard = class ApiAuthorizationGuard {
30
30
  }
31
31
  const action = this.resolveAction(context);
32
32
  authorizationGuardLogger.verbose(`Evaluating authorization for entity "${entityConstructor.name}" action "${action}"`);
33
- const policy = await this.policyRegistry.buildAggregatedPolicy(entityConstructor, action);
33
+ const request = context.switchToHttp().getRequest();
34
+ const subject = resolveDefaultSubject_utility.AuthorizationResolveDefaultSubject(request.user);
35
+ const authenticationRequest = request;
36
+ const policy = await this.policyRegistry.buildAggregatedPolicy(entityConstructor, action, {
37
+ authenticationRequest,
38
+ subject,
39
+ });
34
40
  if (!policy) {
35
41
  authorizationGuardLogger.debug(`No policy found for entity "${entityConstructor.name}" action "${action}", allowing access`);
36
42
  return true;
37
43
  }
38
44
  authorizationGuardLogger.verbose(`Found policy "${policy.policyId}" with ${policy.rules.length} rules for entity "${entityConstructor.name}" action "${action}"`);
39
- const request = context.switchToHttp().getRequest();
40
- const subject = resolveDefaultSubject_utility.AuthorizationResolveDefaultSubject(request.user);
41
45
  const decision = await this.authorizationEngine.evaluate({
42
46
  action,
43
47
  policy,
@@ -1 +1 @@
1
- {"version":3,"file":"guard.class.js","sources":["../../../../../../src/class/api/authorization/guard.class.ts"],"sourcesContent":[null],"names":["LoggerUtility","ApiAuthorizationGuard","AuthorizationResolveDefaultSubject","EAuthorizationEffect","ForbiddenException","AUTHORIZATION_DECISION_METADATA_CONSTANT","CONTROLLER_API_DECORATOR_CONSTANT","__decorate","Injectable","__param","Inject","AUTHORIZATION_POLICY_REGISTRY_TOKEN","ApiAuthorizationEngine"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,wBAAwB,GAAkBA,4BAAa,CAAC,SAAS,CAAC,uBAAuB,CAAC;AAGnFC,6BAAqB,GAA3B,MAAM,qBAAqB,CAAA;AAE8B,IAAA,cAAA;AAC7C,IAAA,mBAAA;IAFlB,WAAA,CAC+D,cAA+C,EAC5F,mBAA2C,EAAA;QADE,IAAA,CAAA,cAAc,GAAd,cAAc;QAC3D,IAAA,CAAA,mBAAmB,GAAnB,mBAAmB;IAClC;IAEI,MAAM,WAAW,CAAC,OAAyB,EAAA;QACjD,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE;AACzC,YAAA,wBAAwB,CAAC,KAAK,CAAC,6EAA6E,CAAC;AAE7G,YAAA,OAAO,IAAI;QACZ;QAEA,MAAM,iBAAiB,GAA2C,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AAA;AADjC,IAAAC,iBAAU,EAAE;AAGV,IAAAC,iBAAA,CAAA,CAAA,EAAAC,aAAM,CAACC,qDAAmC,CAAC,CAAA;uDACNC,mCAAsB,CAAA;AAHjD,CAAA,EAAAX,6BAAqB,CAgFjC;;"}
1
+ {"version":3,"file":"guard.class.js","sources":["../../../../../../src/class/api/authorization/guard.class.ts"],"sourcesContent":[null],"names":["LoggerUtility","ApiAuthorizationGuard","AuthorizationResolveDefaultSubject","EAuthorizationEffect","ForbiddenException","AUTHORIZATION_DECISION_METADATA_CONSTANT","CONTROLLER_API_DECORATOR_CONSTANT","__decorate","Injectable","__param","Inject","AUTHORIZATION_POLICY_REGISTRY_TOKEN","ApiAuthorizationEngine"],"mappings":";;;;;;;;;;;;AAkBA,MAAM,wBAAwB,GAAkBA,4BAAa,CAAC,SAAS,CAAC,uBAAuB,CAAC;AAGnFC,6BAAqB,GAA3B,MAAM,qBAAqB,CAAA;AAE8B,IAAA,cAAA;AAC7C,IAAA,mBAAA;IAFlB,WAAA,CAC+D,cAA+C,EAC5F,mBAA2C,EAAA;QADE,IAAA,CAAA,cAAc,GAAd,cAAc;QAC3D,IAAA,CAAA,mBAAmB,GAAnB,mBAAmB;IAClC;IAEI,MAAM,WAAW,CAAC,OAAyB,EAAA;QACjD,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE;AACzC,YAAA,wBAAwB,CAAC,KAAK,CAAC,6EAA6E,CAAC;AAE7G,YAAA,OAAO,IAAI;QACZ;QAEA,MAAM,iBAAiB,GAA2C,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC;QAExG,IAAI,CAAC,iBAAiB,EAAE;AACvB,YAAA,wBAAwB,CAAC,KAAK,CAAC,4EAA4E,CAAC;AAE5G,YAAA,OAAO,IAAI;QACZ;QAEA,MAAM,MAAM,GAAW,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;QAClD,wBAAwB,CAAC,OAAO,CAAC,CAAA,qCAAA,EAAw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
1
  import type { IApiBaseEntity } from '../../../../interface/api-base-entity.interface';
2
- import type { IApiAuthorizationPolicySubscriberRule } from '../../../../interface/class/api/authorization/policy/subscriber/index';
2
+ import type { IApiAuthorizationPolicySubscriber, IApiAuthorizationPolicySubscriberRule } from '../../../../interface/class/api/authorization/policy/subscriber/index';
3
3
  import { ApiSubscriberBase } from '../../subscriber/base.class';
4
4
  /**
5
5
  * Base class for all authorization policies. It mirrors ApiFunctionSubscriberBase
6
6
  * and provides helper methods to create allow/deny rules that are later executed by the policy executor.
7
7
  * @template E - Entity type extending IApiBaseEntity
8
8
  */
9
- export declare abstract class ApiAuthorizationPolicyBase<E extends IApiBaseEntity> extends ApiSubscriberBase {
9
+ export declare abstract class ApiAuthorizationPolicyBase<E extends IApiBaseEntity> extends ApiSubscriberBase implements IApiAuthorizationPolicySubscriber<E> {
10
+ getCustomActionRule?: IApiAuthorizationPolicySubscriber<E>["getCustomActionRule"];
11
+ onBeforeCreate?: IApiAuthorizationPolicySubscriber<E>["onBeforeCreate"];
12
+ onBeforeDelete?: IApiAuthorizationPolicySubscriber<E>["onBeforeDelete"];
13
+ onBeforeGet?: IApiAuthorizationPolicySubscriber<E>["onBeforeGet"];
14
+ onBeforeGetList?: IApiAuthorizationPolicySubscriber<E>["onBeforeGetList"];
15
+ onBeforePartialUpdate?: IApiAuthorizationPolicySubscriber<E>["onBeforePartialUpdate"];
16
+ onBeforeUpdate?: IApiAuthorizationPolicySubscriber<E>["onBeforeUpdate"];
10
17
  /**
11
18
  * Creates an ALLOW rule with optional overrides.
12
19
  * @param {Omit<IApiAuthorizationPolicySubscriberRule<E>, "effect">} [rule] - Rule fields to merge.
@@ -28,10 +35,14 @@ export declare abstract class ApiAuthorizationPolicyBase<E extends IApiBaseEntit
28
35
  protected deny<R>(rule?: Omit<IApiAuthorizationPolicySubscriberRule<E, R>, "effect">): IApiAuthorizationPolicySubscriberRule<E, R>;
29
36
  /**
30
37
  * Helper that scopes data access to the owner identified by a field.
31
- * Automatically handles relations by using nested id structure.
38
+ * Automatically resolves relation vs scalar fields by default.
32
39
  * @param {keyof E} [ownerField] - Entity field used to match the subject id, defaults to ownerId.
33
40
  * @param {Omit<IApiAuthorizationPolicySubscriberRule<E>, "effect">} [rule] - Optional overrides.
41
+ * @param {{ isRelation?: boolean }} [options] - Override relation handling; defaults to auto.
42
+ * @param {boolean} [options.isRelation] - Whether the field is a relation (defaults to auto).
34
43
  * @returns {IApiAuthorizationPolicySubscriberRule<E>} Allow rule with owner scope.
35
44
  */
36
- protected scopeToOwner<R>(ownerField?: keyof E, rule?: Omit<IApiAuthorizationPolicySubscriberRule<E, R>, "effect">): IApiAuthorizationPolicySubscriberRule<E, R>;
45
+ protected scopeToOwner<R>(ownerField?: keyof E, rule?: Omit<IApiAuthorizationPolicySubscriberRule<E, R>, "effect">, options?: {
46
+ isRelation?: boolean;
47
+ }): IApiAuthorizationPolicySubscriberRule<E, R>;
37
48
  }
@@ -45,17 +45,22 @@ class ApiAuthorizationPolicyBase extends base_class.ApiSubscriberBase {
45
45
  }
46
46
  /**
47
47
  * Helper that scopes data access to the owner identified by a field.
48
- * Automatically handles relations by using nested id structure.
48
+ * Automatically resolves relation vs scalar fields by default.
49
49
  * @param {keyof E} [ownerField] - Entity field used to match the subject id, defaults to ownerId.
50
50
  * @param {Omit<IApiAuthorizationPolicySubscriberRule<E>, "effect">} [rule] - Optional overrides.
51
+ * @param {{ isRelation?: boolean }} [options] - Override relation handling; defaults to auto.
52
+ * @param {boolean} [options.isRelation] - Whether the field is a relation (defaults to auto).
51
53
  * @returns {IApiAuthorizationPolicySubscriberRule<E>} Allow rule with owner scope.
52
54
  */
53
- scopeToOwner(ownerField = "ownerId", rule = {}) {
55
+ scopeToOwner(ownerField = "ownerId", rule = {}, options = {}) {
56
+ const ownerFieldName = String(ownerField);
57
+ const isRelation = options.isRelation ?? !ownerFieldName.endsWith("Id");
54
58
  return this.allow({
55
59
  scope: ({ subject }) => {
60
+ const ownerCondition = isRelation ? { id: subject.id } : subject.id;
56
61
  return {
57
62
  where: {
58
- [ownerField]: { id: subject.id },
63
+ [ownerFieldName]: ownerCondition,
59
64
  },
60
65
  };
61
66
  },
@@ -1 +1 @@
1
- {"version":3,"file":"base.class.js","sources":["../../../../../../../src/class/api/authorization/policy/base.class.ts"],"sourcesContent":[null],"names":["ApiSubscriberBase","EAuthorizationEffect"],"mappings":";;;;;AAQA;;;;AAIG;AACG,MAAgB,0BAAqD,SAAQA,4BAAiB,CAAA;AACnG;;;;AAIG;IACO,KAAK,CAAI,OAAoE,EAAiE,EAAA;QACvJ,OAAO;YACN,MAAM,EAAEC,gCAAoB,CAAC,KAAK;AAClC,YAAA,GAAG,IAAI;SACP;IACF;AAEA;;;;;AAKG;AACO,IAAA,aAAa,CAAI,KAAoB,EAAE,IAAA,GAAoE,EAAiE,EAAA;QACrL,OAAO,IAAI,CAAC,KAAK,CAAC;YACjB,SAAS,EAAE,CAAC,EAAE,OAAO,EAAmC,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,IAAY,KAAK,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACvH,YAAA,GAAG,IAAI;AACP,SAAA,CAAC;IACH;AAEA;;;;AAIG;IACO,IAAI,CAAI,OAAoE,EAAiE,EAAA;QACtJ,OAAO;YACN,MAAM,EAAEA,gCAAoB,CAAC,IAAI;AACjC,YAAA,GAAG,IAAI;SACP;IACF;AAEA;;;;;;AAMG;AACO,IAAA,YAAY,CAAI,UAAA,GAAsB,SAAoB,EAAE,OAAoE,EAAiE,EAAA;QAC1M,OAAO,IAAI,CAAC,KAAK,CAAC;AACjB,YAAA,KAAK,EAAE,CAAC,EAAE,OAAO,EAAmC,KAAI;gBACvD,OAAO;AACN,oBAAA,KAAK,EAAE;wBACN,CAAC,UAAoB,GAAG,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE;AACnB,qBAAA;iBACxB;YACF,CAAC;AACD,YAAA,GAAG,IAAI;AACP,SAAA,CAAC;IACH;AACA;;;;"}
1
+ {"version":3,"file":"base.class.js","sources":["../../../../../../../src/class/api/authorization/policy/base.class.ts"],"sourcesContent":[null],"names":["ApiSubscriberBase","EAuthorizationEffect"],"mappings":";;;;;AAQA;;;;AAIG;AACG,MAAgB,0BAAqD,SAAQA,4BAAiB,CAAA;AAenG;;;;AAIG;IACO,KAAK,CAAI,OAAoE,EAAiE,EAAA;QACvJ,OAAO;YACN,MAAM,EAAEC,gCAAoB,CAAC,KAAK;AAClC,YAAA,GAAG,IAAI;SACP;IACF;AAEA;;;;;AAKG;AACO,IAAA,aAAa,CAAI,KAAoB,EAAE,IAAA,GAAoE,EAAiE,EAAA;QACrL,OAAO,IAAI,CAAC,KAAK,CAAC;YACjB,SAAS,EAAE,CAAC,EAAE,OAAO,EAAmC,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,IAAY,KAAK,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACvH,YAAA,GAAG,IAAI;AACP,SAAA,CAAC;IACH;AAEA;;;;AAIG;IACO,IAAI,CAAI,OAAoE,EAAiE,EAAA;QACtJ,OAAO;YACN,MAAM,EAAEA,gCAAoB,CAAC,IAAI;AACjC,YAAA,GAAG,IAAI;SACP;IACF;AAEA;;;;;;;;AAQG;IACO,YAAY,CAAI,aAAsB,SAAoB,EAAE,OAAoE,EAAiE,EAAE,UAAoC,EAAE,EAAA;AAClP,QAAA,MAAM,cAAc,GAAW,MAAM,CAAC,UAAU,CAAC;AACjD,QAAA,MAAM,UAAU,GAAY,OAAO,CAAC,UAAU,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC;QAEhF,OAAO,IAAI,CAAC,KAAK,CAAC;AACjB,YAAA,KAAK,EAAE,CAAC,EAAE,OAAO,EAAmC,KAAI;AACvD,gBAAA,MAAM,cAAc,GAAY,UAAU,GAAG,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE;gBAE5E,OAAO;AACN,oBAAA,KAAK,EAAE;wBACN,CAAC,cAAc,GAAG,cAAc;AACT,qBAAA;iBACxB;YACF,CAAC;AACD,YAAA,GAAG,IAAI;AACP,SAAA,CAAC;IACH;AACA;;;;"}
@@ -31,6 +31,7 @@ exports.ApiAuthorizationPolicyDiscoveryService = class ApiAuthorizationPolicyDis
31
31
  }
32
32
  const policyId = properties.policyId ?? `${properties.entity.name?.toLowerCase() ?? "unknown"}${decorator_constant.AUTHORIZATION_POLICY_DECORATOR_CONSTANT.DEFAULT_POLICY_ID_SUFFIX}`;
33
33
  this.registry.registerSubscriber({
34
+ cache: properties.cache,
34
35
  description: properties.description,
35
36
  entity: properties.entity,
36
37
  policyId,
@@ -1 +1 @@
1
- {"version":3,"file":"discovery-service.class.js","sources":["../../../../../../../src/class/api/authorization/policy/discovery-service.class.ts"],"sourcesContent":[null],"names":["LoggerUtility","ApiAuthorizationPolicyDiscoveryService","AUTHORIZATION_POLICY_DECORATOR_CONSTANT","ApiAuthorizationPolicyBase","__decorate","Injectable","DiscoveryService","ApiAuthorizationPolicyRegistry"],"mappings":";;;;;;;;;;AAYA,MAAM,qBAAqB,GAAkBA,4BAAa,CAAC,SAAS,CAAC,wCAAwC,CAAC;AAGjGC,8CAAsC,GAA5C,MAAM,sCAAsC,CAAA;AAEhC,IAAA,gBAAA;AACA,IAAA,QAAA;IAFlB,WAAA,CACkB,gBAAkC,EAClC,QAAwC,EAAA;QADxC,IAAA,CAAA,gBAAgB,GAAhB,gBAAgB;QAChB,IAAA,CAAA,QAAQ,GAAR,QAAQ;IACvB;IAEI,YAAY,GAAA;AAClB,QAAA,qBAAqB,CAAC,OAAO,CAAC,4CAA4C,CAAC;QAC3E,MAAM,SAAS,GAA2B,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE;AAC9E,QAAA,MAAM,eAAe,GAA2B,SAAS,CAAC,MAAM,CAAC,CAAC,OAAwB,KAAK,IAAI,CAAC,eAAe,CAAC,O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YAAYC,qCAA0B,IAAI,OAAO,CAAC,WAAW,CAACD,0DAAuC,CAAC,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9M;;AAzCYD,8CAAsC,GAAAG,oBAAA,CAAA;AADlD,IAAAC,iBAAU,EAAE;+CAGwBC,qBAAgB;QACxBC,6CAA8B,CAAA;AAH9C,CAAA,EAAAN,8CAAsC,CA0ClD;;"}
1
+ {"version":3,"file":"discovery-service.class.js","sources":["../../../../../../../src/class/api/authorization/policy/discovery-service.class.ts"],"sourcesContent":[null],"names":["LoggerUtility","ApiAuthorizationPolicyDiscoveryService","AUTHORIZATION_POLICY_DECORATOR_CONSTANT","ApiAuthorizationPolicyBase","__decorate","Injectable","DiscoveryService","ApiAuthorizationPolicyRegistry"],"mappings":";;;;;;;;;;AAYA,MAAM,qBAAqB,GAAkBA,4BAAa,CAAC,SAAS,CAAC,wCAAwC,CAAC;AAGjGC,8CAAsC,GAA5C,MAAM,sCAAsC,CAAA;AAEhC,IAAA,gBAAA;AACA,IAAA,QAAA;IAFlB,WAAA,CACkB,gBAAkC,EAClC,QAAwC,EAAA;QADxC,IAAA,CAAA,gBAAgB,GAAhB,gBAAgB;QAChB,IAAA,CAAA,QAAQ,GAAR,QAAQ;IACvB;IAEI,YAAY,GAAA;AAClB,QAAA,qBAAqB,CAAC,OAAO,CAAC,4CAA4C,CAAC;QAC3E,MAAM,SAAS,GAA2B,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE;AAC9E,QAAA,MAAM,eAAe,GAA2B,SAAS,CAAC,MAAM,CAAC,CAAC,OAAwB,KAAK,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAE7H,QAAA,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE;AACtC,YAAA,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;gBACtB;YACD;AAEA,YAAA,MAAM,QAAQ,GAAY,OAAO,CAAC,WAAW,CAACC,0DAAuC,CAAC,YAAY,EAAE,OA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;+CAGwBC,qBAAgB;QACxBC,6CAA8B,CAAA;AAH9C,CAAA,EAAAN,8CAAsC,CA2ClD;;"}
@@ -1,22 +1,30 @@
1
1
  import type { IApiBaseEntity } from '../../../../interface/api-base-entity.interface';
2
2
  import type { IApiAuthorizationPolicy, IApiAuthorizationPolicyRegistry, IApiAuthorizationPolicySubscriberRegistration } from '../../../../interface/class/api/authorization/index';
3
+ import type { IApiAuthorizationPolicyBuildOptions } from '../../../../interface/class/api/authorization/policy/build-options.interface';
4
+ import type { IApiAuthorizationPolicyCacheOptions } from '../../../../interface/class/api/authorization/policy/cache-options.interface';
3
5
  import type { TApiAuthorizationPolicyHookResult } from '../../../../type/class/api/authorization/policy/hook/index';
4
6
  type TEntityConstructor<E extends IApiBaseEntity> = new () => E;
5
7
  export declare class ApiAuthorizationPolicyRegistry implements IApiAuthorizationPolicyRegistry {
6
- private readonly POLICY_CACHE;
8
+ private cacheOptions;
7
9
  private readonly POLICY_REGISTRY;
10
+ private readonly POLICY_RULE_CACHE;
8
11
  constructor();
9
- buildAggregatedPolicy<E extends IApiBaseEntity, TAction extends string>(entity: TEntityConstructor<E>, action: TAction): Promise<IApiAuthorizationPolicy<E, TApiAuthorizationPolicyHookResult<TAction, E>> | undefined>;
12
+ buildAggregatedPolicy<E extends IApiBaseEntity, TAction extends string>(entity: TEntityConstructor<E>, action: TAction, options?: IApiAuthorizationPolicyBuildOptions): Promise<IApiAuthorizationPolicy<E, TApiAuthorizationPolicyHookResult<TAction, E>> | undefined>;
10
13
  clear(): void;
14
+ configureCache(options?: IApiAuthorizationPolicyCacheOptions): void;
11
15
  registerSubscriber<E extends IApiBaseEntity>(registration: IApiAuthorizationPolicySubscriberRegistration<E>): void;
12
- private cachePolicy;
13
- private createCacheKey;
16
+ private cacheRules;
17
+ private createPolicyCacheKey;
18
+ private getCachedRules;
14
19
  private getEntityName;
20
+ private getSubscriberName;
15
21
  private invalidateCacheForEntity;
22
+ private isCacheExpired;
16
23
  private normalizeRule;
24
+ private resolveCacheOptions;
17
25
  private resolvePolicyId;
26
+ private resolvePolicyRules;
18
27
  private resolveRouteType;
19
- private toBasePolicy;
20
28
  }
21
29
  export declare const apiAuthorizationPolicyRegistry: ApiAuthorizationPolicyRegistry;
22
30
  export {};
@@ -5,27 +5,24 @@ require('../../../../external/@elsikora/cladi/dist/esm/domain/enum/logger-log-le
5
5
  require('../../../../external/@elsikora/cladi/dist/esm/infrastructure/constant/console-logger-default-options.constant.js');
6
6
  var registry_utility = require('../../../../external/@elsikora/cladi/dist/esm/presentation/utility/create/registry.utility.js');
7
7
  var routeType_enum = require('../../../../enum/decorator/api/route-type.enum.js');
8
+ var resolveDefaultSubject_utility = require('../../../../utility/authorization/subject/resolve-default-subject.utility.js');
8
9
  var generateEntityInformation_utility = require('../../../../utility/generate-entity-information.utility.js');
9
10
  var logger_utility = require('../../../../utility/logger.utility.js');
10
11
  var executor_class = require('./executor.class.js');
11
12
 
12
13
  const policyRegistryLogger = logger_utility.LoggerUtility.getLogger("ApiAuthorizationPolicyRegistry");
13
14
  class ApiAuthorizationPolicyRegistry {
14
- POLICY_CACHE;
15
+ cacheOptions;
15
16
  POLICY_REGISTRY;
17
+ POLICY_RULE_CACHE;
16
18
  constructor() {
17
- this.POLICY_CACHE = new Map();
19
+ this.POLICY_RULE_CACHE = new Map();
18
20
  this.POLICY_REGISTRY = registry_utility.createRegistry({});
21
+ this.cacheOptions = { isEnabled: false };
19
22
  }
20
- async buildAggregatedPolicy(entity, action) {
23
+ async buildAggregatedPolicy(entity, action, options = {}) {
21
24
  const entityName = this.getEntityName(entity);
22
- const cacheKey = this.createCacheKey(entity, action);
23
- policyRegistryLogger.debug(`Building aggregated policy for entity "${entityName}" action "${action}" (cache key: ${cacheKey})`);
24
- const cachedPolicy = this.POLICY_CACHE.get(cacheKey);
25
- if (cachedPolicy) {
26
- policyRegistryLogger.debug(`Returning cached policy for "${cacheKey}"`);
27
- return cachedPolicy;
28
- }
25
+ policyRegistryLogger.debug(`Building aggregated policy for entity "${entityName}" action "${action}"`);
29
26
  const registrationWrapper = this.POLICY_REGISTRY.get(entityName);
30
27
  const registrations = registrationWrapper?.registrations ?? [];
31
28
  policyRegistryLogger.debug(`Found ${registrations.length} registration(s) for entity "${entityName}"`);
@@ -37,18 +34,28 @@ class ApiAuthorizationPolicyRegistry {
37
34
  }
38
35
  const entityMetadata = generateEntityInformation_utility.GenerateEntityInformation(entity);
39
36
  const routeType = this.resolveRouteType(action);
37
+ const { authenticationRequest, subject: subjectOverride } = options;
38
+ const subject = subjectOverride ?? resolveDefaultSubject_utility.AuthorizationResolveDefaultSubject(authenticationRequest?.user);
39
+ const contextData = {
40
+ action,
41
+ authenticationRequest,
42
+ entity,
43
+ entityMetadata,
44
+ routeType,
45
+ subject,
46
+ };
40
47
  const aggregatedRules = [];
48
+ const policyIds = new Set();
41
49
  for (const registration of registrations) {
42
50
  const context = {
43
- action,
44
- entity,
45
- entityMetadata,
46
- routeType,
51
+ ...contextData,
52
+ DATA: contextData,
47
53
  };
48
- const rules = await executor_class.ApiAuthorizationPolicyExecutor.execute(registration.subscriber, action, context);
54
+ const rules = await this.resolvePolicyRules(registration, action, context, entityName);
49
55
  if (rules.length === 0) {
50
56
  continue;
51
57
  }
58
+ policyIds.add(registration.policyId);
52
59
  const normalizedRules = rules.map((rule) => this.normalizeRule(registration.policyId, registration.priority ?? 0, rule, action));
53
60
  aggregatedRules.push(...normalizedRules);
54
61
  }
@@ -57,22 +64,30 @@ class ApiAuthorizationPolicyRegistry {
57
64
  }
58
65
  aggregatedRules.sort((a, b) => b.priority - a.priority);
59
66
  const policyDescription = registrations.find((registration) => Boolean(registration.description))?.description;
67
+ const policyIdList = [...policyIds];
60
68
  const policy = {
61
69
  action,
62
70
  description: policyDescription,
63
71
  entity,
64
72
  policyId: this.resolvePolicyId(entity),
73
+ policyIds: policyIdList,
65
74
  rules: aggregatedRules,
66
75
  };
67
- this.cachePolicy(cacheKey, policy);
68
76
  return policy;
69
77
  }
70
78
  clear() {
71
- this.POLICY_CACHE.clear();
79
+ this.POLICY_RULE_CACHE.clear();
72
80
  this.POLICY_REGISTRY.clear();
73
81
  }
82
+ configureCache(options = {}) {
83
+ this.cacheOptions = {
84
+ isEnabled: Boolean(options.isEnabled),
85
+ ttlMs: options.ttlMs,
86
+ };
87
+ }
74
88
  registerSubscriber(registration) {
75
89
  const normalizedRegistration = {
90
+ cache: registration.cache,
76
91
  description: registration.description,
77
92
  entity: registration.entity,
78
93
  policyId: registration.policyId,
@@ -90,22 +105,49 @@ class ApiAuthorizationPolicyRegistry {
90
105
  policyRegistryLogger.debug(`Total registrations for entity "${entityName}": ${wrapper.getRegistrationCount()}`);
91
106
  this.invalidateCacheForEntity(entityName);
92
107
  }
93
- cachePolicy(cacheKey, policy) {
94
- this.POLICY_CACHE.set(cacheKey, this.toBasePolicy(policy));
108
+ cacheRules(cacheKey, rules, cacheOptions) {
109
+ if (!cacheOptions.isEnabled) {
110
+ return;
111
+ }
112
+ this.POLICY_RULE_CACHE.set(cacheKey, { cachedAt: Date.now(), rules: rules });
113
+ }
114
+ createPolicyCacheKey(entityName, registration, action) {
115
+ const subscriberName = this.getSubscriberName(registration.subscriber);
116
+ return `${entityName}::${registration.policyId}::${subscriberName}::${action.toLowerCase()}`;
95
117
  }
96
- createCacheKey(entity, action) {
97
- return `${this.getEntityName(entity)}::${action.toLowerCase()}`;
118
+ getCachedRules(cacheKey, cacheOptions) {
119
+ if (!cacheOptions.isEnabled) {
120
+ return undefined;
121
+ }
122
+ const cachedEntry = this.POLICY_RULE_CACHE.get(cacheKey);
123
+ if (!cachedEntry) {
124
+ return undefined;
125
+ }
126
+ if (this.isCacheExpired(cachedEntry.cachedAt, cacheOptions.ttlMs)) {
127
+ this.POLICY_RULE_CACHE.delete(cacheKey);
128
+ return undefined;
129
+ }
130
+ return cachedEntry.rules;
98
131
  }
99
132
  getEntityName(entity) {
100
133
  return (entity.name ?? "UnknownResource").toLowerCase();
101
134
  }
135
+ getSubscriberName(subscriber) {
136
+ return subscriber.constructor?.name ?? "UnknownPolicySubscriber";
137
+ }
102
138
  invalidateCacheForEntity(entityName) {
103
- for (const cacheKey of this.POLICY_CACHE.keys()) {
139
+ for (const cacheKey of this.POLICY_RULE_CACHE.keys()) {
104
140
  if (cacheKey.startsWith(`${entityName}::`)) {
105
- this.POLICY_CACHE.delete(cacheKey);
141
+ this.POLICY_RULE_CACHE.delete(cacheKey);
106
142
  }
107
143
  }
108
144
  }
145
+ isCacheExpired(cachedAt, ttlMs) {
146
+ if (ttlMs === undefined) {
147
+ return false;
148
+ }
149
+ return Date.now() - cachedAt > ttlMs;
150
+ }
109
151
  normalizeRule(policyId, subscriberPriority, rule, action) {
110
152
  const rulePriority = rule.priority ?? 0;
111
153
  return {
@@ -119,16 +161,30 @@ class ApiAuthorizationPolicyRegistry {
119
161
  scope: rule.scope,
120
162
  };
121
163
  }
164
+ resolveCacheOptions(options) {
165
+ return {
166
+ isEnabled: options?.isEnabled ?? this.cacheOptions.isEnabled,
167
+ ttlMs: options?.ttlMs ?? this.cacheOptions.ttlMs,
168
+ };
169
+ }
122
170
  resolvePolicyId(entity) {
123
171
  return `${this.getEntityName(entity)}${decorator_constant.AUTHORIZATION_POLICY_DECORATOR_CONSTANT.DEFAULT_POLICY_ID_SUFFIX}`;
124
172
  }
173
+ async resolvePolicyRules(registration, action, context, entityName) {
174
+ const cacheOptions = this.resolveCacheOptions(registration.cache);
175
+ const cacheKey = this.createPolicyCacheKey(entityName, registration, action);
176
+ const cachedRules = this.getCachedRules(cacheKey, cacheOptions);
177
+ if (cachedRules) {
178
+ return cachedRules;
179
+ }
180
+ const rules = await executor_class.ApiAuthorizationPolicyExecutor.execute(registration.subscriber, action, context);
181
+ this.cacheRules(cacheKey, rules, cacheOptions);
182
+ return rules;
183
+ }
125
184
  resolveRouteType(action) {
126
185
  const routeTypes = Object.values(routeType_enum.EApiRouteType);
127
186
  return routeTypes.find((routeType) => routeType === action);
128
187
  }
129
- toBasePolicy(policy) {
130
- return policy;
131
- }
132
188
  }
133
189
  const apiAuthorizationPolicyRegistry = new ApiAuthorizationPolicyRegistry();
134
190
  class PolicySubscriberWrapper {
@@ -1 +1 @@
1
- {"version":3,"file":"registry.class.js","sources":["../../../../../../../src/class/api/authorization/policy/registry.class.ts"],"sourcesContent":[null],"names":["LoggerUtility","createRegistry","GenerateEntityInformation","ApiAuthorizationPolicyExecutor","AUTHORIZATION_POLICY_DECORATOR_CONSTANT","EApiRouteType"],"mappings":";;;;;;;;;;;AAcA,MAAM,oBAAoB,GAAkBA,4BAAa,CAAC,SAAS,CAAC,gCAAgC,CAAC;MAIxF,8BAA8B,CAAA;AACzB,IAAA,YAAY;AAEZ,IAAA,eAAe;AAEhC,IAAA,WAAA,GAAA;AACC,QAAA,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE;AAC7B,QAAA,IAAI,CAAC,eAAe,GAAGC,+BAAc,CAA0B,EAAE,CAAC;IACnE;AAEO,IAAA,MAAM,qBAAqB,CAAmD,MAA6B,EAAE,MAAe,EAAA;QAClI,MAAM,UAAU,GAAW,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;QACrD,MAAM,QAAQ,GAAW,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC;QAC5D,oBAAoB,CAAC,KAAK,CAAC,CAAA,uCAAA,EAA0C,UAAU,CAAA,UAAA,EAAa,MAAM,CAAA,cAAA,EAAiB,QAAQ,CAAA,CAAA,CAAG,CAAC;QAE/H,MAAM,YAAY,GAA0F,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAA0F;QAEpO,IAAI,YAAY,EAAE;AACjB,YAAA,oBAAoB,CAAC,KAAK,CAAC,gCAAgC,QAAQ,CAAA,CAAA,CAAG,CAAC;AAEvE,YAAA,OAAO,YAAY;QACpB;QAEA,MAAM,mBAAmB,GAAwC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC;AACrG,QAAA,MAAM,aAAa,GAAyE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IAAI,CAAC,CAAC,CAAC;IACvM;IAEO,OAAO,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,iBAAiB,EAAE;IAChC;IAEO,oBAAoB,GAAA;AAC1B,QAAA,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM;IACjC;IAEQ,iBAAiB,GAAA;QACxB,OAAO,IAAI,CAAC,IAAI;IACjB;AACA;;;;;"}
1
+ {"version":3,"file":"registry.class.js","sources":["../../../../../../../src/class/api/authorization/policy/registry.class.ts"],"sourcesContent":[null],"names":["LoggerUtility","createRegistry","GenerateEntityInformation","AuthorizationResolveDefaultSubject","AUTHORIZATION_POLICY_DECORATOR_CONSTANT","ApiAuthorizationPolicyExecutor","EApiRouteType"],"mappings":";;;;;;;;;;;;AAmBA,MAAM,oBAAoB,GAAkBA,4BAAa,CAAC,SAAS,CAAC,gCAAgC,CAAC;MAIxF,8BAA8B,CAAA;AAClC,IAAA,YAAY;AAEH,IAAA,eAAe;AAEf,IAAA,iBAAiB;AAElC,IAAA,WAAA,GAAA;AACC,QAAA,IAAI,CAAC,iBAAiB,GAAG,IAAI,GAAG,EAAE;AAClC,QAAA,IAAI,CAAC,eAAe,GAAGC,+BAAc,CAA0B,EAAE,CAAC;QAClE,IAAI,CAAC,YAAY,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE;IACzC;IAEO,MAAM,qBAAqB,CAAmD,MAA6B,EAAE,MAAe,EAAE,UAA+C,EAAE,EAAA;QACrL,MAAM,UAAU,GAAW,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;QACrD,oBAAoB,CAAC,KAAK,CAAC,CAAA,uCAAA,EAA0C,UAAU,CAAA,UAAA,EAAa,MAAM,CAAA,CAAA,CAAG,CAAC;QAEtG,MAAM,mBAAmB,GAAwC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC;AACrG,QAAA,MAAM,aAAa,GAAyE,mBAAmB,EAAE,aAAa,IAAI,EAAE;QAEpI,oBAAoB,CAAC,KAAK,C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aAAa,CAAC,MAAM;IACjC;IAEQ,iBAAiB,GAAA;QACxB,OAAO,IAAI,CAAC,IAAI;IACjB;AACA;;;;;"}
@@ -12,6 +12,7 @@ var decorator_constant = require('../../../constant/class/authorization/policy/d
12
12
  function ApiAuthorizationPolicy(properties) {
13
13
  const normalizedPolicyId = properties.policyId ?? `${properties.entity.name?.toLowerCase() ?? "unknown"}${decorator_constant.AUTHORIZATION_POLICY_DECORATOR_CONSTANT.DEFAULT_POLICY_ID_SUFFIX}`;
14
14
  const metadata = {
15
+ cache: properties.cache,
15
16
  description: properties.description,
16
17
  entity: properties.entity,
17
18
  policyId: normalizedPolicyId,
@@ -1 +1 @@
1
- {"version":3,"file":"policy.decorator.js","sources":["../../../../../../src/decorator/api/authorization/policy.decorator.ts"],"sourcesContent":[null],"names":["AUTHORIZATION_POLICY_DECORATOR_CONSTANT"],"mappings":";;;;AAKA;;;;;;AAMG;AACG,SAAU,sBAAsB,CAA2B,UAA0D,EAAA;IAC1H,MAAM,kBAAkB,GAAW,UAAU,CAAC,QAAQ,IAAI,CAAA,EAAG,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,SAAS,GAAGA,0DAAuC,CAAC,wBAAwB,CAAA,CAAE;AAEpL,IAAA,MAAM,QAAQ,GAAmD;QAChE,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,MAAM,EAAE,UAAU,CAAC,MAAM;AACzB,QAAA,QAAQ,EAAE,kBAAkB;AAC5B,QAAA,QAAQ,EAAE,UAAU,CAAC,QAAQ,IAAI,CAAC;KAClC;IAED,OAAO,CAAC,MAAc,KAAI;QACzB,OAAO,CAAC,cAAc,CAACA,0DAAuC,CAAC,YAAY,EAAE,QAAQ,EAAE,MAAM,CAAC;AAC/F,IAAA,CAAC;AACF;;;;"}
1
+ {"version":3,"file":"policy.decorator.js","sources":["../../../../../../src/decorator/api/authorization/policy.decorator.ts"],"sourcesContent":[null],"names":["AUTHORIZATION_POLICY_DECORATOR_CONSTANT"],"mappings":";;;;AAKA;;;;;;AAMG;AACG,SAAU,sBAAsB,CAA2B,UAA0D,EAAA;IAC1H,MAAM,kBAAkB,GAAW,UAAU,CAAC,QAAQ,IAAI,CAAA,EAAG,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,SAAS,GAAGA,0DAAuC,CAAC,wBAAwB,CAAA,CAAE;AAEpL,IAAA,MAAM,QAAQ,GAAmD;QAChE,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,MAAM,EAAE,UAAU,CAAC,MAAM;AACzB,QAAA,QAAQ,EAAE,kBAAkB;AAC5B,QAAA,QAAQ,EAAE,UAAU,CAAC,QAAQ,IAAI,CAAC;KAClC;IAED,OAAO,CAAC,MAAc,KAAI;QACzB,OAAO,CAAC,cAAc,CAACA,0DAAuC,CAAC,YAAY,EAAE,QAAQ,EAAE,MAAM,CAAC;AAC/F,IAAA,CAAC;AACF;;;;"}
@@ -9,6 +9,7 @@ export interface IApiAuthorizationDecision<E extends IApiBaseEntity, R> {
9
9
  appliedRules: Array<IApiAuthorizationRule<E, R>>;
10
10
  effect: EAuthorizationEffect;
11
11
  policyId: string;
12
+ policyIds: Array<string>;
12
13
  resource?: E;
13
14
  resourceType: string;
14
15
  scope?: IApiAuthorizationScope<E>;
@@ -0,0 +1,10 @@
1
+ import type { IApiAuthenticationRequest } from '../../../../api-authentication-request.interface';
2
+ import type { IApiAuthorizationSubject } from '../subject.interface';
3
+ /**
4
+ * Optional inputs for policy building.
5
+ * Used to enrich policy hook context.
6
+ */
7
+ export interface IApiAuthorizationPolicyBuildOptions {
8
+ authenticationRequest?: IApiAuthenticationRequest;
9
+ subject?: IApiAuthorizationSubject;
10
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Cache configuration for authorization policy registry.
3
+ * Disabled by default to avoid caching subject-dependent rules.
4
+ */
5
+ export interface IApiAuthorizationPolicyCacheOptions {
6
+ isEnabled?: boolean;
7
+ ttlMs?: number;
8
+ }
@@ -1,3 +1,5 @@
1
+ export { type IApiAuthorizationPolicyBuildOptions } from './build-options.interface';
2
+ export { type IApiAuthorizationPolicyCacheOptions } from './cache-options.interface';
1
3
  export { type IApiAuthorizationPolicy } from './interface';
2
4
  export { type IApiAuthorizationPolicyRegistry } from './registry.interface';
3
5
  export type * from './subscriber/index';
@@ -5,5 +5,6 @@ export interface IApiAuthorizationPolicy<E extends IApiBaseEntity, R> {
5
5
  description?: string;
6
6
  entity: new () => E;
7
7
  policyId: string;
8
+ policyIds: Array<string>;
8
9
  rules: Array<IApiAuthorizationRule<E, R>>;
9
10
  }
@@ -1,9 +1,12 @@
1
1
  import type { IApiBaseEntity } from '../../../../api-base-entity.interface';
2
+ import type { IApiAuthorizationPolicyBuildOptions } from './build-options.interface';
3
+ import type { IApiAuthorizationPolicyCacheOptions } from './cache-options.interface';
2
4
  import type { IApiAuthorizationPolicy } from './interface';
3
5
  import type { IApiAuthorizationPolicySubscriberRegistration } from './subscriber/registration.interface';
4
6
  import type { TApiAuthorizationPolicyHookResult } from '../../../../../type/class/api/authorization/policy/hook/index';
5
7
  export interface IApiAuthorizationPolicyRegistry {
6
- buildAggregatedPolicy<E extends IApiBaseEntity, TAction extends string>(entity: new () => E, action: TAction): Promise<IApiAuthorizationPolicy<E, TApiAuthorizationPolicyHookResult<TAction, E>> | undefined>;
8
+ buildAggregatedPolicy<E extends IApiBaseEntity, TAction extends string>(entity: new () => E, action: TAction, options?: IApiAuthorizationPolicyBuildOptions): Promise<IApiAuthorizationPolicy<E, TApiAuthorizationPolicyHookResult<TAction, E>> | undefined>;
7
9
  clear(): void;
10
+ configureCache(options?: IApiAuthorizationPolicyCacheOptions): void;
8
11
  registerSubscriber<E extends IApiBaseEntity>(registration: IApiAuthorizationPolicySubscriberRegistration<E>): void;
9
12
  }
@@ -0,0 +1,17 @@
1
+ import type { EApiRouteType } from '../../../../../../../enum/decorator/api/route-type.enum';
2
+ import type { IApiAuthenticationRequest } from '../../../../../../api-authentication-request.interface';
3
+ import type { IApiBaseEntity } from '../../../../../../api-base-entity.interface';
4
+ import type { IApiAuthorizationSubject } from '../../../subject.interface';
5
+ import type { IApiEntity } from '../../../../../../entity/interface';
6
+ /**
7
+ * Data container for authorization policy subscriber context.
8
+ * Provides strongly typed access to request metadata and subject.
9
+ */
10
+ export interface IApiAuthorizationPolicySubscriberContextData<E extends IApiBaseEntity> {
11
+ action: string;
12
+ authenticationRequest?: IApiAuthenticationRequest;
13
+ entity: new () => E;
14
+ entityMetadata: IApiEntity<E>;
15
+ routeType?: EApiRouteType;
16
+ subject: IApiAuthorizationSubject;
17
+ }
@@ -0,0 +1,2 @@
1
+ export { type IApiAuthorizationPolicySubscriberContextData } from './data.interface';
2
+ export { type IApiAuthorizationPolicySubscriberContext } from './interface';
@@ -0,0 +1,19 @@
1
+ import type { EApiRouteType } from '../../../../../../../enum/decorator/api/route-type.enum';
2
+ import type { IApiAuthenticationRequest } from '../../../../../../api-authentication-request.interface';
3
+ import type { IApiBaseEntity } from '../../../../../../api-base-entity.interface';
4
+ import type { IApiAuthorizationSubject } from '../../../subject.interface';
5
+ import type { IApiEntity } from '../../../../../../entity/interface';
6
+ import type { IApiAuthorizationPolicySubscriberContextData } from './data.interface';
7
+ /**
8
+ * Execution context for authorization policy hooks.
9
+ * Includes typed DATA while keeping legacy top-level fields.
10
+ */
11
+ export interface IApiAuthorizationPolicySubscriberContext<E extends IApiBaseEntity> {
12
+ action: string;
13
+ authenticationRequest?: IApiAuthenticationRequest;
14
+ readonly DATA: IApiAuthorizationPolicySubscriberContextData<E>;
15
+ entity: new () => E;
16
+ entityMetadata: IApiEntity<E>;
17
+ routeType?: EApiRouteType;
18
+ subject: IApiAuthorizationSubject;
19
+ }
@@ -1,4 +1,4 @@
1
- export { type IApiAuthorizationPolicySubscriberContext } from './context.interface';
1
+ export type * from './context/index';
2
2
  export { type IApiAuthorizationPolicySubscriber } from './interface';
3
3
  export { type IApiAuthorizationPolicySubscriberProperties } from './properties.interface';
4
4
  export { type IApiAuthorizationPolicySubscriberRegistration } from './registration.interface';
@@ -1,9 +1,10 @@
1
1
  import type { EApiRouteType } from '../../../../../../enum/decorator/api/route-type.enum';
2
2
  import type { IApiBaseEntity } from '../../../../../api-base-entity.interface';
3
- import type { IApiAuthorizationPolicySubscriberContext } from './context.interface';
3
+ import type { IApiAuthorizationPolicySubscriberContext } from './context/index';
4
+ import type { IApiSubscriber } from '../../../subscriber/interface';
4
5
  import type { TApiAuthorizationPolicyHookResult } from '../../../../../../type/class/api/authorization/policy/hook/index';
5
6
  import type { TApiAuthorizationPolicySubscriberRuleResult } from '../../../../../../type/class/api/authorization/policy/policy-subscriber-rule-result.type';
6
- export interface IApiAuthorizationPolicySubscriber<E extends IApiBaseEntity> {
7
+ export interface IApiAuthorizationPolicySubscriber<E extends IApiBaseEntity> extends IApiSubscriber {
7
8
  getCustomActionRule?<TAction extends string>(action: TAction, context: IApiAuthorizationPolicySubscriberContext<E>): Promise<TApiAuthorizationPolicySubscriberRuleResult<E, TApiAuthorizationPolicyHookResult<TAction, E>>> | TApiAuthorizationPolicySubscriberRuleResult<E, TApiAuthorizationPolicyHookResult<TAction, E>>;
8
9
  onBeforeCreate?(context: IApiAuthorizationPolicySubscriberContext<E>): Promise<TApiAuthorizationPolicySubscriberRuleResult<E, TApiAuthorizationPolicyHookResult<EApiRouteType.CREATE, E>>> | TApiAuthorizationPolicySubscriberRuleResult<E, TApiAuthorizationPolicyHookResult<EApiRouteType.CREATE, E>>;
9
10
  onBeforeDelete?(context: IApiAuthorizationPolicySubscriberContext<E>): Promise<TApiAuthorizationPolicySubscriberRuleResult<E, TApiAuthorizationPolicyHookResult<EApiRouteType.DELETE, E>>> | TApiAuthorizationPolicySubscriberRuleResult<E, TApiAuthorizationPolicyHookResult<EApiRouteType.DELETE, E>>;
@@ -1,5 +1,7 @@
1
1
  import type { IApiBaseEntity } from '../../../../../api-base-entity.interface';
2
+ import type { IApiAuthorizationPolicyCacheOptions } from '../cache-options.interface';
2
3
  export interface IApiAuthorizationPolicySubscriberProperties<E extends IApiBaseEntity> {
4
+ cache?: IApiAuthorizationPolicyCacheOptions;
3
5
  description?: string;
4
6
  entity: new () => E;
5
7
  policyId?: string;