Skip to content

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

misc: removed remaining folder path references and addressed comments

Sheen Capadngan4166bd19822c
diff --git a/backend/src/db/migrations/20260206151238_add-uniqueness-constraints-for-pam.ts b/backend/src/db/migrations/20260206151238_add-uniqueness-constraints-for-pam.ts
index 6e9a4df340..e4c6499e52 100644
--- a/backend/src/db/migrations/20260206151238_add-uniqueness-constraints-for-pam.ts
+++ b/backend/src/db/migrations/20260206151238_add-uniqueness-constraints-for-pam.ts
@@ -7,7 +7,15 @@ const RESOURCE_CONSTRAINT_NAME = "pam_resources_name_project_id_unique";
const ACCOUNT_CONSTRAINT_NAME = "pam_accounts_name_resource_id_unique";
export async function up(knex: Knex): Promise<void> {
- // Delete all existing PAM access approval policies because we're moving away from FOLDERS
+ // Delete all existing PAM access approval requests, grants, and policies because we're moving away from FOLDERS
+ if (await knex.schema.hasTable(TableName.ApprovalRequestGrants)) {
+ await knex(TableName.ApprovalRequestGrants).where("type", "pam-access").del();
+ }
+
+ if (await knex.schema.hasTable(TableName.ApprovalRequests)) {
+ await knex(TableName.ApprovalRequests).where("type", "pam-access").del();
+ }
+
if (await knex.schema.hasTable(TableName.ApprovalPolicies)) {
await knex(TableName.ApprovalPolicies).where("type", "pam-access").del();
}
diff --git a/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts b/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts
index 4f70db3dde..8543e7933d 100644
--- a/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts
+++ b/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts
@@ -1,6 +1,5 @@
import { z } from "zod";
-import { PamFoldersSchema } from "@app/db/schemas";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
import { PamAccountOrderBy, PamAccountView } from "@app/ee/services/pam-account/pam-account-enums";
import { SanitizedAwsIamAccountWithResourceSchema } from "@app/ee/services/pam-resource/aws-iam/aws-iam-resource-schemas";
@@ -12,7 +11,6 @@ import { SanitizedPostgresAccountWithResourceSchema } from "@app/ee/services/pam
import { SanitizedRedisAccountWithResourceSchema } from "@app/ee/services/pam-resource/redis/redis-resource-schemas";
import { SanitizedSSHAccountWithResourceSchema } from "@app/ee/services/pam-resource/ssh/ssh-resource-schemas";
import { BadRequestError } from "@app/lib/errors";
-import { removeTrailingSlash } from "@app/lib/fn";
import { ms } from "@app/lib/ms";
import { OrderByDirection } from "@app/lib/types";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
@@ -31,10 +29,7 @@ const SanitizedAccountSchema = z.union([
const ListPamAccountsResponseSchema = z.object({
accounts: SanitizedAccountSchema.array(),
- folders: PamFoldersSchema.array(),
- totalCount: z.number().default(0),
- folderId: z.string().optional(),
- folderPaths: z.record(z.string(), z.string())
+ totalCount: z.number().default(0)
});
export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
@@ -92,7 +87,6 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
description: "List PAM accounts",
querystring: z.object({
projectId: z.string().uuid(),
- accountPath: z.string().trim().default("/").transform(removeTrailingSlash),
accountView: z.nativeEnum(PamAccountView).default(PamAccountView.Flat),
offset: z.coerce.number().min(0).default(0),
limit: z.coerce.number().min(1).max(100).default(100),
@@ -115,16 +109,14 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
},
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
- const { projectId, accountPath, accountView, limit, offset, search, orderBy, orderDirection, filterResourceIds } =
- req.query;
+ const { projectId, accountView, limit, offset, search, orderBy, orderDirection, filterResourceIds } = req.query;
- const { accounts, folders, totalCount, folderId, folderPaths } = await server.services.pamAccount.list({
+ const { accounts, totalCount } = await server.services.pamAccount.list({
actorId: req.permission.id,
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
projectId,
- accountPath,
accountView,
limit,
offset,
@@ -141,13 +133,12 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
event: {
type: EventType.PAM_ACCOUNT_LIST,
metadata: {
- accountCount: accounts.length,
- folderCount: folders.length
+ accountCount: accounts.length
}
}
});
- return { accounts, folders, totalCount, folderId, folderPaths } as z.infer<typeof ListPamAccountsResponseSchema>;
+ return { accounts, totalCount } as z.infer<typeof ListPamAccountsResponseSchema>;
}
});
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 7721edab87..4ad4600f09 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -4238,7 +4238,6 @@ interface PamAccountListEvent {
type: EventType.PAM_ACCOUNT_LIST;
metadata: {
accountCount: number;
- folderCount: number;
};
}
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts
index c76bacf271..52c14b741a 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError, subject } from "@casl/ability";
-import { ActionProjectType, OrganizationActionScope, TPamAccounts, TPamFolders, TPamResources } from "@app/db/schemas";
+import { ActionProjectType, OrganizationActionScope, TPamAccounts, TPamResources } from "@app/db/schemas";
import {
extractAwsAccountIdFromArn,
generateConsoleFederationUrl,
@@ -15,7 +15,6 @@ import {
import { SSHAuthMethod } from "@app/ee/services/pam-resource/ssh/ssh-resource-enums";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import {
- ProjectPermissionActions,
ProjectPermissionPamAccountActions,
ProjectPermissionSub
} from "@app/ee/services/permission/project-permission";
@@ -50,8 +49,6 @@ import { TUserDALFactory } from "@app/services/user/user-dal";
import { EventType, TAuditLogServiceFactory } from "../audit-log/audit-log-types";
import { TGatewayV2ServiceFactory } from "../gateway-v2/gateway-v2-service";
-import { TPamFolderDALFactory } from "../pam-folder/pam-folder-dal";
-import { getFullPamFolderPath } from "../pam-folder/pam-folder-fns";
import { TPamResourceDALFactory } from "../pam-resource/pam-resource-dal";
import { PamResource } from "../pam-resource/pam-resource-enums";
import { TPamAccountCredentials } from "../pam-resource/pam-resource-types";
@@ -62,7 +59,6 @@ import { TPamSessionDALFactory } from "../pam-session/pam-session-dal";
import { PamSessionStatus } from "../pam-session/pam-session-enums";
import { OrgPermissionGatewayActions, OrgPermissionSubjects } from "../permission/org-permission";
import { TPamAccountDALFactory } from "./pam-account-dal";
-import { PamAccountView } from "./pam-account-enums";
import { decryptAccount, decryptAccountCredentials, encryptAccountCredentials } from "./pam-account-fns";
import {
TAccessAccountDTO,
@@ -76,7 +72,6 @@ type TPamAccountServiceFactoryDep = {
pamResourceDAL: TPamResourceDALFactory;
pamSessionDAL: TPamSessionDALFactory;
pamAccountDAL: TPamAccountDALFactory;
- pamFolderDAL: TPamFolderDALFactory;
mfaSessionService: TMfaSessionServiceFactory;
projectDAL: TProjectDALFactory;
orgDAL: TOrgDALFactory;
@@ -104,7 +99,6 @@ export const pamAccountServiceFactory = ({
pamSessionDAL,
pamAccountDAL,
mfaSessionService,
- pamFolderDAL,
projectDAL,
orgDAL,
userDAL,
@@ -151,18 +145,11 @@ export const pamAccountServiceFactory = ({
throw new NotFoundError({ message: "Rotation credentials are not configured for this account's resource" });
}
- const accountPath = await getFullPamFolderPath({
- pamFolderDAL,
- folderId,
- projectId: resource.projectId
- });
-
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionPamAccountActions.Create,
subject(ProjectPermissionSub.PamAccounts, {
resourceName: resource.name,
- accountName: name,
- accountPath
+ accountName: name
})
);
@@ -257,18 +244,11 @@ export const pamAccountServiceFactory = ({
actionProjectType: ActionProjectType.PAM
});
- const accountPath = await getFullPamFolderPath({
- pamFolderDAL,
- folderId: account.folderId,
- projectId: account.projectId
- });
-
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionPamAccountActions.Edit,
subject(ProjectPermissionSub.PamAccounts, {
resourceName: resource.name,
- accountName: account.name,
- accountPath
+ accountName: account.name
})
);
@@ -387,18 +367,11 @@ export const pamAccountServiceFactory = ({
actionProjectType: ActionProjectType.PAM
});
- const accountPath = await getFullPamFolderPath({
- pamFolderDAL,
- folderId: account.folderId,
- projectId: account.projectId
- });
-
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionPamAccountActions.Delete,
subject(ProjectPermissionSub.PamAccounts, {
resourceName: resource.name,
- accountName: account.name,
- accountPath
+ accountName: account.name
})
);
@@ -417,7 +390,6 @@ export const pamAccountServiceFactory = ({
const list = async ({
projectId,
- accountPath,
accountView,
actor,
actorId,
@@ -437,74 +409,17 @@ export const pamAccountServiceFactory = ({
const limit = params.limit || 20;
const offset = params.offset || 0;
- const canReadFolders = permission.can(ProjectPermissionActions.Read, ProjectPermissionSub.PamFolders);
-
- const folder = accountPath === "/" ? null : await pamFolderDAL.findByPath(projectId, accountPath);
- if (accountPath !== "/" && !folder) {
- return { accounts: [], folders: [], totalCount: 0, folderPaths: {} };
- }
- const folderId = folder?.id;
-
- let totalFolderCount = 0;
- if (canReadFolders && accountView === PamAccountView.Nested) {
- const { totalCount } = await pamFolderDAL.findByProjectId({
- projectId,
- parentId: folderId,
- search: params.search
- });
- totalFolderCount = totalCount;
- }
-
- let folders: TPamFolders[] = [];
- if (canReadFolders && accountView === PamAccountView.Nested && offset < totalFolderCount) {
- const folderLimit = Math.min(limit, totalFolderCount - offset);
- const { folders: foldersResp } = await pamFolderDAL.findByProjectId({
+ const { accounts: accountsWithResourceDetails, totalCount } =
+ await pamAccountDAL.findByProjectIdWithResourceDetails({
projectId,
- parentId: folderId,
- limit: folderLimit,
- offset,
- search: params.search,
- orderBy: params.orderBy,
- orderDirection: params.orderDirection
- });
-
- folders = foldersResp;
- }
-
- let accountsWithResourceDetails: Awaited<
- ReturnType<typeof pamAccountDAL.findByProjectIdWithResourceDetails>
- >["accounts"] = [];
- let totalAccountCount = 0;
-
- const accountsToFetch = limit - folders.length;
- if (accountsToFetch > 0) {
- const accountOffset = Math.max(0, offset - totalFolderCount);
- const { accounts, totalCount } = await pamAccountDAL.findByProjectIdWithResourceDetails({
- projectId,
- folderId,
accountView,
- offset: accountOffset,
- limit: accountsToFetch,
+ offset,
+ limit,
search: params.search,
orderBy: params.orderBy,
orderDirection: params.orderDirection,
filterResourceIds: params.filterResourceIds
});
- accountsWithResourceDetails = accounts;
- totalAccountCount = totalCount;
- } else {
- // if no accounts are to be fetched for the current page, we still need the total count for pagination
- const { totalCount } = await pamAccountDAL.findByProjectIdWithResourceDetails({
- projectId,
- folderId,
- accountView,
- search: params.search,
- filterResourceIds: params.filterResourceIds
- });
- totalAccountCount = totalCount;
- }
-
- const totalCount = totalFolderCount + totalAccountCount;
const decryptedAndPermittedAccounts: Array<
Omit<TPamAccounts, "encryptedCredentials" | "encryptedLastRotationMessage"> & {
@@ -521,8 +436,7 @@ export const pamAccountServiceFactory = ({
ProjectPermissionPamAccountActions.Read,
subject(ProjectPermissionSub.PamAccounts, {
resourceName: account.resource.name,
- accountName: account.name,
- accountPath
+ accountName: account.name
})
)
) {
@@ -541,27 +455,9 @@ export const pamAccountServiceFactory = ({
}
}
- const folderPaths: Record<string, string> = {};
- const accountFolderIds = [
- ...new Set(decryptedAndPermittedAccounts.flatMap((a) => (a.folderId ? [a.folderId] : [])))
- ];
-
- await Promise.all(
- accountFolderIds.map(async (fId) => {
- folderPaths[fId] = await getFullPamFolderPath({
- pamFolderDAL,
- folderId: fId,
- projectId
- });
- })
- );
-
return {
accounts: decryptedAndPermittedAccounts,
- folders,
- totalCount,
- folderId,
- folderPaths
+ totalCount
};
};
@@ -578,18 +474,11 @@ export const pamAccountServiceFactory = ({
actionProjectType: ActionProjectType.PAM
});
- const accountPath = await getFullPamFolderPath({
- pamFolderDAL,
- folderId: accountWithResource.folderId,
- projectId: accountWithResource.projectId
- });
-
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionPamAccountActions.Read,
subject(ProjectPermissionSub.PamAccounts, {
resourceName: accountWithResource.resource.name,
- accountName: accountWithResource.name,
- accountPath
+ accountName: accountWithResource.name
})
);
diff --git a/backend/src/ee/services/pam-account/pam-account-types.ts b/backend/src/ee/services/pam-account/pam-account-types.ts
index 4f79ee6c83..c453f7b612 100644
--- a/backend/src/ee/services/pam-account/pam-account-types.ts
+++ b/backend/src/ee/services/pam-account/pam-account-types.ts
@@ -28,7 +28,6 @@ export type TAccessAccountDTO = {
};
export type TListAccountsDTO = {
- accountPath: string;
accountView: PamAccountView;
search?: string;
orderBy?: PamAccountOrderBy;
diff --git a/backend/src/ee/services/pam-resource/pam-resource-service.ts b/backend/src/ee/services/pam-resource/pam-resource-service.ts
index 3c903db50b..30eb48cd18 100644
--- a/backend/src/ee/services/pam-resource/pam-resource-service.ts
+++ b/backend/src/ee/services/pam-resource/pam-resource-service.ts
@@ -19,7 +19,6 @@ import { TGatewayV2ServiceFactory } from "../gateway-v2/gateway-v2-service";
import { TPamAccountDALFactory } from "../pam-account/pam-account-dal";
import { PamAccountView } from "../pam-account/pam-account-enums";
import { decryptAccountCredentials, encryptAccountCredentials } from "../pam-account/pam-account-fns";
-import { TPamFolderDALFactory } from "../pam-folder/pam-folder-dal";
import { TPamResourceDALFactory } from "./pam-resource-dal";
import { PamResource } from "./pam-resource-enums";
import { PAM_RESOURCE_FACTORY_MAP } from "./pam-resource-factory";
@@ -37,7 +36,6 @@ import { TSSHResourceMetadata } from "./ssh/ssh-resource-types";
type TPamResourceServiceFactoryDep = {
pamResourceDAL: TPamResourceDALFactory;
pamAccountDAL: Pick<TPamAccountDALFactory, "findByProjectIdWithResourceDetails">;
- pamFolderDAL: Pick<TPamFolderDALFactory, "find">;
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getOrgPermission">;
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
gatewayV2Service: Pick<
@@ -51,7 +49,6 @@ export type TPamResourceServiceFactory = ReturnType<typeof pamResourceServiceFac
export const pamResourceServiceFactory = ({
pamResourceDAL,
pamAccountDAL,
- pamFolderDAL,
permissionService,
kmsService,
gatewayV2Service
@@ -79,35 +76,12 @@ export const pamResourceServiceFactory = ({
filterResourceIds: [id]
});
- // Compute folder paths for account path resolution
- const uniqueFolderIds = [...new Set(accounts.filter((a) => a.folderId).map((a) => a.folderId!))];
- const folderPathMap: Record<string, string> = {};
-
- if (uniqueFolderIds.length > 0) {
- const allFolders = await pamFolderDAL.find({ projectId: resource.projectId });
- const folderMap = new Map(allFolders.map((f) => [f.id, f]));
-
- for (const folderId of uniqueFolderIds) {
- const pathSegments: string[] = [];
- let currentId: string | null | undefined = folderId;
- while (currentId) {
- const folder = folderMap.get(currentId);
- if (!folder) break;
- pathSegments.unshift(folder.name);
- currentId = folder.parentId;
- }
- folderPathMap[folderId] = `/${pathSegments.join("/")}`;
- }
- }
-
const hasAccountAccess = accounts.some((account) => {
- const accountPath = account.folderId ? folderPathMap[account.folderId] || "/" : "/";
return permission.can(
ProjectPermissionPamAccountActions.Read,
subject(ProjectPermissionSub.PamAccounts, {
resourceName: resource.name,
- accountName: account.name,
- accountPath
+ accountName: account.name
})
);
});
@@ -388,33 +362,11 @@ export const pamResourceServiceFactory = ({
return { resources: [], totalCount: 0 };
}
- // Compute folder paths so we can build the accountPath for each account
- const uniqueFolderIds = [...new Set(allAccounts.filter((a) => a.folderId).map((a) => a.folderId!))];
- const folderPathMap: Record<string, string> = {};
-
- if (uniqueFolderIds.length > 0) {
- const allFolders = await pamFolderDAL.find({ projectId });
- const folderMap = new Map(allFolders.map((f) => [f.id, f]));
-
- for (const folderId of uniqueFolderIds) {
- const pathSegments: string[] = [];
- let currentId: string | null | undefined = folderId;
- while (currentId) {
- const folder = folderMap.get(currentId);
- if (!folder) break;
- pathSegments.unshift(folder.name);
- currentId = folder.parentId;
- }
- folderPathMap[folderId] = `/${pathSegments.join("/")}`;
- }
- }
-
// Group accounts by resource ID
- const accountsByResourceId = new Map<string, Array<{ accountName: string; accountPath: string }>>();
+ const accountsByResourceId = new Map<string, Array<{ accountName: string }>>();
for (const account of allAccounts) {
- const accountPath = account.folderId ? folderPathMap[account.folderId] || "/" : "/";
const existing = accountsByResourceId.get(account.resourceId) || [];
- existing.push({ accountName: account.name, accountPath });
+ existing.push({ accountName: account.name });
accountsByResourceId.set(account.resourceId, existing);
}
@@ -426,8 +378,7 @@ export const pamResourceServiceFactory = ({
ProjectPermissionPamAccountActions.Read,
subject(ProjectPermissionSub.PamAccounts, {
resourceName: resource.name,
- accountName: account.accountName,
- accountPath: account.accountPath
+ accountName: account.accountName
})
)
);
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 55a6b58260..b7ec652333 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -2552,7 +2552,6 @@ export const registerRoutes = async (
const pamResourceService = pamResourceServiceFactory({
pamResourceDAL,
pamAccountDAL,
- pamFolderDAL,
permissionService,
kmsService,
gatewayV2Service
@@ -2574,7 +2573,6 @@ export const registerRoutes = async (
pamAccountDAL,
gatewayV2Service,
kmsService,
- pamFolderDAL,
pamResourceDAL,
pamSessionDAL,
permissionService,
diff --git a/frontend/src/hooks/api/pam/queries.tsx b/frontend/src/hooks/api/pam/queries.tsx
index 1ed5dc6de1..3e73329eae 100644
--- a/frontend/src/hooks/api/pam/queries.tsx
+++ b/frontend/src/hooks/api/pam/queries.tsx
@@ -8,7 +8,6 @@ import {
TListPamAccountsDTO,
TListPamResourcesDTO,
TPamAccount,
- TPamFolder,
TPamResource,
TPamSession
} from "./types";
@@ -123,10 +122,7 @@ export const useGetPamResourceById = (
// Accounts
type TListPamAccountsResponse = {
accounts: TPamAccount[];
- folders: TPamFolder[];
totalCount: number;
- folderId?: string;
- folderPaths: Record<string, string>;
};
export const useListPamAccounts = (
diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.ts
index f8b14e7962..f6f006d7c5 100644
--- a/frontend/src/hooks/api/pam/types/index.ts
+++ b/frontend/src/hooks/api/pam/types/index.ts
@@ -135,7 +135,6 @@ export type TDeletePamResourceDTO = {
// Account DTOs
export type TListPamAccountsDTO = {
projectId: string;
- accountPath?: string | null;
accountView?: PamAccountView;
offset?: number;
limit?: number;
diff --git a/frontend/src/pages/pam/ApprovalsPage/components/ApprovalRequestTab/ApprovalRequestTab.tsx b/frontend/src/pages/pam/ApprovalsPage/components/ApprovalRequestTab/ApprovalRequestTab.tsx
index 258d49e684..22839b463d 100644
--- a/frontend/src/pages/pam/ApprovalsPage/components/ApprovalRequestTab/ApprovalRequestTab.tsx
+++ b/frontend/src/pages/pam/ApprovalsPage/components/ApprovalRequestTab/ApprovalRequestTab.tsx
@@ -278,6 +278,7 @@ export const ApprovalRequestTab = () => {
<THead>
<Tr>
<Th>Requester</Th>
+ <Th>Resource</Th>
<Th>Account</Th>
<Th>Access Duration</Th>
<Th>Status</Th>
@@ -285,7 +286,7 @@ export const ApprovalRequestTab = () => {
</Tr>
</THead>
<TBody>
- {isRequestsLoading && <TableSkeleton columns={5} innerKey="approval-requests" />}
+ {isRequestsLoading && <TableSkeleton columns={6} innerKey="approval-requests" />}
{!isRequestsLoading &&
paginatedRequests.map((request) => {
const needsApproval = checkIfUserNeedsToApprove(request, userId, userGroups);
@@ -307,18 +308,10 @@ export const ApprovalRequestTab = () => {
</div>
</Td>
<Td>
- <div className="space-y-0.5">
- {resourceName && (
- <div className="text-sm text-mineshaft-200">
- <span className="text-mineshaft-400">Resource:</span> {resourceName}
- </div>
- )}
- {accountName && (
- <div className="text-sm text-mineshaft-200">
- <span className="text-mineshaft-400">Account:</span> {accountName}
- </div>
- )}
- </div>
+ <span className="text-sm text-mineshaft-200">{resourceName || "-"}</span>
+ </Td>
+ <Td>
+ <span className="text-sm text-mineshaft-200">{accountName || "-"}</span>
</Td>
<Td>
<span className="text-sm text-mineshaft-200">{accessDuration}</span>
diff --git a/frontend/src/pages/pam/ApprovalsPage/components/PolicyTab/components/PolicySchema.tsx b/frontend/src/pages/pam/ApprovalsPage/components/PolicyTab/components/PolicySchema.tsx
index 9d22cd8a35..d06866499a 100644
--- a/frontend/src/pages/pam/ApprovalsPage/components/PolicyTab/components/PolicySchema.tsx
+++ b/frontend/src/pages/pam/ApprovalsPage/components/PolicyTab/components/PolicySchema.tsx
@@ -28,17 +28,18 @@ export const PolicyFormSchema = z.object({
resourceNames: z.string().array().optional(),
accountNames: z.string().array().optional()
})
- .refine(
- (data) => {
- // At least one condition type must be provided
- const hasResourceNames = data.resourceNames && data.resourceNames.length > 0;
- const hasAccountNames = data.accountNames && data.accountNames.length > 0;
- return hasResourceNames || hasAccountNames;
- },
- {
- message: "At least one condition type must be provided (Resource Names or Account Names)"
+ .superRefine((data, ctx) => {
+ // At least one condition type must be provided
+ const hasResourceNames = data.resourceNames && data.resourceNames.length > 0;
+ const hasAccountNames = data.accountNames && data.accountNames.length > 0;
+ if (!hasResourceNames && !hasAccountNames) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: "At least one condition type must be provided (Resource Names or Account Names)",
+ path: ["resourceNames"]
+ });
}
- )
+ })
.array()
.min(1, "At least one condition is required"),
constraints: z.object({
diff --git a/frontend/src/pages/pam/ApprovalsPage/components/PolicyTab/components/PolicySteps/PolicyDetailsStep.tsx b/frontend/src/pages/pam/ApprovalsPage/components/PolicyTab/components/PolicySteps/PolicyDetailsStep.tsx
index 6ea9ef9fab..e889d0da6e 100644
--- a/frontend/src/pages/pam/ApprovalsPage/components/PolicyTab/components/PolicySteps/PolicyDetailsStep.tsx
+++ b/frontend/src/pages/pam/ApprovalsPage/components/PolicyTab/components/PolicySteps/PolicyDetailsStep.tsx
@@ -6,7 +6,7 @@ import { FormControl, Input } from "@app/components/v2";
import { TPolicyForm } from "../PolicySchema";
export const PolicyDetailsStep = () => {
- const { control, formState } = useFormContext<TPolicyForm>();
+ const { control } = useFormContext<TPolicyForm>();
return (
<div className="flex flex-col gap-4">
@@ -51,7 +51,7 @@ export const PolicyDetailsStep = () => {
className="mb-0"
label="Resource Names"
isError={Boolean(error)}
- errorText={error?.message ?? (formState.errors.conditions as any)?.[0]?.message}
+ errorText={error?.message}
helperText="Match accounts on resources with these names (supports glob patterns)"
>
<Input
diff --git a/frontend/src/pages/pam/ApprovalsPage/components/RequestGrantTab/RequestGrantTab.tsx b/frontend/src/pages/pam/ApprovalsPage/components/RequestGrantTab/RequestGrantTab.tsx
index 5fbb59a095..694587ff36 100644
--- a/frontend/src/pages/pam/ApprovalsPage/components/RequestGrantTab/RequestGrantTab.tsx
+++ b/frontend/src/pages/pam/ApprovalsPage/components/RequestGrantTab/RequestGrantTab.tsx
@@ -275,6 +275,7 @@ export const RequestGrantTab = () => {
<THead>
<Tr>
<Th>User</Th>
+ <Th>Resource</Th>
<Th>Account</Th>
<Th>Access Duration</Th>
<Th>Status</Th>
@@ -284,7 +285,7 @@ export const RequestGrantTab = () => {
</Tr>
</THead>
<TBody>
- {isGrantsLoading && <TableSkeleton columns={7} innerKey="access-grants" />}
+ {isGrantsLoading && <TableSkeleton columns={8} innerKey="access-grants" />}
{!isGrantsLoading &&
paginatedGrants.map((grant) => {
if (grant.type !== ApprovalPolicyType.PamAccess) return null;
@@ -296,20 +297,14 @@ export const RequestGrantTab = () => {
{grant.granteeUserId ? getGrantedUser(grant.granteeUserId) : "Unknown"}
</Td>
<Td>
- <div className="space-y-0.5">
- {grant.attributes.resourceName && (
- <div className="text-sm text-mineshaft-200">
- <span className="text-mineshaft-400">Resource:</span>{" "}
- {grant.attributes.resourceName}
- </div>
- )}
- {grant.attributes.accountName && (
- <div className="text-sm text-mineshaft-200">
- <span className="text-mineshaft-400">Account:</span>{" "}
- {grant.attributes.accountName}
- </div>
- )}
- </div>
+ <span className="text-sm text-mineshaft-200">
+ {grant.attributes.resourceName || "-"}
+ </span>
+ </Td>
+ <Td>
+ <span className="text-sm text-mineshaft-200">
+ {grant.attributes.accountName || "-"}
+ </span>
</Td>
<Td>
<span className="text-sm text-mineshaft-200">