Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: add flag to get all entities with potential or actual access to secret

Scott Wilsonef368ed9500a
diff --git a/backend/src/ee/routes/v1/secret-router.ts b/backend/src/ee/routes/v1/secret-router.ts
index bf4847560f..9ee1e4f08e 100644
--- a/backend/src/ee/routes/v1/secret-router.ts
+++ b/backend/src/ee/routes/v1/secret-router.ts
@@ -41,7 +41,12 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
.trim()
.default("/")
.transform(removeTrailingSlash)
- .describe(RAW_SECRETS.GET_ACCESS_LIST.secretPath)
+ .describe(RAW_SECRETS.GET_ACCESS_LIST.secretPath),
+ includeAllEntities: z
+ .enum(["true", "false"])
+ .default("false")
+ .transform((val) => val === "true")
+ .describe(RAW_SECRETS.GET_ACCESS_LIST.includeAllEntities)
}),
response: {
200: z.object({
@@ -54,7 +59,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
const { secretName } = req.params;
- const { secretPath, environment, projectId } = req.query;
+ const { secretPath, environment, projectId, includeAllEntities } = req.query;
return server.services.secret.getSecretAccessList({
actorId: req.permission.id,
@@ -64,7 +69,8 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
secretPath,
environment,
projectId,
- secretName
+ secretName,
+ includeAllEntities
});
}
});
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 7d14027137..c5e2d8f540 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -1321,7 +1321,9 @@ export const RAW_SECRETS = {
secretName: "The name of the secret to get the access list for.",
projectId: "The ID of the project where the secret is located.",
environment: "The slug of the environment where the the secret is located.",
- secretPath: "The folder path where the secret is located."
+ secretPath: "The folder path where the secret is located.",
+ includeAllEntities:
+ "When true, includes all project users, identities, and groups in the response, even those without any access to the secret."
}
} as const;
diff --git a/backend/src/services/secret/secret-service.ts b/backend/src/services/secret/secret-service.ts
index beecb5dd52..8389187ee1 100644
--- a/backend/src/services/secret/secret-service.ts
+++ b/backend/src/services/secret/secret-service.ts
@@ -1283,7 +1283,7 @@ export const secretServiceFactory = ({
};
const getSecretAccessList = async (dto: TGetSecretAccessListDTO) => {
- const { environment, secretPath, secretName, projectId } = dto;
+ const { environment, secretPath, secretName, projectId, includeAllEntities } = dto;
const plan = await licenseService.getPlan(dto.actorOrgId);
if (!plan.secretAccessInsights) {
throw new BadRequestError({
@@ -1351,15 +1351,14 @@ export const secretServiceFactory = ({
};
};
- const usersWithAccess = userPermissions.map(attachAllowedActions).filter((user) => user.allowedActions.length > 0);
- const identitiesWithAccess = identityPermissions
- .map(attachAllowedActions)
- .filter((identity) => identity.allowedActions.length > 0);
- const groupsWithAccess = groupPermissions
- .map(attachAllowedActions)
- .filter((group) => group.allowedActions.length > 0);
+ const hasAccess = (entity: { allowedActions: string[] }) => entity.allowedActions.length > 0;
+ const filterFn = includeAllEntities ? () => true : hasAccess;
- return { users: usersWithAccess, identities: identitiesWithAccess, groups: groupsWithAccess };
+ const users = userPermissions.map(attachAllowedActions).filter(filterFn);
+ const identities = identityPermissions.map(attachAllowedActions).filter(filterFn);
+ const groups = groupPermissions.map(attachAllowedActions).filter(filterFn);
+
+ return { users, identities, groups };
};
const getAccessibleSecrets = async ({
diff --git a/backend/src/services/secret/secret-types.ts b/backend/src/services/secret/secret-types.ts
index 96901c20c6..6698b4c956 100644
--- a/backend/src/services/secret/secret-types.ts
+++ b/backend/src/services/secret/secret-types.ts
@@ -236,6 +236,7 @@ export type TGetSecretAccessListDTO = {
environment: string;
secretPath: string;
secretName: string;
+ includeAllEntities?: boolean;
} & TProjectPermission;
export type TGetASecretRawDTO = {
diff --git a/frontend/src/hooks/api/secrets/queries.tsx b/frontend/src/hooks/api/secrets/queries.tsx
index 2855b6614c..131c1c0f73 100644
--- a/frontend/src/hooks/api/secrets/queries.tsx
+++ b/frontend/src/hooks/api/secrets/queries.tsx
@@ -45,9 +45,10 @@ export const secretKeys = {
projectId,
environment,
secretPath,
- secretKey
+ secretKey,
+ includeAllEntities
}: TGetSecretAccessListDTO) =>
- ["secret-access-list", { projectId, environment, secretPath, secretKey }] as const,
+ ["secret-access-list", { projectId, environment, secretPath, secretKey, includeAllEntities }] as const,
getSecretReferenceTree: (dto: TGetSecretReferenceTreeDTO) => ["secret-reference-tree", dto],
getSecretReferences: (dto: TGetSecretReferencesDTO) => ["secret-references", dto]
};
@@ -307,7 +308,8 @@ export const useGetSecretAccessList = (dto: TGetSecretAccessListDTO) =>
params: {
projectId: dto.projectId,
environment: dto.environment,
- secretPath: dto.secretPath
+ secretPath: dto.secretPath,
+ includeAllEntities: dto.includeAllEntities ?? undefined
}
});
diff --git a/frontend/src/hooks/api/secrets/types.ts b/frontend/src/hooks/api/secrets/types.ts
index 7f6543054f..c7a52a7b3e 100644
--- a/frontend/src/hooks/api/secrets/types.ts
+++ b/frontend/src/hooks/api/secrets/types.ts
@@ -165,6 +165,7 @@ export type TGetSecretAccessListDTO = {
environment: string;
secretPath: string;
secretKey: string;
+ includeAllEntities?: boolean;
};
export type TCreateSecretsV3DTO = {
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx
index 41553efe36..87ebefb36a 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx
@@ -21,6 +21,7 @@ import {
InputGroupAddon,
InputGroupInput,
Sheet,
+ Switch,
SheetContent,
SheetDescription,
SheetHeader,
@@ -117,6 +118,7 @@ export function SecretAccessInsights({ secretKey, environment, secretPath }: Pro
const [editingPrivilege, setEditingPrivilege] = useState<EditingPrivilege | null>(null);
const [searchFilter, setSearchFilter] = useState("");
const [typeFilters, setTypeFilters] = useState<Set<AccessRowType>>(() => new Set());
+ const [showAllEntities, setShowAllEntities] = useState(false);
const toggleTypeFilter = (type: AccessRowType) => {
setTypeFilters((prev) => {
@@ -161,7 +163,8 @@ export function SecretAccessInsights({ secretKey, environment, secretPath }: Pro
projectId: currentProject.id,
environment,
secretPath,
- secretKey
+ secretKey,
+ includeAllEntities: showAllEntities
});
const flatRows = useMemo<AccessRow[]>(() => {
@@ -360,6 +363,14 @@ export function SecretAccessInsights({ secretKey, environment, secretPath }: Pro
})}
</UnstableDropdownMenuContent>
</UnstableDropdownMenu>
+ <label className="flex cursor-pointer items-center gap-2 text-xs text-muted whitespace-nowrap">
+ <Switch
+ size="sm"
+ checked={showAllEntities}
+ onCheckedChange={setShowAllEntities}
+ />
+ Show all
+ </label>
</div>
{filteredRows.length === 0 ? (