Migrate tag module to ABAC
MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -318,6 +318,8 @@ export default class AuthorizationService {
!tags.canExport && delete tags.canExport; // Optimize data over the net
tags.canUnassign = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.TAGS, Action.UNASSIGN, authorizationFilter);
!tags.canUnassign && delete tags.canUnassign; // Optimize data over the net
+ tags.canListUsers = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.USERS, Action.LIST, authorizationFilter);
+ !tags.canListUsers && delete tags.canListUsers; // Optimize data over the net
tags.metadata = authorizationFilter.metadata;
for (const tag of tags.result) {
await AuthorizationService.addTagAuthorizations(tenant, userToken, tag, authorizationFilter);
@@ -344,6 +346,9 @@ export default class AuthorizationService {
tag.canAssign = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.TAG, Action.ASSIGN, authorizationFilter, { TagID: tag.id }, tag);
!tag.canAssign && delete tag.canAssign; // Optimize data over the net
+ tag.canListUsers = await AuthorizationService.canPerformAuthorizationAction(
+ tenant, userToken, Entity.USERS, Action.LIST, authorizationFilter);
+ !tag.canListUsers && delete tag.canListUsers; // Optimize data over the net
}
}

MODIFY
src/types/Authorization.ts
src/types/Authorization.ts
@@ -201,6 +201,7 @@ export interface AuthorizationActions {
canCreate?: boolean;
canUpdate?: boolean;
canDelete?: boolean;
+ canListUsers?: boolean;
projectFields?: string[];
metadata?: Record<string, unknown>;
}

MODIFY
src/types/DataResult.ts
src/types/DataResult.ts
@@ -59,6 +59,7 @@ export interface TagDataResult extends DataResult<Tag> {
canExport: boolean;
canUnassign: boolean;
canAssign: boolean;
+ canListUsers: boolean;
}
export interface TransactionDataResult extends DataResult<Transaction> {

Migrate tag module to ABAC