Skip to content

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

improvement: show inherited group actions in access insights

Scott Wilson77a0a2891614
diff --git a/backend/src/ee/routes/v1/secret-router.ts b/backend/src/ee/routes/v1/secret-router.ts
index 9ee1e4f08e..41366f54ff 100644
--- a/backend/src/ee/routes/v1/secret-router.ts
+++ b/backend/src/ee/routes/v1/secret-router.ts
@@ -7,14 +7,12 @@ import { readLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
-const AccessListEntrySchema = z
- .object({
- allowedActions: z.nativeEnum(ProjectPermissionSecretActions).array(),
- id: z.string(),
- name: z.string(),
- membershipId: z.string()
- })
- .array();
+const AccessListEntrySchema = z.object({
+ allowedActions: z.nativeEnum(ProjectPermissionSecretActions).array(),
+ id: z.string(),
+ name: z.string(),
+ membershipId: z.string()
+});
export const registerSecretRouter = async (server: FastifyZodProvider) => {
server.route({
@@ -50,9 +48,12 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- groups: AccessListEntrySchema,
- identities: AccessListEntrySchema,
- users: AccessListEntrySchema
+ groups: AccessListEntrySchema.extend({
+ userIds: z.string().array(),
+ identityIds: z.string().array()
+ }).array(),
+ identities: AccessListEntrySchema.array(),
+ users: AccessListEntrySchema.array()
})
}
},
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 100e452622..b6cbbce50a 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -1698,7 +1698,9 @@ export const registerRoutes = async (
licenseService,
reminderService,
secretVersionV2DAL: secretVersionV2BridgeDAL,
- secretV2BridgeDAL
+ secretV2BridgeDAL,
+ userGroupMembershipDAL,
+ identityGroupMembershipDAL
});
const secretSharingService = secretSharingServiceFactory({
diff --git a/backend/src/services/secret/secret-service.ts b/backend/src/services/secret/secret-service.ts
index 8389187ee1..cd22d9fbae 100644
--- a/backend/src/services/secret/secret-service.ts
+++ b/backend/src/services/secret/secret-service.ts
@@ -12,6 +12,8 @@ import {
SecretsSchema,
SecretType
} from "@app/db/schemas";
+import { TIdentityGroupMembershipDALFactory } from "@app/ee/services/group/identity-group-membership-dal";
+import { TUserGroupMembershipDALFactory } from "@app/ee/services/group/user-group-membership-dal";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import {
hasSecretReadValueOrDescribePermission,
@@ -137,6 +139,8 @@ type TSecretServiceFactoryDep = {
reminderService: Pick<TReminderServiceFactory, "createReminder">;
secretVersionV2DAL: Pick<TSecretVersionV2DALFactory, "findOne">;
secretV2BridgeDAL: Pick<TSecretV2BridgeDALFactory, "invalidateSecretCacheByProjectId">;
+ userGroupMembershipDAL: Pick<TUserGroupMembershipDALFactory, "find">;
+ identityGroupMembershipDAL: Pick<TIdentityGroupMembershipDALFactory, "find">;
};
export type TSecretServiceFactory = ReturnType<typeof secretServiceFactory>;
@@ -162,7 +166,9 @@ export const secretServiceFactory = ({
licenseService,
reminderService,
secretVersionV2DAL,
- secretV2BridgeDAL
+ secretV2BridgeDAL,
+ userGroupMembershipDAL,
+ identityGroupMembershipDAL
}: TSecretServiceFactoryDep) => {
const getSecretReference = async (projectId: string) => {
// if bot key missing means e2e still exist
@@ -1356,7 +1362,20 @@ export const secretServiceFactory = ({
const users = userPermissions.map(attachAllowedActions).filter(filterFn);
const identities = identityPermissions.map(attachAllowedActions).filter(filterFn);
- const groups = groupPermissions.map(attachAllowedActions).filter(filterFn);
+ const groupsWithActions = groupPermissions.map(attachAllowedActions).filter(filterFn);
+
+ // Fetch group member user IDs and identity IDs
+ const groupIds = groupsWithActions.map((g) => g.id);
+ const [userGroupMemberships, identityGroupMemberships] = await Promise.all([
+ groupIds.length > 0 ? userGroupMembershipDAL.find({ $in: { groupId: groupIds } }) : [],
+ groupIds.length > 0 ? identityGroupMembershipDAL.find({ $in: { groupId: groupIds } }) : []
+ ]);
+
+ const groups = groupsWithActions.map((group) => ({
+ ...group,
+ userIds: userGroupMemberships.filter((m) => m.groupId === group.id).map((m) => m.userId),
+ identityIds: identityGroupMemberships.filter((m) => m.groupId === group.id).map((m) => m.identityId)
+ }));
return { users, identities, groups };
};
diff --git a/frontend/src/hooks/api/secrets/queries.tsx b/frontend/src/hooks/api/secrets/queries.tsx
index a75a7bece0..be9b765b1f 100644
--- a/frontend/src/hooks/api/secrets/queries.tsx
+++ b/frontend/src/hooks/api/secrets/queries.tsx
@@ -12,6 +12,7 @@ import { ERROR_NOT_ALLOWED_READ_SECRETS } from "./constants";
import {
GetSecretVersionsDTO,
SecretAccessListEntry,
+ SecretAccessListGroupEntry,
SecretType,
SecretV3Raw,
SecretV3RawResponse,
@@ -304,7 +305,7 @@ export const useGetSecretAccessList = (dto: TGetSecretAccessListDTO) =>
queryKey: secretKeys.getSecretAccessList(dto),
queryFn: async () => {
const { data } = await apiRequest.get<{
- groups: SecretAccessListEntry[];
+ groups: SecretAccessListGroupEntry[];
identities: SecretAccessListEntry[];
users: SecretAccessListEntry[];
}>(`/api/v1/secrets/${dto.secretKey}/access-list`, {
diff --git a/frontend/src/hooks/api/secrets/types.ts b/frontend/src/hooks/api/secrets/types.ts
index 790beb8faf..381999f615 100644
--- a/frontend/src/hooks/api/secrets/types.ts
+++ b/frontend/src/hooks/api/secrets/types.ts
@@ -296,3 +296,8 @@ export type SecretAccessListEntry = {
membershipId: string;
name: string;
};
+
+export type SecretAccessListGroupEntry = SecretAccessListEntry & {
+ userIds: string[];
+ identityIds: string[];
+};
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 1d803f18fd..fd002b27e2 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx
@@ -103,6 +103,8 @@ type AccessRow = {
linkParams: Record<string, string>;
canEdit: boolean;
onEdit?: () => void;
+ inheritedFromGroups?: string[];
+ inheritedActions?: Set<string>;
};
const PERMISSION_COLUMNS = [
@@ -375,9 +377,29 @@ export function SecretAccessInsights({ secretKey, environment, secretPath }: Pro
if (!secretAccessList) return [];
const baseUrl = getProjectBaseURL(currentProject.type);
+ // Build lookup: for each user/identity, find groups they belong to that have access
+ const groupsWithAccess = secretAccessList.groups.filter((g) => g.allowedActions.length > 0);
+
+ const getGroupInheritance = (
+ entityId: string,
+ directActions: string[],
+ memberField: "userIds" | "identityIds"
+ ) => {
+ const matchingGroups = groupsWithAccess.filter((g) => g[memberField].includes(entityId));
+ const groupNames = matchingGroups.map((g) => g.name);
+ const inherited = new Set<string>(
+ matchingGroups
+ .flatMap((g) => g.allowedActions)
+ .filter((action) => !directActions.includes(action))
+ );
+ return { groupNames, inherited };
+ };
+
return [
- ...secretAccessList.users.map(
- (user): AccessRow => ({
+ ...secretAccessList.users.map((user): AccessRow => {
+ const { groupNames: inheritedFromGroups, inherited: inheritedActions } =
+ getGroupInheritance(user.id, user.allowedActions, "userIds");
+ return {
type: "user",
entry: user,
linkTo: `${baseUrl}/members/$membershipId`,
@@ -395,11 +417,15 @@ export function SecretAccessInsights({ secretKey, environment, secretPath }: Pro
type: "user",
membershipId: user.membershipId,
name: user.name
- })
- })
- ),
- ...secretAccessList.identities.map(
- (identity): AccessRow => ({
+ }),
+ inheritedFromGroups,
+ inheritedActions
+ };
+ }),
+ ...secretAccessList.identities.map((identity): AccessRow => {
+ const { groupNames: identityInheritedGroups, inherited: identityInheritedActions } =
+ getGroupInheritance(identity.id, identity.allowedActions, "identityIds");
+ return {
type: "identity",
entry: identity,
linkTo: `${baseUrl}/identities/$identityId`,
@@ -418,9 +444,11 @@ export function SecretAccessInsights({ secretKey, environment, secretPath }: Pro
membershipId: identity.membershipId,
identityId: identity.id,
name: identity.name
- })
- })
- ),
+ }),
+ inheritedFromGroups: identityInheritedGroups,
+ inheritedActions: identityInheritedActions
+ };
+ }),
...secretAccessList.groups.map(
(group): AccessRow => ({
type: "group",
@@ -619,17 +647,47 @@ export function SecretAccessInsights({ secretKey, environment, secretPath }: Pro
</span>
</UnstableTableCell>
<UnstableTableCell isTruncatable className="max-w-[180px] font-medium">
- {row.entry.name}
- </UnstableTableCell>
- {visibleColumns.map((col) => (
- <UnstableTableCell key={col.action} className="w-[100px] text-center">
- {row.entry.allowedActions.includes(col.action) ? (
- <CheckIcon className="mx-auto size-4 text-success" />
- ) : (
- <BanIcon className="mx-auto size-4 text-muted" />
+ <div className="flex items-center gap-1.5">
+ <span className="truncate">{row.entry.name}</span>
+ {row.inheritedFromGroups && row.inheritedFromGroups.length > 0 && (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="inline-flex shrink-0 items-center gap-1 rounded bg-foreground/5 px-1.5 py-0.5 text-xs text-muted">
+ <UsersIcon className="size-3" />
+ {row.inheritedFromGroups.length}
+ </span>
+ </TooltipTrigger>
+ <TooltipContent side="bottom">
+ Access through{" "}
+ {row.inheritedFromGroups.length === 1
+ ? `group: ${row.inheritedFromGroups[0]}`
+ : `groups: ${row.inheritedFromGroups.join(", ")}`}
+ </TooltipContent>
+ </Tooltip>
)}
- </UnstableTableCell>
- ))}
+ </div>
+ </UnstableTableCell>
+ {visibleColumns.map((col) => {
+ const hasDirect = row.entry.allowedActions.includes(col.action);
+ const hasInherited = row.inheritedActions?.has(col.action);
+ return (
+ <UnstableTableCell key={col.action} className="w-[100px] text-center">
+ {/* eslint-disable-next-line no-nested-ternary */}
+ {hasDirect ? (
+ <CheckIcon className="mx-auto size-4 text-success" />
+ ) : hasInherited ? (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <UsersIcon className="mx-auto size-4 text-success" />
+ </TooltipTrigger>
+ <TooltipContent>Inherited from group</TooltipContent>
+ </Tooltip>
+ ) : (
+ <BanIcon className="mx-auto size-4 text-muted" />
+ )}
+ </UnstableTableCell>
+ );
+ })}
<UnstableTableCell className="text-right">
<UnstableDropdownMenu>
<UnstableDropdownMenuTrigger asChild>