From 197df96ff4e966b0579264a7e399422bc6e145e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Wed, 21 Jun 2023 13:12:21 +0100 Subject: [PATCH] fix: consider ADMIN in API tokens fetch permissions (#4032) https://github.com/Unleash/unleash/pull/4019 introduced a bug where API token filtering was not taking into account ADMIN permissions, which means the API tokens were not being displayed on the UI. --- src/lib/routes/admin-api/api-token.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/routes/admin-api/api-token.ts b/src/lib/routes/admin-api/api-token.ts index b12a651523..02127f253e 100644 --- a/src/lib/routes/admin-api/api-token.ts +++ b/src/lib/routes/admin-api/api-token.ts @@ -353,13 +353,16 @@ export class ApiTokenController extends Controller { const userPermissions = await this.accessService.getPermissionsForUser( user, ); - let allowedTokenTypes = [ + + const allowedTokenTypes = [ READ_ADMIN_API_TOKEN, READ_CLIENT_API_TOKEN, READ_FRONTEND_API_TOKEN, ] .filter((readPerm) => - userPermissions.some((p) => p.permission === readPerm), + userPermissions.some( + (p) => p.permission === readPerm || p.permission === ADMIN, + ), ) .map(permissionToTokenType) .filter((t) => t);