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(api): enhance group and identity queries to include organization context
Victor Hugo dos Santos2aa5ca27dd3d
diff --git a/frontend/src/hooks/api/groups/queries.tsx b/frontend/src/hooks/api/groups/queries.tsxindex cd2b9a00cb..fda82120cb 100644--- a/frontend/src/hooks/api/groups/queries.tsx+++ b/frontend/src/hooks/api/groups/queries.tsx@@ -1,6 +1,7 @@import { useQuery } from "@tanstack/react-query";import { apiRequest } from "@app/config/request";+import { useOrganization } from "@app/context";import { OrderByDirection } from "../generic/types";import {@@ -18,6 +19,8 @@ import {export const groupKeys = {getGroupById: (groupId: string) => [{ groupId }, "group"] as const,+ getGroupByIdForOrg: (orgId: string, groupId: string) =>+ [...groupKeys.getGroupById(groupId), orgId] as const,allGroupUserMemberships: () => ["group-user-memberships"] as const,forGroupUserMemberships: (slug: string) =>[...groupKeys.allGroupUserMemberships(), slug] as const,@@ -77,6 +80,7 @@ export const groupKeys = {allGroupProjects: () => ["group-projects"] as const,forGroupProjects: (groupId: string) => [...groupKeys.allGroupProjects(), groupId] as const,specificGroupProjects: ({+ orgId,groupId,offset,limit,@@ -85,6 +89,7 @@ export const groupKeys = {orderBy,orderDirection}: {+ orgId: string;groupId: string;offset: number;limit: number;@@ -95,14 +100,18 @@ export const groupKeys = {}) =>[...groupKeys.forGroupProjects(groupId),+ orgId,{ offset, limit, search, filter, orderBy, orderDirection }] as const};export const useGetGroupById = (groupId: string) => {+ const { currentOrg } = useOrganization();+ const orgId = currentOrg?.id || "";+return useQuery({enabled: Boolean(groupId),- queryKey: groupKeys.getGroupById(groupId),+ queryKey: groupKeys.getGroupByIdForOrg(orgId, groupId),queryFn: async () => {const { data } = await apiRequest.get<TGroup>(`/api/v1/groups/${groupId}`);@@ -276,8 +285,12 @@ export const useListGroupProjects = ({orderDirection?: OrderByDirection;filter?: FilterReturnedProjects;}) => {+ const { currentOrg } = useOrganization();+ const orgId = currentOrg?.id || "";+return useQuery({queryKey: groupKeys.specificGroupProjects({+ orgId,groupId: id,offset,limit,diff --git a/frontend/src/hooks/api/identities/queries.tsx b/frontend/src/hooks/api/identities/queries.tsxindex bc698516b8..1128c52668 100644--- a/frontend/src/hooks/api/identities/queries.tsx+++ b/frontend/src/hooks/api/identities/queries.tsx@@ -1,6 +1,7 @@import { useQuery } from "@tanstack/react-query";import { apiRequest } from "@app/config/request";+import { useOrganization } from "@app/context";import { TReactQueryOptions } from "@app/types/reactQuery";import {@@ -58,7 +59,11 @@ export const identitiesKeys = {getIdentityTokensTokenAuth: (identityId: string) =>[{ identityId }, "identity-tokens-token-auth"] as const,getIdentityProjectMemberships: (identityId: string) =>- [{ identityId }, "identity-project-memberships"] as const+ [{ identityId }, "identity-project-memberships"] as const,+ // The membership list is filtered to the viewing org (Membership.scopeOrgId),+ // so a sub-org and its parent must not share this cache entry.+ getIdentityProjectMembershipsForOrg: (orgId: string, identityId: string) =>+ [...identitiesKeys.getIdentityProjectMemberships(identityId), orgId] as const};export const useGetOrgIdentityMembershipById = (identityId: string) => {@@ -114,9 +119,12 @@ export const useCountOrgIdentityMemberships = (dto: TCountIdentitiesDTO) => {};export const useGetIdentityProjectMemberships = (identityId: string) => {+ const { currentOrg } = useOrganization();+ const orgId = currentOrg?.id || "";+return useQuery({enabled: Boolean(identityId),- queryKey: identitiesKeys.getIdentityProjectMemberships(identityId),+ queryKey: identitiesKeys.getIdentityProjectMembershipsForOrg(orgId, identityId),queryFn: async () => {const {data: { identityMemberships }