@open-rlb/nestjs-amqp 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -8
- package/common/errors.d.ts +2 -0
- package/common/errors.js +4 -1
- package/common/errors.js.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/index.js.map +1 -1
- package/modules/acl/cache/acl-cache.service.d.ts +2 -2
- package/modules/acl/cache/acl-cache.service.js +6 -6
- package/modules/acl/cache/acl-cache.service.js.map +1 -1
- package/modules/acl/config/acl.config.d.ts +0 -1
- package/modules/acl/const.d.ts +5 -0
- package/modules/acl/const.js +5 -0
- package/modules/acl/const.js.map +1 -1
- package/modules/acl/models.d.ts +9 -0
- package/modules/acl/repository/acl-action.repository.d.ts +10 -0
- package/modules/acl/repository/acl-action.repository.js.map +1 -1
- package/modules/acl/repository/acl-grant.repository.d.ts +4 -0
- package/modules/acl/repository/acl-grant.repository.js.map +1 -1
- package/modules/acl/repository/acl-role.repository.d.ts +10 -0
- package/modules/acl/repository/acl-role.repository.js.map +1 -1
- package/modules/acl/services/acl-management.service.d.ts +4 -1
- package/modules/acl/services/acl-management.service.js +50 -6
- package/modules/acl/services/acl-management.service.js.map +1 -1
- package/modules/acl/services/acl.service.d.ts +12 -3
- package/modules/acl/services/acl.service.js +129 -11
- package/modules/acl/services/acl.service.js.map +1 -1
- package/modules/broker/broker.module.d.ts +4 -1
- package/modules/broker/broker.module.js +17 -1
- package/modules/broker/broker.module.js.map +1 -1
- package/modules/broker/config/decorator-paths.d.ts +1 -0
- package/modules/broker/config/decorator-paths.js +35 -0
- package/modules/broker/config/decorator-paths.js.map +1 -0
- package/modules/broker/config/handler-auth.config.d.ts +2 -2
- package/modules/broker/config/route-discovery.config.d.ts +8 -0
- package/modules/broker/config/route-discovery.config.js +3 -0
- package/modules/broker/config/route-discovery.config.js.map +1 -0
- package/modules/broker/const.d.ts +3 -0
- package/modules/broker/const.js +4 -1
- package/modules/broker/const.js.map +1 -1
- package/modules/broker/decorators/broker-action.decorator.d.ts +15 -2
- package/modules/broker/decorators/broker-action.decorator.js +4 -4
- package/modules/broker/decorators/broker-action.decorator.js.map +1 -1
- package/modules/broker/index.d.ts +3 -0
- package/modules/broker/index.js +3 -0
- package/modules/broker/index.js.map +1 -1
- package/modules/broker/services/metadata-scanner.service.d.ts +1 -0
- package/modules/broker/services/metadata-scanner.service.js +28 -4
- package/modules/broker/services/metadata-scanner.service.js.map +1 -1
- package/modules/broker/services/route-discovery-publisher.service.d.ts +13 -0
- package/modules/broker/services/route-discovery-publisher.service.js +64 -0
- package/modules/broker/services/route-discovery-publisher.service.js.map +1 -0
- package/modules/gateway-admin/const.d.ts +2 -0
- package/modules/gateway-admin/const.js +2 -0
- package/modules/gateway-admin/const.js.map +1 -1
- package/modules/gateway-admin/gateway-admin.module.js +2 -1
- package/modules/gateway-admin/gateway-admin.module.js.map +1 -1
- package/modules/gateway-admin/index.d.ts +4 -0
- package/modules/gateway-admin/index.js +4 -0
- package/modules/gateway-admin/index.js.map +1 -1
- package/modules/gateway-admin/models.d.ts +49 -0
- package/modules/gateway-admin/repository/http-metric.repository.d.ts +4 -1
- package/modules/gateway-admin/repository/http-metric.repository.js.map +1 -1
- package/modules/gateway-admin/repository/http-path.repository.d.ts +5 -0
- package/modules/gateway-admin/repository/http-path.repository.js +6 -0
- package/modules/gateway-admin/repository/http-path.repository.js.map +1 -1
- package/modules/gateway-admin/repository/route-sync-log.repository.d.ts +5 -0
- package/modules/gateway-admin/repository/route-sync-log.repository.js +7 -0
- package/modules/gateway-admin/repository/route-sync-log.repository.js.map +1 -0
- package/modules/gateway-admin/services/gateway-metrics.service.d.ts +3 -1
- package/modules/gateway-admin/services/gateway-metrics.service.js +53 -0
- package/modules/gateway-admin/services/gateway-metrics.service.js.map +1 -1
- package/modules/gateway-admin/services/gateway-path.service.d.ts +1 -0
- package/modules/gateway-admin/services/gateway-path.service.js +16 -1
- package/modules/gateway-admin/services/gateway-path.service.js.map +1 -1
- package/modules/gateway-admin/services/route-sync.service.d.ts +19 -0
- package/modules/gateway-admin/services/route-sync.service.js +137 -0
- package/modules/gateway-admin/services/route-sync.service.js.map +1 -0
- package/modules/gateway-admin/util/route-diff.d.ts +27 -0
- package/modules/gateway-admin/util/route-diff.js +44 -0
- package/modules/gateway-admin/util/route-diff.js.map +1 -0
- package/modules/gateway-admin/util/route-manifest.d.ts +7 -0
- package/modules/gateway-admin/util/route-manifest.js +34 -0
- package/modules/gateway-admin/util/route-manifest.js.map +1 -0
- package/modules/proxy/index.d.ts +1 -0
- package/modules/proxy/index.js +1 -0
- package/modules/proxy/index.js.map +1 -1
- package/modules/proxy/services/acl.service.d.ts +2 -1
- package/modules/proxy/services/http-auth-handler.service.d.ts +1 -1
- package/modules/proxy/services/http-auth-handler.service.js +29 -34
- package/modules/proxy/services/http-auth-handler.service.js.map +1 -1
- package/modules/proxy/services/http-handler.service.d.ts +3 -1
- package/modules/proxy/services/http-handler.service.js +49 -18
- package/modules/proxy/services/http-handler.service.js.map +1 -1
- package/modules/proxy/services/metrics-hook.d.ts +15 -0
- package/modules/proxy/services/metrics-hook.js +5 -0
- package/modules/proxy/services/metrics-hook.js.map +1 -0
- package/modules/proxy/services/websocket.service.js +4 -1
- package/modules/proxy/services/websocket.service.js.map +1 -1
- package/package.json +1 -1
- package/schematics/nest-add/files/skills/rlb-amqp/references/config-schema.md +4 -3
- package/schematics/nest-add/files/skills/rlb-amqp/references/gotchas.md +14 -5
- package/schematics/nest-add/files/skills/rlb-amqp-add-route/SKILL.md +5 -2
- package/modules/remote-config/index.d.ts +0 -2
- package/modules/remote-config/index.js +0 -19
- package/modules/remote-config/index.js.map +0 -1
- package/modules/remote-config/remote-config.module.d.ts +0 -2
- package/modules/remote-config/remote-config.module.js +0 -22
- package/modules/remote-config/remote-config.module.js.map +0 -1
- package/modules/remote-config/remote-config.service.d.ts +0 -12
- package/modules/remote-config/remote-config.service.js +0 -68
- package/modules/remote-config/remote-config.service.js.map +0 -1
package/README.md
CHANGED
|
@@ -268,8 +268,6 @@ auth-providers:
|
|
|
268
268
|
headerPrefix: X-GTW-AUTH- # prefisso degli header propagati ai microservizi
|
|
269
269
|
uidClaim: USERID # dest (uppercase) usato come user id per l'ACL
|
|
270
270
|
usernameClaim: USERNAME
|
|
271
|
-
aclTopic: acl # topic RPC interrogato per i ruoli
|
|
272
|
-
aclAction: can-user-do
|
|
273
271
|
|
|
274
272
|
- name: gateway-jwt
|
|
275
273
|
type: jwt
|
|
@@ -281,8 +279,6 @@ auth-providers:
|
|
|
281
279
|
headerPrefix: X-GTW-AUTH-
|
|
282
280
|
uidClaim: USERID
|
|
283
281
|
usernameClaim: USERNAME
|
|
284
|
-
aclTopic: acl
|
|
285
|
-
aclAction: can-user-do
|
|
286
282
|
|
|
287
283
|
- name: gateway-basic
|
|
288
284
|
type: basic
|
|
@@ -298,7 +294,7 @@ auth-providers:
|
|
|
298
294
|
|
|
299
295
|
Mapping dei claim: un token con `{ sub: "u_1", roles: [...] }` e `jwtMap: [sub:userId]`, `headerPrefix: X-GTW-AUTH-` produce l'header `X-GTW-AUTH-USERID = u_1` propagato al microservizio. Leggilo con `@BrokerParam('header', 'X-GTW-AUTH-USERID')`.
|
|
300
296
|
|
|
301
|
-
> **Sicurezza dei provider**: `algorithms` è **obbligatorio** per `jwt`/`jwks` (se omesso la verifica è negata → previene l'algorithm-confusion); per `jwks` solo algoritmi asimmetrici (RS\*/ES\*/PS\*), `HS*`/`none` rifiutati. `str-compare` senza `secret` e `basic` senza `clientSecret` fanno **pass-through** (richiesta considerata autenticata — provider di fatto aperto/disabilitato; usalo consapevolmente). Senza `jwtMap`
|
|
297
|
+
> **Sicurezza dei provider**: `algorithms` è **obbligatorio** per `jwt`/`jwks` (se omesso la verifica è negata → previene l'algorithm-confusion); per `jwks` solo algoritmi asimmetrici (RS\*/ES\*/PS\*), `HS*`/`none` rifiutati. `str-compare` senza `secret` e `basic` senza `clientSecret` fanno **pass-through** (richiesta considerata autenticata — provider di fatto aperto/disabilitato; usalo consapevolmente). Senza `jwtMap` **nessun claim viene inoltrato** (il token resta accettato, `success:true`): il gateway fa fail-safe invece di propagare l'intero payload. Definiscilo sempre per inoltrare gli header identità (es. `X-GTW-AUTH-USERID`).
|
|
302
298
|
|
|
303
299
|
### `gateway`
|
|
304
300
|
|
|
@@ -574,8 +570,10 @@ import { AclModule, AclService, AclActionRepository, AclRoleRepository, AclGrant
|
|
|
574
570
|
export class AppModule {}
|
|
575
571
|
```
|
|
576
572
|
|
|
577
|
-
- I handler sono esposti su `BrokerService` con topic **`rlb-acl`** (costante `ACL_TOPIC`): `acl-can-user-do` (rpc), `acl-grant`/`acl-revoke`, `acl-action-*`, `acl-role-*`. Definisci nel tuo `broker.topics` un topic `rlb-acl
|
|
578
|
-
-
|
|
573
|
+
- I handler sono esposti su `BrokerService` con topic **`rlb-acl`** (costante `ACL_TOPIC`): `acl-can-user-do` / `acl-can-user-do-gtw` (rpc), `acl-grant`/`acl-revoke`, `acl-action-*`, `acl-role-*`. Definisci nel tuo `broker.topics` un topic `rlb-acl`. (Il check ruoli del gateway è in-process via `IAclRoleService`, quindi gli auth-provider non richiedono più `aclTopic`/`aclAction`.)
|
|
574
|
+
- **Due verifiche role-based** (servite dalla cache 2-tier, miss → DB → ripopola); input solo `userId` + `roles`, **niente topic/action**:
|
|
575
|
+
- `canUserDoGtw(roles, userId)` — **filtro primario del gateway** (role-based, OR): vero se l'utente ha almeno uno dei ruoli, resource-agnostico. È quello usato da `checkRoles` su `path.roles`. RPC `acl-can-user-do-gtw`.
|
|
576
|
+
- `canUserDo(roles, userId, resourceId)` — **lato microservizio**: vero se un grant **globale** (senza `resourceId`) **oppure** legato a quella risorsa dà all'utente il ruolo (`roles` accetta `string | string[]`). La risorsa è nota solo al ms, che chiama l'RPC `acl-can-user-do` con payload `{ userId, resource, roles }`.
|
|
579
577
|
- **Invalidazione**: ogni mutazione (grant/role/action) svuota L1 e L2 → la prossima verifica pesca dal DB. Senza L2, la coerenza multi-istanza è limitata dal `ramTtlMs`.
|
|
580
578
|
- **Cache L2 pluggable**: il consumer fornisce `{ provide: RLB_ACL_CACHE_STORE, useClass/useExisting }` che implementa `AclCacheStore` (`get/set/del/keys`). In `gateway-2` è `InMemoryAclStore` (mock in RAM, nessuna dipendenza esterna); in produzione plugga uno store condiviso (es. Redis).
|
|
581
579
|
|
|
@@ -660,7 +658,7 @@ Questi sono i punti che causano più frequentemente bug silenziosi. **Leggili pr
|
|
|
660
658
|
|
|
661
659
|
### Auth / ACL
|
|
662
660
|
|
|
663
|
-
14. **`roles` su una path
|
|
661
|
+
14. **`roles` su una path richiede un `IAclRoleService`** registrato via `RLB_GTW_ACL_ROLE_SERVICE` in `ProxyModule.forRootAsync({ providers: [...] })`. Il check del gateway è **role-based**: `path.roles` elenca **nomi di ruolo** e l'utente passa se ne possiede **almeno uno** (`canUserDoGtw(path.roles, userId)`, filtro primario resource-agnostico). L'auth-provider deve definire `uidClaim` (per estrarre lo userId) + `headerPrefix`. La verifica fine sulla risorsa va fatta sul microservizio con `canUserDo(roles, userId, resourceId)` (RPC `acl-can-user-do`). Nota: `authOptions`/`gatewayOptions` si passano a `ProxyModule`, non a `BrokerModule`.
|
|
664
662
|
15. **Gli header propagati sono uppercase e prefissati** (`${headerPrefix}${DEST}`): leggi `X-GTW-AUTH-USERID`, non `userId`.
|
|
665
663
|
|
|
666
664
|
### WebSocket
|
package/common/errors.d.ts
CHANGED
|
@@ -9,5 +9,7 @@ export declare class ForbiddenError extends BrokerHttpError {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class NotFoundError extends BrokerHttpError {
|
|
11
11
|
}
|
|
12
|
+
export declare class ConflictError extends BrokerHttpError {
|
|
13
|
+
}
|
|
12
14
|
export declare class InvalidParamsErrror extends BrokerHttpError {
|
|
13
15
|
}
|
package/common/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidParamsErrror = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.BadRequestError = exports.BrokerHttpError = void 0;
|
|
3
|
+
exports.InvalidParamsErrror = exports.ConflictError = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.BadRequestError = exports.BrokerHttpError = void 0;
|
|
4
4
|
class BrokerHttpError extends Error {
|
|
5
5
|
constructor(message) {
|
|
6
6
|
super(message);
|
|
@@ -20,6 +20,9 @@ exports.ForbiddenError = ForbiddenError;
|
|
|
20
20
|
class NotFoundError extends BrokerHttpError {
|
|
21
21
|
}
|
|
22
22
|
exports.NotFoundError = NotFoundError;
|
|
23
|
+
class ConflictError extends BrokerHttpError {
|
|
24
|
+
}
|
|
25
|
+
exports.ConflictError = ConflictError;
|
|
23
26
|
class InvalidParamsErrror extends BrokerHttpError {
|
|
24
27
|
}
|
|
25
28
|
exports.InvalidParamsErrror = InvalidParamsErrror;
|
package/common/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../libs/rlb-nestjs-amqp/src/common/errors.ts"],"names":[],"mappings":";;;AAKA,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AALD,0CAKC;AAED,MAAa,eAAgB,SAAQ,eAAe;CAAI;AAAxD,0CAAwD;AACxD,MAAa,iBAAkB,SAAQ,eAAe;CAAI;AAA1D,8CAA0D;AAC1D,MAAa,cAAe,SAAQ,eAAe;CAAI;AAAvD,wCAAuD;AACvD,MAAa,aAAc,SAAQ,eAAe;CAAI;AAAtD,sCAAsD;AAEtD,MAAa,mBAAoB,SAAQ,eAAe;CAAI;AAA5D,kDAA4D"}
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../libs/rlb-nestjs-amqp/src/common/errors.ts"],"names":[],"mappings":";;;AAKA,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AALD,0CAKC;AAED,MAAa,eAAgB,SAAQ,eAAe;CAAI;AAAxD,0CAAwD;AACxD,MAAa,iBAAkB,SAAQ,eAAe;CAAI;AAA1D,8CAA0D;AAC1D,MAAa,cAAe,SAAQ,eAAe;CAAI;AAAvD,wCAAuD;AACvD,MAAa,aAAc,SAAQ,eAAe;CAAI;AAAtD,sCAAsD;AACtD,MAAa,aAAc,SAAQ,eAAe;CAAI;AAAtD,sCAAsD;AAEtD,MAAa,mBAAoB,SAAQ,eAAe;CAAI;AAA5D,kDAA4D"}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -20,5 +20,4 @@ __exportStar(require("./modules/broker/index"), exports);
|
|
|
20
20
|
__exportStar(require("./modules/broker/services/utils.service"), exports);
|
|
21
21
|
__exportStar(require("./modules/gateway-admin"), exports);
|
|
22
22
|
__exportStar(require("./modules/proxy/index"), exports);
|
|
23
|
-
__exportStar(require("./modules/remote-config/index"), exports);
|
|
24
23
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../libs/rlb-nestjs-amqp/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,gDAA8B;AAC9B,yDAAuC;AACvC,0EAAwD;AACxD,0DAAwC;AACxC,wDAAsC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../libs/rlb-nestjs-amqp/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,gDAA8B;AAC9B,yDAAuC;AACvC,0EAAwD;AACxD,0DAAwC;AACxC,wDAAsC"}
|
|
@@ -8,8 +8,8 @@ export declare class AclCacheService {
|
|
|
8
8
|
private readonly l2TtlSec;
|
|
9
9
|
constructor(options: AclModuleOptions, store?: AclCacheStore);
|
|
10
10
|
private key;
|
|
11
|
-
get(userId: string,
|
|
12
|
-
set(userId: string,
|
|
11
|
+
get(userId: string, action: string): Promise<boolean | null>;
|
|
12
|
+
set(userId: string, action: string, value: boolean): Promise<void>;
|
|
13
13
|
invalidate(userId?: string): Promise<void>;
|
|
14
14
|
invalidateLocalRam(userId?: string): void;
|
|
15
15
|
}
|
|
@@ -24,11 +24,11 @@ let AclCacheService = AclCacheService_1 = class AclCacheService {
|
|
|
24
24
|
this.ramTtlMs = options.cache?.ramTtlMs ?? 30_000;
|
|
25
25
|
this.l2TtlSec = options.cache?.l2TtlSec ?? 600;
|
|
26
26
|
}
|
|
27
|
-
key(userId,
|
|
28
|
-
return `acl/${userId}/${
|
|
27
|
+
key(userId, action) {
|
|
28
|
+
return `acl/${userId}/${action}`;
|
|
29
29
|
}
|
|
30
|
-
async get(userId,
|
|
31
|
-
const key = this.key(userId,
|
|
30
|
+
async get(userId, action) {
|
|
31
|
+
const key = this.key(userId, action);
|
|
32
32
|
const local = this.ram.get(key);
|
|
33
33
|
if (local && local.exp > Date.now())
|
|
34
34
|
return local.v;
|
|
@@ -49,8 +49,8 @@ let AclCacheService = AclCacheService_1 = class AclCacheService {
|
|
|
49
49
|
}
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
|
-
async set(userId,
|
|
53
|
-
const key = this.key(userId,
|
|
52
|
+
async set(userId, action, value) {
|
|
53
|
+
const key = this.key(userId, action);
|
|
54
54
|
this.ram.set(key, { v: value, exp: Date.now() + this.ramTtlMs });
|
|
55
55
|
if (this.store) {
|
|
56
56
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acl-cache.service.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/cache/acl-cache.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAsE;AAEtE,oCAAgE;AAMzD,IAAM,eAAe,uBAArB,MAAM,eAAe;IAM1B,YAC2B,OAAyB,EACT,KAAsC;QAArB,UAAK,GAAL,KAAK,CAAgB;QAPhE,WAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;QAC1C,QAAG,GAAG,IAAI,GAAG,EAAoB,CAAC;QAQjD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,EAAE,QAAQ,IAAI,MAAM,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,EAAE,QAAQ,IAAI,GAAG,CAAC;IACjD,CAAC;IAEO,GAAG,CAAC,MAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"acl-cache.service.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/cache/acl-cache.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAsE;AAEtE,oCAAgE;AAMzD,IAAM,eAAe,uBAArB,MAAM,eAAe;IAM1B,YAC2B,OAAyB,EACT,KAAsC;QAArB,UAAK,GAAL,KAAK,CAAgB;QAPhE,WAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;QAC1C,QAAG,GAAG,IAAI,GAAG,EAAoB,CAAC;QAQjD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,EAAE,QAAQ,IAAI,MAAM,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,EAAE,QAAQ,IAAI,GAAG,CAAC;IACjD,CAAC;IAEO,GAAG,CAAC,MAAc,EAAE,MAAc;QACxC,OAAO,OAAO,MAAM,IAAI,MAAM,EAAE,CAAC;IACnC,CAAC;IAGD,KAAK,CAAC,GAAG,CAAC,MAAc,EAAE,MA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,CAAC;QAChC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;YAClC,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC;gBAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;CACF,CAAA;AA3EY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAQR,WAAA,IAAA,eAAM,EAAC,uBAAe,CAAC,CAAA;IACvB,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,2BAAmB,CAAC,CAAA;;GAR/B,eAAe,CA2E3B"}
|
package/modules/acl/const.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ export declare const RLB_ACL_OPTIONS = "RLB_ACL_OPTIONS";
|
|
|
3
3
|
export declare const RLB_ACL_CACHE_STORE = "RLB_ACL_CACHE_STORE";
|
|
4
4
|
export declare const ACL_ACTIONS: {
|
|
5
5
|
readonly canUserDo: "acl-can-user-do";
|
|
6
|
+
readonly canUserDoGtw: "acl-can-user-do-gtw";
|
|
7
|
+
readonly listResourcesByUser: "acl-list-resources-by-user";
|
|
8
|
+
readonly listByUser: "acl-list-by-user";
|
|
9
|
+
readonly verifyAccess: "acl-verify-access";
|
|
6
10
|
readonly grant: "acl-grant";
|
|
7
11
|
readonly revoke: "acl-revoke";
|
|
8
12
|
readonly invalidate: "acl-invalidate";
|
|
@@ -14,4 +18,5 @@ export declare const ACL_ACTIONS: {
|
|
|
14
18
|
readonly roleUpdate: "acl-role-update";
|
|
15
19
|
readonly roleDelete: "acl-role-delete";
|
|
16
20
|
readonly roleList: "acl-role-list";
|
|
21
|
+
readonly roleGet: "acl-role-get";
|
|
17
22
|
};
|
package/modules/acl/const.js
CHANGED
|
@@ -6,6 +6,10 @@ exports.RLB_ACL_OPTIONS = 'RLB_ACL_OPTIONS';
|
|
|
6
6
|
exports.RLB_ACL_CACHE_STORE = 'RLB_ACL_CACHE_STORE';
|
|
7
7
|
exports.ACL_ACTIONS = {
|
|
8
8
|
canUserDo: 'acl-can-user-do',
|
|
9
|
+
canUserDoGtw: 'acl-can-user-do-gtw',
|
|
10
|
+
listResourcesByUser: 'acl-list-resources-by-user',
|
|
11
|
+
listByUser: 'acl-list-by-user',
|
|
12
|
+
verifyAccess: 'acl-verify-access',
|
|
9
13
|
grant: 'acl-grant',
|
|
10
14
|
revoke: 'acl-revoke',
|
|
11
15
|
invalidate: 'acl-invalidate',
|
|
@@ -17,5 +21,6 @@ exports.ACL_ACTIONS = {
|
|
|
17
21
|
roleUpdate: 'acl-role-update',
|
|
18
22
|
roleDelete: 'acl-role-delete',
|
|
19
23
|
roleList: 'acl-role-list',
|
|
24
|
+
roleGet: 'acl-role-get',
|
|
20
25
|
};
|
|
21
26
|
//# sourceMappingURL=const.js.map
|
package/modules/acl/const.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/acl/const.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/acl/const.ts"],"names":[],"mappings":";;;AAGa,QAAA,SAAS,GAAG,SAAS,CAAC;AAEtB,QAAA,eAAe,GAAG,iBAAiB,CAAC;AAEpC,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAG5C,QAAA,WAAW,GAAG;IAEzB,SAAS,EAAE,iBAAiB;IAE5B,YAAY,EAAE,qBAAqB;IAEnC,mBAAmB,EAAE,4BAA4B;IAEjD,UAAU,EAAE,kBAAkB;IAE9B,YAAY,EAAE,mBAAmB;IACjC,KAAK,EAAE,WAAW;IAClB,MAAM,EAAE,YAAY;IACpB,UAAU,EAAE,gBAAgB;IAC5B,YAAY,EAAE,mBAAmB;IACjC,YAAY,EAAE,mBAAmB;IACjC,YAAY,EAAE,mBAAmB;IACjC,UAAU,EAAE,iBAAiB;IAC7B,UAAU,EAAE,iBAAiB;IAC7B,UAAU,EAAE,iBAAiB;IAC7B,UAAU,EAAE,iBAAiB;IAC7B,QAAQ,EAAE,eAAe;IACzB,OAAO,EAAE,cAAc;CACf,CAAC"}
|
package/modules/acl/models.d.ts
CHANGED
|
@@ -17,3 +17,12 @@ export interface AclGrant<Id = string> {
|
|
|
17
17
|
resourceId?: string;
|
|
18
18
|
roles: string[];
|
|
19
19
|
}
|
|
20
|
+
export interface AclResource {
|
|
21
|
+
resourceId?: string;
|
|
22
|
+
actions: string[];
|
|
23
|
+
friendlyName?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface AclResourceGroup {
|
|
26
|
+
resourceBusinessId?: string;
|
|
27
|
+
resources: AclResource[];
|
|
28
|
+
}
|
|
@@ -2,10 +2,20 @@ import { PaginationModel } from '../../../common';
|
|
|
2
2
|
import { AclAction } from '../models';
|
|
3
3
|
export declare abstract class AclActionRepository {
|
|
4
4
|
abstract insert(model: AclAction): Promise<AclAction>;
|
|
5
|
+
abstract insertMany(models: AclAction[]): Promise<AclAction[]>;
|
|
5
6
|
abstract findById(id: string): Promise<AclAction>;
|
|
6
7
|
abstract findOne(filter: Record<string, any>): Promise<AclAction>;
|
|
8
|
+
abstract upsertById(id: string, model: Partial<AclAction>): Promise<AclAction>;
|
|
9
|
+
abstract upsertOne(filter: Record<string, any>, model: Partial<AclAction>): Promise<AclAction>;
|
|
7
10
|
abstract updateById(id: string, model: Partial<AclAction>): Promise<AclAction>;
|
|
11
|
+
abstract updateOne(filter: Record<string, any>, model: Partial<AclAction>): Promise<AclAction>;
|
|
12
|
+
abstract mergeById(id: string, model: Partial<AclAction>): Promise<AclAction>;
|
|
13
|
+
abstract mergeOne(filter: Record<string, any>, model: Partial<AclAction>): Promise<AclAction>;
|
|
8
14
|
abstract removeById(id: string): Promise<AclAction>;
|
|
15
|
+
abstract removeOne(filter: Record<string, any>): Promise<AclAction>;
|
|
16
|
+
abstract removeMany(filter: Record<string, any>): Promise<number>;
|
|
9
17
|
abstract filter(filter: Record<string, any>): Promise<AclAction[]>;
|
|
10
18
|
abstract filterPaginated(filter: Record<string, any>, page?: number, limit?: number): Promise<PaginationModel<AclAction>>;
|
|
19
|
+
abstract retrieveAll(): Promise<AclAction[]>;
|
|
20
|
+
abstract retrieveAllPaginated(page: number, limit: number): Promise<PaginationModel<AclAction>>;
|
|
11
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acl-action.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/repository/acl-action.repository.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"acl-action.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/repository/acl-action.repository.ts"],"names":[],"mappings":";;;AAQA,MAAsB,mBAAmB;CAoBxC;AApBD,kDAoBC"}
|
|
@@ -2,8 +2,12 @@ import { PaginationModel } from '../../../common';
|
|
|
2
2
|
import { AclGrant } from '../models';
|
|
3
3
|
export declare abstract class AclGrantRepository {
|
|
4
4
|
abstract insert(model: AclGrant): Promise<AclGrant>;
|
|
5
|
+
abstract findById(id: string): Promise<AclGrant>;
|
|
5
6
|
abstract findOne(filter: Record<string, any>): Promise<AclGrant>;
|
|
7
|
+
abstract updateById(id: string, model: Partial<AclGrant>): Promise<AclGrant>;
|
|
6
8
|
abstract updateOne(filter: Record<string, any>, model: Partial<AclGrant>): Promise<AclGrant>;
|
|
9
|
+
abstract mergeById(id: string, model: Partial<AclGrant>): Promise<AclGrant>;
|
|
10
|
+
abstract removeById(id: string): Promise<AclGrant>;
|
|
7
11
|
abstract removeOne(filter: Record<string, any>): Promise<AclGrant>;
|
|
8
12
|
abstract filter(filter: Record<string, any>): Promise<AclGrant[]>;
|
|
9
13
|
abstract filterPaginated(filter: Record<string, any>, page?: number, limit?: number): Promise<PaginationModel<AclGrant>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acl-grant.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/repository/acl-grant.repository.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"acl-grant.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/repository/acl-grant.repository.ts"],"names":[],"mappings":";;;AAOA,MAAsB,kBAAkB;CAiBvC;AAjBD,gDAiBC"}
|
|
@@ -2,9 +2,19 @@ import { PaginationModel } from '../../../common';
|
|
|
2
2
|
import { AclRole } from '../models';
|
|
3
3
|
export declare abstract class AclRoleRepository {
|
|
4
4
|
abstract insert(model: AclRole): Promise<AclRole>;
|
|
5
|
+
abstract insertMany(models: AclRole[]): Promise<AclRole[]>;
|
|
6
|
+
abstract findById(id: string): Promise<AclRole>;
|
|
5
7
|
abstract findOne(filter: Record<string, any>): Promise<AclRole>;
|
|
8
|
+
abstract upsertById(id: string, model: Partial<AclRole>): Promise<AclRole>;
|
|
9
|
+
abstract upsertOne(filter: Record<string, any>, model: Partial<AclRole>): Promise<AclRole>;
|
|
10
|
+
abstract updateById(id: string, model: Partial<AclRole>): Promise<AclRole>;
|
|
6
11
|
abstract updateOne(filter: Record<string, any>, model: Partial<AclRole>): Promise<AclRole>;
|
|
12
|
+
abstract mergeById(id: string, model: Partial<AclRole>): Promise<AclRole>;
|
|
13
|
+
abstract removeById(id: string): Promise<AclRole>;
|
|
7
14
|
abstract removeOne(filter: Record<string, any>): Promise<AclRole>;
|
|
8
15
|
abstract filter(filter: Record<string, any>): Promise<AclRole[]>;
|
|
9
16
|
abstract filterPaginated(filter: Record<string, any>, page?: number, limit?: number): Promise<PaginationModel<AclRole>>;
|
|
17
|
+
abstract list(): Promise<AclRole[]>;
|
|
18
|
+
abstract listPaginated(page: number, limit: number): Promise<PaginationModel<AclRole>>;
|
|
19
|
+
abstract getActionsByNames(names: string[]): Promise<string[]>;
|
|
10
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acl-role.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/repository/acl-role.repository.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"acl-role.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/repository/acl-role.repository.ts"],"names":[],"mappings":";;;AAQA,MAAsB,iBAAiB;CAmBtC;AAnBD,8CAmBC"}
|
|
@@ -12,7 +12,8 @@ export declare class AclManagementService {
|
|
|
12
12
|
private readonly logger;
|
|
13
13
|
constructor(actions: AclActionRepository, roles: AclRoleRepository, grants: AclGrantRepository, cache: AclCacheService);
|
|
14
14
|
grant(userId: string, roles: string[], resourceId?: string, resourceBusinessId?: string, friendlyName?: string): Promise<AclGrant>;
|
|
15
|
-
revoke(userId: string, resourceId?: string): Promise<AclGrant>;
|
|
15
|
+
revoke(userId: string, resourceId?: string, roles?: string[]): Promise<AclGrant | null>;
|
|
16
|
+
private findGrant;
|
|
16
17
|
createAction(name: string, description?: string): Promise<AclAction>;
|
|
17
18
|
updateAction(id: string, model: Partial<AclAction>): Promise<AclAction>;
|
|
18
19
|
deleteAction(id: string): Promise<AclAction>;
|
|
@@ -21,6 +22,8 @@ export declare class AclManagementService {
|
|
|
21
22
|
updateRole(name: string, model: Partial<AclRole>): Promise<AclRole>;
|
|
22
23
|
deleteRole(name: string): Promise<AclRole>;
|
|
23
24
|
listRoles(page?: number, limit?: number): Promise<PaginationModel<AclRole>>;
|
|
25
|
+
getRole(name: string): Promise<AclRole>;
|
|
26
|
+
getActionsByNames(names: string[]): Promise<string[]>;
|
|
24
27
|
private assertActionsExist;
|
|
25
28
|
private assertRolesExist;
|
|
26
29
|
}
|
|
@@ -36,16 +36,44 @@ let AclManagementService = AclManagementService_1 = class AclManagementService {
|
|
|
36
36
|
if (!roles?.length)
|
|
37
37
|
throw new common_2.BadRequestError('roles are required');
|
|
38
38
|
await this.assertRolesExist(roles);
|
|
39
|
-
const
|
|
39
|
+
const existing = await this.findGrant(userId, resourceId);
|
|
40
|
+
let result;
|
|
41
|
+
if (existing) {
|
|
42
|
+
const merged = Array.from(new Set([...(existing.roles || []), ...roles]));
|
|
43
|
+
result = await this.grants.updateById(existing._id, {
|
|
44
|
+
roles: merged,
|
|
45
|
+
resourceBusinessId: resourceBusinessId ?? existing.resourceBusinessId,
|
|
46
|
+
friendlyName: friendlyName ?? existing.friendlyName,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
result = await this.grants.insert({ userId, roles: Array.from(new Set(roles)), resourceId, resourceBusinessId, friendlyName });
|
|
51
|
+
}
|
|
40
52
|
await this.cache.invalidate(userId);
|
|
41
|
-
return
|
|
53
|
+
return result;
|
|
42
54
|
}
|
|
43
|
-
async revoke(userId, resourceId) {
|
|
55
|
+
async revoke(userId, resourceId, roles) {
|
|
44
56
|
if (!userId)
|
|
45
57
|
throw new common_2.BadRequestError('userId is required');
|
|
46
|
-
const
|
|
58
|
+
const existing = await this.findGrant(userId, resourceId);
|
|
59
|
+
if (!existing)
|
|
60
|
+
return null;
|
|
61
|
+
let result;
|
|
62
|
+
if (roles?.length) {
|
|
63
|
+
const remaining = (existing.roles || []).filter((r) => !roles.includes(r));
|
|
64
|
+
result = remaining.length
|
|
65
|
+
? await this.grants.updateById(existing._id, { roles: remaining })
|
|
66
|
+
: await this.grants.removeById(existing._id);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
result = await this.grants.removeById(existing._id);
|
|
70
|
+
}
|
|
47
71
|
await this.cache.invalidate(userId);
|
|
48
|
-
return
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
async findGrant(userId, resourceId) {
|
|
75
|
+
const all = await this.grants.filter({ userId });
|
|
76
|
+
return (all || []).find((g) => (g.resourceId ?? null) === (resourceId ?? null));
|
|
49
77
|
}
|
|
50
78
|
async createAction(name, description) {
|
|
51
79
|
if (!name)
|
|
@@ -96,6 +124,14 @@ let AclManagementService = AclManagementService_1 = class AclManagementService {
|
|
|
96
124
|
async listRoles(page, limit) {
|
|
97
125
|
return this.roles.filterPaginated({}, Number(page) || 1, Number(limit) || 10);
|
|
98
126
|
}
|
|
127
|
+
async getRole(name) {
|
|
128
|
+
if (!name)
|
|
129
|
+
throw new common_2.BadRequestError('name is required');
|
|
130
|
+
return this.roles.findOne({ name });
|
|
131
|
+
}
|
|
132
|
+
async getActionsByNames(names) {
|
|
133
|
+
return this.roles.getActionsByNames(names);
|
|
134
|
+
}
|
|
99
135
|
async assertActionsExist(names) {
|
|
100
136
|
const found = await this.actions.filter({ name: { $in: names } });
|
|
101
137
|
const missing = names.filter((n) => !found.some((a) => a.name === n));
|
|
@@ -125,8 +161,9 @@ __decorate([
|
|
|
125
161
|
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.revoke, 'rpc'),
|
|
126
162
|
__param(0, (0, broker_1.BrokerParam)('body', 'userId')),
|
|
127
163
|
__param(1, (0, broker_1.BrokerParam)('body', 'resourceId')),
|
|
164
|
+
__param(2, (0, broker_1.BrokerParam)('body', 'roles')),
|
|
128
165
|
__metadata("design:type", Function),
|
|
129
|
-
__metadata("design:paramtypes", [String, String]),
|
|
166
|
+
__metadata("design:paramtypes", [String, String, Array]),
|
|
130
167
|
__metadata("design:returntype", Promise)
|
|
131
168
|
], AclManagementService.prototype, "revoke", null);
|
|
132
169
|
__decorate([
|
|
@@ -192,6 +229,13 @@ __decorate([
|
|
|
192
229
|
__metadata("design:paramtypes", [Number, Number]),
|
|
193
230
|
__metadata("design:returntype", Promise)
|
|
194
231
|
], AclManagementService.prototype, "listRoles", null);
|
|
232
|
+
__decorate([
|
|
233
|
+
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.roleGet, 'rpc'),
|
|
234
|
+
__param(0, (0, broker_1.BrokerParam)('body', 'name')),
|
|
235
|
+
__metadata("design:type", Function),
|
|
236
|
+
__metadata("design:paramtypes", [String]),
|
|
237
|
+
__metadata("design:returntype", Promise)
|
|
238
|
+
], AclManagementService.prototype, "getRole", null);
|
|
195
239
|
exports.AclManagementService = AclManagementService = AclManagementService_1 = __decorate([
|
|
196
240
|
(0, common_1.Injectable)(),
|
|
197
241
|
__metadata("design:paramtypes", [acl_action_repository_1.AclActionRepository,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acl-management.service.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/services/acl-management.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,4CAAmE;AACnE,yCAAyD;AACzD,kEAA6D;AAC7D,oCAAkD;AAElD,+EAA0E;AAC1E,6EAAwE;AACxE,2EAAsE;AAG/D,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAG/B,YACmB,OAA4B,EAC5B,KAAwB,EACxB,MAA0B,EAC1B,KAAsB;QAHtB,YAAO,GAAP,OAAO,CAAqB;QAC5B,UAAK,GAAL,KAAK,CAAmB;QACxB,WAAM,GAAN,MAAM,CAAoB;QAC1B,UAAK,GAAL,KAAK,CAAiB;QANxB,WAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,CAAC;IAO5D,CAAC;
|
|
1
|
+
{"version":3,"file":"acl-management.service.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/services/acl-management.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,4CAAmE;AACnE,yCAAyD;AACzD,kEAA6D;AAC7D,oCAAkD;AAElD,+EAA0E;AAC1E,6EAAwE;AACxE,2EAAsE;AAG/D,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAG/B,YACmB,OAA4B,EAC5B,KAAwB,EACxB,MAA0B,EAC1B,KAAsB;QAHtB,YAAO,GAAP,OAAO,CAAqB;QAC5B,UAAK,GAAL,KAAK,CA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I5C;AAGK;IADL,IAAA,qBAAY,EAAC,iBAAS,EAAE,mBAAW,CAAC,QAAQ,EAAE,KAAK,CAAC;IAElD,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3B,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,OAAO,CAAC,CAAA;;;;qDAG9B;AAGK;IADL,IAAA,qBAAY,EAAC,iBAAS,EAAE,mBAAW,CAAC,OAAO,EAAE,KAAK,CAAC;IACrC,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;;;;mDAGzC;+BAvJU,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAKiB,2CAAmB;QACrB,uCAAiB;QAChB,yCAAkB;QACnB,mCAAe;GAP9B,oBAAoB,CAwKhC"}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { IAclRoleService } from '../../proxy/services/acl.service';
|
|
2
2
|
import { AclCacheService } from '../cache/acl-cache.service';
|
|
3
|
+
import { AclGrant, AclResourceGroup } from '../models';
|
|
3
4
|
import { AclGrantRepository } from '../repository/acl-grant.repository';
|
|
5
|
+
import { AclRoleRepository } from '../repository/acl-role.repository';
|
|
4
6
|
export declare class AclService implements IAclRoleService {
|
|
5
7
|
private readonly grants;
|
|
8
|
+
private readonly roles;
|
|
6
9
|
private readonly cache;
|
|
7
10
|
private readonly logger;
|
|
8
|
-
constructor(grants: AclGrantRepository, cache: AclCacheService);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
constructor(grants: AclGrantRepository, roles: AclRoleRepository, cache: AclCacheService);
|
|
12
|
+
private toList;
|
|
13
|
+
canUserDoGtw(roles: string | string[], userId: string): Promise<boolean>;
|
|
14
|
+
canUserDo(roles: string | string[], userId: string, resourceId?: string): Promise<boolean>;
|
|
15
|
+
handleCanUserDoGtw(userId: string, roles?: string | string[]): Promise<boolean>;
|
|
16
|
+
handleCanUserDo(userId: string, resource: string, roles?: string | string[]): Promise<boolean>;
|
|
17
|
+
listResourcesByUser(userId: string): Promise<AclResourceGroup[]>;
|
|
18
|
+
listByUser(userId: string): Promise<AclGrant[]>;
|
|
19
|
+
verifyAccess(userId: string, resourceId: string, action: string, resourceBusinessId?: string, productId?: string): Promise<boolean>;
|
|
11
20
|
}
|