Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: add tag filtering support to dashboard API and frontend components
Victor Hugo dos Santosbaa127c7c80d
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 7d14027137..9e245728e3 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -1375,6 +1375,7 @@ export const DASHBOARD = {orderBy: "The column to order secrets/folders by.",orderDirection: "The direction to order secrets/folders in.",search: "The text string to filter secret keys and folder names by.",+ tags: "The tags to filter secrets by (comma separated, ie 'tags=billing,engineering').",includeSecrets: "Whether to include project secrets in the response.",includeFolders: "Whether to include project folders in the response.",includeDynamicSecrets: "Whether to include dynamic project secrets in the response.",diff --git a/backend/src/server/routes/v1/dashboard-router.ts b/backend/src/server/routes/v1/dashboard-router.tsindex 2ddc5a6714..438a518ee9 100644--- a/backend/src/server/routes/v1/dashboard-router.ts+++ b/backend/src/server/routes/v1/dashboard-router.ts@@ -101,6 +101,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {.describe(DASHBOARD.SECRET_OVERVIEW_LIST.orderDirection).optional(),search: z.string().trim().describe(DASHBOARD.SECRET_OVERVIEW_LIST.search).optional(),+ tags: z.string().trim().transform(decodeURIComponent).describe(DASHBOARD.SECRET_OVERVIEW_LIST.tags).optional(),includeSecrets: booleanSchema.describe(DASHBOARD.SECRET_OVERVIEW_LIST.includeSecrets),includeFolders: booleanSchema.describe(DASHBOARD.SECRET_OVERVIEW_LIST.includeFolders),includeImports: booleanSchema.describe(DASHBOARD.SECRET_OVERVIEW_LIST.includeImports),@@ -217,6 +218,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {} = req.query;const environments = req.query.environments.split(",");+ const tagSlugs = req.query.tags?.split(",").filter(Boolean) ?? [];if (!projectId || environments.length === 0)throw new BadRequestError({ message: "Missing project id or environment(s)" });@@ -466,6 +468,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {projectId,path: secretPath,search,+ tagSlugs,isInternal: true});@@ -484,6 +487,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {orderBy,orderDirection,search,+ tagSlugs,limit: remainingLimit,offset: adjustedOffset,isInternal: truediff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.tsindex e599eb98ab..8741e6b3b7 100644--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts@@ -938,7 +938,10 @@ export const secretV2BridgeServiceFactory = ({environments,isInternal,...params- }: Pick<TGetSecretsDTO, "actorId" | "actor" | "path" | "projectId" | "actorOrgId" | "actorAuthMethod" | "search"> & {+ }: Pick<+ TGetSecretsDTO,+ "actorId" | "actor" | "path" | "projectId" | "actorOrgId" | "actorAuthMethod" | "search" | "tagSlugs"+ > & {environments: string[];isInternal?: boolean;}) => {@@ -1093,7 +1096,10 @@ export const secretV2BridgeServiceFactory = ({actorAuthMethod,isInternal,...params- }: Pick<TGetSecretsDTO, "actorId" | "actor" | "path" | "projectId" | "actorOrgId" | "actorAuthMethod" | "search"> & {+ }: Pick<+ TGetSecretsDTO,+ "actorId" | "actor" | "path" | "projectId" | "actorOrgId" | "actorAuthMethod" | "search" | "tagSlugs"+ > & {environments: string[];isInternal?: boolean;}) => {diff --git a/backend/src/services/secret/secret-service.ts b/backend/src/services/secret/secret-service.tsindex beecb5dd52..219c9a3a54 100644--- a/backend/src/services/secret/secret-service.ts+++ b/backend/src/services/secret/secret-service.ts@@ -1198,7 +1198,7 @@ export const secretServiceFactory = ({...v2Params}: Pick<TGetSecretsRawDTO,- "projectId" | "path" | "actor" | "actorId" | "actorOrgId" | "actorAuthMethod" | "search"+ "projectId" | "path" | "actor" | "actorId" | "actorOrgId" | "actorAuthMethod" | "search" | "tagSlugs"> & { environments: string[]; isInternal?: boolean }) => {const { shouldUseSecretV2Bridge } = await projectBotService.getBotKey(projectId);@@ -1231,7 +1231,7 @@ export const secretServiceFactory = ({actorAuthMethod,environments,...params- }: Omit<TGetSecretsRawDTO, "environment" | "includeImports" | "expandSecretReferences" | "recursive" | "tagSlugs"> & {+ }: Omit<TGetSecretsRawDTO, "environment" | "includeImports" | "expandSecretReferences" | "recursive"> & {environments: string[];isInternal?: boolean;}) => {diff --git a/frontend/src/hooks/api/dashboard/queries.tsx b/frontend/src/hooks/api/dashboard/queries.tsxindex 3866c63373..820341475f 100644--- a/frontend/src/hooks/api/dashboard/queries.tsx+++ b/frontend/src/hooks/api/dashboard/queries.tsx@@ -89,6 +89,7 @@ export const dashboardKeys = {export const fetchProjectSecretsOverview = async ({environments,+ tags,...params}: TGetDashboardProjectSecretsOverviewDTO) => {const { data } = await apiRequest.get<DashboardProjectSecretsOverviewResponse>(@@ -96,7 +97,14 @@ export const fetchProjectSecretsOverview = async ({{params: {...params,- environments: encodeURIComponent(environments.join(","))+ environments: encodeURIComponent(environments.join(",")),+ tags: encodeURIComponent(+ Object.entries(tags ?? {})+ // eslint-disable-next-line @typescript-eslint/no-unused-vars+ .filter(([_, enabled]) => enabled)+ .map(([tag]) => tag)+ .join(",")+ )}});@@ -168,6 +176,7 @@ export const useGetProjectSecretsOverview = (orderBy = DashboardSecretsOrderBy.Name,orderDirection = OrderByDirection.ASC,search = "",+ tags,includeSecrets,includeFolders,includeImports,@@ -194,6 +203,7 @@ export const useGetProjectSecretsOverview = (queryKey: dashboardKeys.getProjectSecretsOverview({secretPath,search,+ tags,limit,orderBy,orderDirection,@@ -210,6 +220,7 @@ export const useGetProjectSecretsOverview = (const resp = fetchProjectSecretsOverview({secretPath,search,+ tags,limit,orderBy,orderDirection,diff --git a/frontend/src/hooks/api/dashboard/types.ts b/frontend/src/hooks/api/dashboard/types.tsindex 5a7a519b73..6a738a0af4 100644--- a/frontend/src/hooks/api/dashboard/types.ts+++ b/frontend/src/hooks/api/dashboard/types.ts@@ -100,6 +100,7 @@ export type TGetDashboardProjectSecretsOverviewDTO = {orderBy?: DashboardSecretsOrderBy;orderDirection?: OrderByDirection;search?: string;+ tags?: Record<string, boolean>;includeSecrets?: boolean;includeFolders?: boolean;includeDynamicSecrets?: boolean;diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsxindex 11aa99402e..fb86eb705a 100644--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx@@ -534,6 +534,7 @@ const OverviewPageContent = () => {includeImports: isFilteredByResources ? (filter[RowType.SecretImport] ?? true) : true,includeSecretRotations: isFilteredByResources ? filter.rotation : true,search: debouncedSearchFilter,+ tags: tagFilter,limit,offset},@@ -601,17 +602,7 @@ const OverviewPageContent = () => {const { secretImportNames, isSecretImportInEnv, getSecretImportByEnv, getSecretImportsForEnv } =useSecretImportOverview(overview?.imports);- const { secKeys: rawSecKeys } = useSecretOverview(secrets || []);-- const secKeys = useMemo(() => {- if (!activeTagSlugs.length) return rawSecKeys;- const keysWithTag = new Set(- (secrets || [])- .filter((s) => s.tags?.some((tag) => activeTagSlugs.includes(tag.slug)))- .map((s) => s.key)- );- return rawSecKeys.filter((key) => keysWithTag.has(key));- }, [rawSecKeys, secrets, activeTagSlugs]);+ const { secKeys } = useSecretOverview(secrets || []);const getSecretByKey = useCallback((env: string, key: string) => {