From f85a35fde8a28102d027e986a5533f2f1e096779 Mon Sep 17 00:00:00 2001 From: ShubhamPalriwala Date: Tue, 28 May 2024 23:40:50 +0530 Subject: [PATCH] feat: move feature to org level --- .../ee/services/permission/org-permission.ts | 10 +++++ .../services/permission/project-permission.ts | 11 ----- backend/src/server/routes/index.ts | 3 +- .../server/routes/v1/secret-sharing-router.ts | 22 ++++------ .../secret-sharing/secret-sharing-service.ts | 40 +++++-------------- .../secret-sharing/secret-sharing-types.ts | 2 +- .../src/context/OrgPermissionContext/types.ts | 2 + .../src/hooks/api/secretSharing/mutations.ts | 6 +-- .../src/hooks/api/secretSharing/queries.ts | 4 +- frontend/src/hooks/api/secretSharing/types.ts | 2 - frontend/src/layouts/AppLayout/AppLayout.tsx | 24 +++++------ .../[id]/secret-sharing/index.tsx | 0 .../components/AddShareSecretModal.tsx | 7 ++-- .../components/ShareSecretSection.tsx | 26 +++++------- .../components/ShareSecretsRow.tsx | 12 +++--- .../components/ShareSecretsTable.tsx | 5 +-- 16 files changed, 71 insertions(+), 105 deletions(-) rename frontend/src/pages/{project => org}/[id]/secret-sharing/index.tsx (100%) diff --git a/backend/src/ee/services/permission/org-permission.ts b/backend/src/ee/services/permission/org-permission.ts index 9fece040b..d76406cfd 100644 --- a/backend/src/ee/services/permission/org-permission.ts +++ b/backend/src/ee/services/permission/org-permission.ts @@ -21,6 +21,7 @@ export enum OrgPermissionSubjects { Groups = "groups", Billing = "billing", SecretScanning = "secret-scanning", + SecretSharing = "secret-sharing", Identity = "identity" } @@ -36,6 +37,7 @@ export type OrgPermissionSet = | [OrgPermissionActions, OrgPermissionSubjects.Ldap] | [OrgPermissionActions, OrgPermissionSubjects.Groups] | [OrgPermissionActions, OrgPermissionSubjects.SecretScanning] + | [OrgPermissionActions, OrgPermissionSubjects.SecretSharing] | [OrgPermissionActions, OrgPermissionSubjects.Billing] | [OrgPermissionActions, OrgPermissionSubjects.Identity]; @@ -60,6 +62,10 @@ const buildAdminPermission = () => { can(OrgPermissionActions.Edit, OrgPermissionSubjects.SecretScanning); can(OrgPermissionActions.Delete, OrgPermissionSubjects.SecretScanning); + can(OrgPermissionActions.Read, OrgPermissionSubjects.SecretSharing); + can(OrgPermissionActions.Create, OrgPermissionSubjects.SecretSharing); + can(OrgPermissionActions.Delete, OrgPermissionSubjects.SecretSharing); + can(OrgPermissionActions.Read, OrgPermissionSubjects.Settings); can(OrgPermissionActions.Create, OrgPermissionSubjects.Settings); can(OrgPermissionActions.Edit, OrgPermissionSubjects.Settings); @@ -124,6 +130,10 @@ const buildMemberPermission = () => { can(OrgPermissionActions.Edit, OrgPermissionSubjects.SecretScanning); can(OrgPermissionActions.Delete, OrgPermissionSubjects.SecretScanning); + can(OrgPermissionActions.Read, OrgPermissionSubjects.SecretSharing); + can(OrgPermissionActions.Create, OrgPermissionSubjects.SecretSharing); + can(OrgPermissionActions.Delete, OrgPermissionSubjects.SecretSharing); + can(OrgPermissionActions.Read, OrgPermissionSubjects.Identity); can(OrgPermissionActions.Create, OrgPermissionSubjects.Identity); can(OrgPermissionActions.Edit, OrgPermissionSubjects.Identity); diff --git a/backend/src/ee/services/permission/project-permission.ts b/backend/src/ee/services/permission/project-permission.ts index 8deb6f57e..b24024bd4 100644 --- a/backend/src/ee/services/permission/project-permission.ts +++ b/backend/src/ee/services/permission/project-permission.ts @@ -26,7 +26,6 @@ export enum ProjectPermissionSub { SecretRollback = "secret-rollback", SecretApproval = "secret-approval", SecretRotation = "secret-rotation", - SecretSharing = "secret-sharing", Identity = "identity" } @@ -53,7 +52,6 @@ export type ProjectPermissionSet = | [ProjectPermissionActions, ProjectPermissionSub.ServiceTokens] | [ProjectPermissionActions, ProjectPermissionSub.SecretApproval] | [ProjectPermissionActions, ProjectPermissionSub.SecretRotation] - | [ProjectPermissionActions, ProjectPermissionSub.SecretSharing] | [ProjectPermissionActions, ProjectPermissionSub.Identity] | [ProjectPermissionActions.Delete, ProjectPermissionSub.Project] | [ProjectPermissionActions.Edit, ProjectPermissionSub.Project] @@ -73,10 +71,6 @@ const buildAdminPermissionRules = () => { can(ProjectPermissionActions.Edit, ProjectPermissionSub.SecretApproval); can(ProjectPermissionActions.Delete, ProjectPermissionSub.SecretApproval); - can(ProjectPermissionActions.Read, ProjectPermissionSub.SecretSharing); - can(ProjectPermissionActions.Create, ProjectPermissionSub.SecretSharing); - can(ProjectPermissionActions.Delete, ProjectPermissionSub.SecretSharing); - can(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRotation); can(ProjectPermissionActions.Create, ProjectPermissionSub.SecretRotation); can(ProjectPermissionActions.Edit, ProjectPermissionSub.SecretRotation); @@ -164,10 +158,6 @@ const buildMemberPermissionRules = () => { can(ProjectPermissionActions.Read, ProjectPermissionSub.SecretApproval); can(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRotation); - can(ProjectPermissionActions.Read, ProjectPermissionSub.SecretSharing); - can(ProjectPermissionActions.Create, ProjectPermissionSub.SecretSharing); - can(ProjectPermissionActions.Delete, ProjectPermissionSub.SecretSharing); - can(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRollback); can(ProjectPermissionActions.Create, ProjectPermissionSub.SecretRollback); @@ -227,7 +217,6 @@ const buildViewerPermissionRules = () => { can(ProjectPermissionActions.Read, ProjectPermissionSub.SecretApproval); can(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRollback); can(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRotation); - can(ProjectPermissionActions.Read, ProjectPermissionSub.SecretSharing); can(ProjectPermissionActions.Read, ProjectPermissionSub.Member); can(ProjectPermissionActions.Read, ProjectPermissionSub.Groups); can(ProjectPermissionActions.Read, ProjectPermissionSub.Role); diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts index f8855d11f..582f70d5a 100644 --- a/backend/src/server/routes/index.ts +++ b/backend/src/server/routes/index.ts @@ -201,8 +201,6 @@ export const registerRoutes = async ( const secretVersionTagDAL = secretVersionTagDALFactory(db); const secretBlindIndexDAL = secretBlindIndexDALFactory(db); - const secretSharingDAL = secretSharingDALFactory(db); - const integrationDAL = integrationDALFactory(db); const integrationAuthDAL = integrationAuthDALFactory(db); const webhookDAL = webhookDALFactory(db); @@ -257,6 +255,7 @@ export const registerRoutes = async ( const groupProjectMembershipRoleDAL = groupProjectMembershipRoleDALFactory(db); const userGroupMembershipDAL = userGroupMembershipDALFactory(db); const secretScanningDAL = secretScanningDALFactory(db); + const secretSharingDAL = secretSharingDALFactory(db); const licenseDAL = licenseDALFactory(db); const dynamicSecretDAL = dynamicSecretDALFactory(db); const dynamicSecretLeaseDAL = dynamicSecretLeaseDALFactory(db); diff --git a/backend/src/server/routes/v1/secret-sharing-router.ts b/backend/src/server/routes/v1/secret-sharing-router.ts index 6a7f95565..f5f47d345 100644 --- a/backend/src/server/routes/v1/secret-sharing-router.ts +++ b/backend/src/server/routes/v1/secret-sharing-router.ts @@ -8,25 +8,21 @@ import { AuthMode } from "@app/services/auth/auth-type"; export const registerSecretSharingRouter = async (server: FastifyZodProvider) => { server.route({ method: "GET", - url: "/:projectId", + url: "/", config: { rateLimit: readLimit }, schema: { - params: z.object({ - projectId: z.string().uuid() - }), response: { 200: z.array(SecretSharingSchema) } }, onRequest: verifyAuth([AuthMode.JWT]), handler: async (req) => { - const { projectId } = req.params; const sharedSecrets = await req.server.services.secretSharing.getSharedSecrets({ actor: req.permission.type, actorId: req.permission.id, - projectId, + orgId: req.permission.orgId, actorAuthMethod: req.permission.authMethod, actorOrgId: req.permission.orgId }); @@ -72,8 +68,7 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) => signedValue: z.string(), expiresAt: z.string().refine((date) => new Date(date) > new Date(), { message: "Expires at should be a future date" - }), - workspaceId: z.string().uuid() + }) }), response: { 200: z.object({ @@ -83,11 +78,11 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) => }, onRequest: verifyAuth([AuthMode.JWT]), handler: async (req) => { - const { name, signedValue, expiresAt, workspaceId } = req.body; + const { name, signedValue, expiresAt } = req.body; const sharedSecret = await req.server.services.secretSharing.createSharedSecret({ actor: req.permission.type, actorId: req.permission.id, - projectId: workspaceId, + orgId: req.permission.orgId, actorAuthMethod: req.permission.authMethod, actorOrgId: req.permission.orgId, name, @@ -100,13 +95,12 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) => server.route({ method: "DELETE", - url: "/:projectId/:sharedSecretId", + url: "/:sharedSecretId", config: { rateLimit: writeLimit }, schema: { params: z.object({ - projectId: z.string().uuid(), sharedSecretId: z.string().uuid() }), response: { @@ -115,11 +109,11 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) => }, onRequest: verifyAuth([AuthMode.JWT]), handler: async (req) => { - const { projectId, sharedSecretId } = req.params; + const { sharedSecretId } = req.params; const deletedSharedSecret = await req.server.services.secretSharing.deleteSharedSecretById({ actor: req.permission.type, actorId: req.permission.id, - projectId, + orgId: req.permission.orgId, actorAuthMethod: req.permission.authMethod, actorOrgId: req.permission.orgId, sharedSecretId diff --git a/backend/src/services/secret-sharing/secret-sharing-service.ts b/backend/src/services/secret-sharing/secret-sharing-service.ts index 7fdc8f6aa..a4952586a 100644 --- a/backend/src/services/secret-sharing/secret-sharing-service.ts +++ b/backend/src/services/secret-sharing/secret-sharing-service.ts @@ -1,13 +1,13 @@ import { ForbiddenError } from "@casl/ability"; +import { OrgPermissionActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission"; import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service"; -import { ProjectPermissionActions, ProjectPermissionSub } from "@app/ee/services/permission/project-permission"; import { TSecretSharingDALFactory } from "./secret-sharing-dal"; import { TCreateSharedSecretDTO, TDeleteSharedSecretDTO, TSharedSecretPermission } from "./secret-sharing-types"; type TSecretSharingServiceFactoryDep = { - permissionService: Pick; + permissionService: Pick; secretSharingDAL: TSecretSharingDALFactory; }; @@ -18,16 +18,10 @@ export const secretSharingServiceFactory = ({ secretSharingDAL }: TSecretSharingServiceFactoryDep) => { const createSharedSecret = async (createSharedSecretInput: TCreateSharedSecretDTO) => { - const { actor, actorId, projectId, actorAuthMethod, actorOrgId, name, signedValue, expiresAt } = + const { actor, actorId, orgId, actorAuthMethod, actorOrgId, name, signedValue, expiresAt } = createSharedSecretInput; - const { permission } = await permissionService.getProjectPermission( - actor, - actorId, - projectId, - actorAuthMethod, - actorOrgId - ); - ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.SecretSharing); + const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId); + ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.SecretSharing); const newSharedSecret = await secretSharingDAL.create({ name, signedValue, @@ -38,15 +32,9 @@ export const secretSharingServiceFactory = ({ }; const getSharedSecrets = async (getSharedSecretsInput: TSharedSecretPermission) => { - const { actor, actorId, projectId, actorAuthMethod, actorOrgId } = getSharedSecretsInput; - const { permission } = await permissionService.getProjectPermission( - actor, - actorId, - projectId, - actorAuthMethod, - actorOrgId - ); - ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretSharing); + const { actor, actorId, orgId, actorAuthMethod, actorOrgId } = getSharedSecretsInput; + const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId); + ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.SecretSharing); const userSharedSecrets = await secretSharingDAL.find({ userId: actorId }, { sort: [["expiresAt", "asc"]] }); return userSharedSecrets; }; @@ -60,15 +48,9 @@ export const secretSharingServiceFactory = ({ }; const deleteSharedSecretById = async (deleteSharedSecretInput: TDeleteSharedSecretDTO) => { - const { actor, actorId, projectId, actorAuthMethod, actorOrgId, sharedSecretId } = deleteSharedSecretInput; - const { permission } = await permissionService.getProjectPermission( - actor, - actorId, - projectId, - actorAuthMethod, - actorOrgId - ); - ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.SecretSharing); + const { actor, actorId, orgId, actorAuthMethod, actorOrgId, sharedSecretId } = deleteSharedSecretInput; + const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId); + ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.SecretSharing); const deletedSharedSecret = await secretSharingDAL.deleteById(sharedSecretId); return deletedSharedSecret; }; diff --git a/backend/src/services/secret-sharing/secret-sharing-types.ts b/backend/src/services/secret-sharing/secret-sharing-types.ts index c08f42612..643aec230 100644 --- a/backend/src/services/secret-sharing/secret-sharing-types.ts +++ b/backend/src/services/secret-sharing/secret-sharing-types.ts @@ -5,7 +5,7 @@ export type TSharedSecretPermission = { actorId: string; actorAuthMethod: ActorAuthMethod; actorOrgId: string; - projectId: string; + orgId: string; }; export type TCreateSharedSecretDTO = { diff --git a/frontend/src/context/OrgPermissionContext/types.ts b/frontend/src/context/OrgPermissionContext/types.ts index 95a9d00ac..d51191ece 100644 --- a/frontend/src/context/OrgPermissionContext/types.ts +++ b/frontend/src/context/OrgPermissionContext/types.ts @@ -19,6 +19,7 @@ export enum OrgPermissionSubjects { Groups = "groups", Billing = "billing", SecretScanning = "secret-scanning", + SecretSharing = "secret-sharing", Identity = "identity" } @@ -34,6 +35,7 @@ export type OrgPermissionSet = | [OrgPermissionActions, OrgPermissionSubjects.Ldap] | [OrgPermissionActions, OrgPermissionSubjects.Groups] | [OrgPermissionActions, OrgPermissionSubjects.SecretScanning] + | [OrgPermissionActions, OrgPermissionSubjects.SecretSharing] | [OrgPermissionActions, OrgPermissionSubjects.Billing] | [OrgPermissionActions, OrgPermissionSubjects.Identity]; diff --git a/frontend/src/hooks/api/secretSharing/mutations.ts b/frontend/src/hooks/api/secretSharing/mutations.ts index a3566282c..e21cc08f6 100644 --- a/frontend/src/hooks/api/secretSharing/mutations.ts +++ b/frontend/src/hooks/api/secretSharing/mutations.ts @@ -20,11 +20,11 @@ export const useDeleteSharedSecret = () => { return useMutation< TSharedSecret, { message: string }, - { sharedSecretId: string; workspaceId: string } + { sharedSecretId: string } >({ - mutationFn: async ({ sharedSecretId, workspaceId }: TDeleteSharedSecretRequest) => { + mutationFn: async ({ sharedSecretId }: TDeleteSharedSecretRequest) => { const { data } = await apiRequest.delete( - `/api/v1/secret-sharing/${workspaceId}/${sharedSecretId}` + `/api/v1/secret-sharing/${sharedSecretId}` ); return data; }, diff --git a/frontend/src/hooks/api/secretSharing/queries.ts b/frontend/src/hooks/api/secretSharing/queries.ts index 33ffddfbc..ad5bbee74 100644 --- a/frontend/src/hooks/api/secretSharing/queries.ts +++ b/frontend/src/hooks/api/secretSharing/queries.ts @@ -4,12 +4,12 @@ import { apiRequest } from "@app/config/request"; import { TSharedSecret, TViewSharedSecretResponse } from "./types"; -export const useGetSharedSecrets = (workspaceId: string) => { +export const useGetSharedSecrets = () => { return useQuery({ queryKey: ["sharedSecrets"], queryFn: async () => { const { data } = await apiRequest.get( - `/api/v1/secret-sharing/${workspaceId}` + "/api/v1/secret-sharing/" ); return data; } diff --git a/frontend/src/hooks/api/secretSharing/types.ts b/frontend/src/hooks/api/secretSharing/types.ts index 6afbe34ea..ca9cb76b8 100644 --- a/frontend/src/hooks/api/secretSharing/types.ts +++ b/frontend/src/hooks/api/secretSharing/types.ts @@ -12,7 +12,6 @@ export type TCreateSharedSecretRequest = { name: string; signedValue: string; expiresAt: Date; - workspaceId: string; }; export type TViewSharedSecretResponse = { @@ -23,5 +22,4 @@ export type TViewSharedSecretResponse = { export type TDeleteSharedSecretRequest = { sharedSecretId: string; - workspaceId: string; }; diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsx index 60c31b72c..1b5df0037 100644 --- a/frontend/src/layouts/AppLayout/AppLayout.tsx +++ b/frontend/src/layouts/AppLayout/AppLayout.tsx @@ -531,18 +531,6 @@ export const AppLayout = ({ children }: LayoutProps) => { - - - - Secret Sharing - - - { + + + + Secret Sharing + + + {(window.location.origin.includes("https://app.infisical.com") || window.location.origin.includes("https://gamma.infisical.com")) && ( diff --git a/frontend/src/pages/project/[id]/secret-sharing/index.tsx b/frontend/src/pages/org/[id]/secret-sharing/index.tsx similarity index 100% rename from frontend/src/pages/project/[id]/secret-sharing/index.tsx rename to frontend/src/pages/org/[id]/secret-sharing/index.tsx diff --git a/frontend/src/views/ShareSecretPage/components/AddShareSecretModal.tsx b/frontend/src/views/ShareSecretPage/components/AddShareSecretModal.tsx index cb4c32866..4ffe1408a 100644 --- a/frontend/src/views/ShareSecretPage/components/AddShareSecretModal.tsx +++ b/frontend/src/views/ShareSecretPage/components/AddShareSecretModal.tsx @@ -22,7 +22,7 @@ import { Select, SelectItem } from "@app/components/v2"; -import { useWorkspace } from "@app/context"; +import { useOrganization } from "@app/context"; import { useToggle } from "@app/hooks"; import { useCreateSharedSecret } from "@app/hooks/api/secretSharing"; import { UsePopUpState } from "@app/hooks/usePopUp"; @@ -87,7 +87,7 @@ export const AddShareSecretModal = ({ popUp, handlePopUpToggle }: Props) => { resolver: yupResolver(schema) }); const createSharedSecret = useCreateSharedSecret(); - const { currentWorkspace } = useWorkspace(); + const { currentOrg } = useOrganization(); const [newSharedSecret, setnewSharedSecret] = useState(""); const [isUrlCopied, setIsUrlCopied] = useToggle(false); const hasSharedSecret = Boolean(newSharedSecret); @@ -108,7 +108,7 @@ export const AddShareSecretModal = ({ popUp, handlePopUpToggle }: Props) => { const onFormSubmit = async ({ name, value, expiresInValue, expiresInUnit }: FormData) => { try { - if (!currentWorkspace?.id) return; + if (!currentOrg?.id) return; const signingKeyPair = generateSignKeyPair(); const signedMessage = signAssymmetric({ @@ -128,7 +128,6 @@ export const AddShareSecretModal = ({ popUp, handlePopUpToggle }: Props) => { name, signedValue: signedMessage, expiresAt, - workspaceId: currentWorkspace.id }); setnewSharedSecret( `${window.location.origin}/shared/secret/${id}?key=${encodeURIComponent( diff --git a/frontend/src/views/ShareSecretPage/components/ShareSecretSection.tsx b/frontend/src/views/ShareSecretPage/components/ShareSecretSection.tsx index 971b77261..e7311ee85 100644 --- a/frontend/src/views/ShareSecretPage/components/ShareSecretSection.tsx +++ b/frontend/src/views/ShareSecretPage/components/ShareSecretSection.tsx @@ -3,10 +3,10 @@ import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { createNotification } from "@app/components/notifications"; -import { ProjectPermissionCan } from "@app/components/permissions"; +import { OrgPermissionCan } from "@app/components/permissions"; import { Button, Checkbox, DeleteActionModal } from "@app/components/v2"; -import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; -import { withProjectPermission } from "@app/hoc"; +import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context"; +import { withPermission } from "@app/hoc"; import { usePopUp } from "@app/hooks"; import { useDeleteSharedSecret } from "@app/hooks/api/secretSharing"; @@ -15,9 +15,8 @@ import { ShareSecretsTable } from "./ShareSecretsTable"; type DeleteModalData = { name: string; id: string }; -export const ShareSecretSection = withProjectPermission( +export const ShareSecretSection = withPermission( () => { - const { currentWorkspace } = useWorkspace(); const deleteSharedSecret = useDeleteSharedSecret(); const [showExpiredSharedSecrets, setShowExpiredSharedSecrets] = useState(false); @@ -28,10 +27,8 @@ export const ShareSecretSection = withProjectPermission( const onDeleteApproved = async () => { try { - if (!currentWorkspace?.id) return; deleteSharedSecret.mutateAsync({ sharedSecretId: (popUp?.deleteSharedSecretConfirmation?.data as DeleteModalData)?.id, - workspaceId: currentWorkspace.id }); createNotification({ text: "Successfully deleted shared secret", @@ -52,9 +49,9 @@ export const ShareSecretSection = withProjectPermission(

Shared Secrets

- {(isAllowed) => (

@@ -93,9 +90,8 @@ export const ShareSecretSection = withProjectPermission( handlePopUpToggle("deleteSharedSecretConfirmation", isOpen)} deleteKey={(popUp?.deleteSharedSecretConfirmation?.data as DeleteModalData)?.name} onClose={() => handlePopUpClose("deleteSharedSecretConfirmation")} @@ -104,5 +100,5 @@ export const ShareSecretSection = withProjectPermission(

); }, - { action: ProjectPermissionActions.Read, subject: ProjectPermissionSub.SecretSharing } + { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.SecretSharing } ); diff --git a/frontend/src/views/ShareSecretPage/components/ShareSecretsRow.tsx b/frontend/src/views/ShareSecretPage/components/ShareSecretsRow.tsx index 8d3b89f23..e4a104f69 100644 --- a/frontend/src/views/ShareSecretPage/components/ShareSecretsRow.tsx +++ b/frontend/src/views/ShareSecretPage/components/ShareSecretsRow.tsx @@ -2,9 +2,9 @@ import { useEffect, useState } from "react"; import { faTrashCan } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { ProjectPermissionCan } from "@app/components/permissions"; +import { OrgPermissionCan } from "@app/components/permissions"; import { IconButton, Td, Tr } from "@app/components/v2"; -import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context"; +import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context"; import { TSharedSecret } from "@app/hooks/api/secretSharing"; import { UsePopUpState } from "@app/hooks/usePopUp"; @@ -110,9 +110,9 @@ export const ShareSecretsRow = ({

{formatDate(row.expiresAt)}

- {(isAllowed) => ( )} - + ); diff --git a/frontend/src/views/ShareSecretPage/components/ShareSecretsTable.tsx b/frontend/src/views/ShareSecretPage/components/ShareSecretsTable.tsx index eac3435e3..4d3321eaa 100644 --- a/frontend/src/views/ShareSecretPage/components/ShareSecretsTable.tsx +++ b/frontend/src/views/ShareSecretPage/components/ShareSecretsTable.tsx @@ -12,7 +12,6 @@ import { THead, Tr } from "@app/components/v2"; -import { useWorkspace } from "@app/context"; import { TSharedSecret, useGetSharedSecrets } from "@app/hooks/api/secretSharing"; import { UsePopUpState } from "@app/hooks/usePopUp"; @@ -34,9 +33,7 @@ type Props = { export const ShareSecretsTable = ({ handlePopUpOpen, showExpiredSharedSecrets }: Props) => { const [tableData, setTableData] = useState([]); - const { currentWorkspace } = useWorkspace(); - const workspaceId = currentWorkspace?.id || ""; - const { isLoading, data = [] } = useGetSharedSecrets(workspaceId); + const { isLoading, data = [] } = useGetSharedSecrets(); useEffect(() => { if (!isLoading) {