Skip to content

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

requested changes

Daniel Hougaard787c0919488d
diff --git a/backend/src/server/routes/v1/secret-requests-router.ts b/backend/src/server/routes/v1/secret-requests-router.ts
index f3197a7629..a1e4eafc2b 100644
--- a/backend/src/server/routes/v1/secret-requests-router.ts
+++ b/backend/src/server/routes/v1/secret-requests-router.ts
@@ -44,7 +44,6 @@ export const registerSecretRequestsRouter = async (server: FastifyZodProvider) =
const secretRequest = await req.server.services.secretSharing.getSecretRequestById({
id: req.params.id,
actorOrgId: req.permission?.orgId,
- orgId: req.permission?.orgId,
actor: req.permission?.type,
actorId: req.permission?.id,
actorAuthMethod: req.permission?.authMethod
@@ -82,7 +81,6 @@ export const registerSecretRequestsRouter = async (server: FastifyZodProvider) =
const secretRequest = await req.server.services.secretSharing.setSecretRequestValue({
id: req.params.id,
actorOrgId: req.permission?.orgId,
- orgId: req.permission?.orgId,
actor: req.permission?.type,
actorId: req.permission?.id,
actorAuthMethod: req.permission?.authMethod,
diff --git a/backend/src/services/secret-sharing/secret-sharing-dal.ts b/backend/src/services/secret-sharing/secret-sharing-dal.ts
index a17e37923a..7cdccd4f89 100644
--- a/backend/src/services/secret-sharing/secret-sharing-dal.ts
+++ b/backend/src/services/secret-sharing/secret-sharing-dal.ts
@@ -2,7 +2,7 @@ import { Knex } from "knex";
import { TDbClient } from "@app/db";
import { TableName, TSecretSharing } from "@app/db/schemas";
-import { DatabaseError } from "@app/lib/errors";
+import { DatabaseError, NotFoundError } from "@app/lib/errors";
import { ormify, selectAllTableCols } from "@app/lib/knex";
import { logger } from "@app/lib/logger";
import { QueueName } from "@app/queue";
@@ -32,10 +32,8 @@ export const secretSharingDALFactory = (db: TDbClient) => {
.first();
if (!secretRequest) {
- throw new DatabaseError({
- error: new Error("Get Secret Request By Id, Not found"),
- message: "Get Secret Request By Id, Not found",
- name: "GetSecretRequestById"
+ throw new NotFoundError({
+ message: `Secret request with ID '${id}' not found`
});
}
diff --git a/backend/src/services/secret-sharing/secret-sharing-service.ts b/backend/src/services/secret-sharing/secret-sharing-service.ts
index 45ca9bb2ae..1ce7acf44e 100644
--- a/backend/src/services/secret-sharing/secret-sharing-service.ts
+++ b/backend/src/services/secret-sharing/secret-sharing-service.ts
@@ -176,7 +176,6 @@ export const secretSharingServiceFactory = ({
id,
actor,
actorId,
- orgId,
actorAuthMethod,
actorOrgId
}: TGetSecretRequestByIdDTO) => {
@@ -187,22 +186,22 @@ export const secretSharingServiceFactory = ({
}
if (secretRequest.accessType === SecretSharingAccessType.Organization) {
- if (orgId === undefined) {
+ if (!secretRequest.orgId) {
+ throw new BadRequestError({ message: "No organization ID present on secret request" });
+ }
+
+ if (!actorOrgId) {
throw new UnauthorizedError();
}
const { permission } = await permissionService.getOrgPermission(
actor,
actorId,
- orgId,
+ secretRequest.orgId,
actorAuthMethod,
actorOrgId
);
if (!permission) throw new ForbiddenRequestError({ name: "User is not a part of the specified organization" });
-
- if (secretRequest.orgId !== orgId) {
- throw new ForbiddenRequestError({ name: "User does not have permission to access this secret request" });
- }
}
if (secretRequest.expiresAt && secretRequest.expiresAt < new Date()) {
@@ -221,7 +220,6 @@ export const secretSharingServiceFactory = ({
id,
actor,
actorId,
- orgId,
actorAuthMethod,
actorOrgId,
secretValue
@@ -237,23 +235,23 @@ export const secretSharingServiceFactory = ({
let respondentUsername: string | undefined;
if (secretRequest.accessType === SecretSharingAccessType.Organization) {
+ if (!secretRequest.orgId) {
+ throw new BadRequestError({ message: "No organization ID present on secret request" });
+ }
+
+ if (!actorOrgId) {
+ throw new UnauthorizedError();
+ }
+
const { permission } = await permissionService.getOrgPermission(
actor,
actorId,
- orgId,
+ secretRequest.orgId,
actorAuthMethod,
actorOrgId
);
if (!permission) throw new ForbiddenRequestError({ name: "User is not a part of the specified organization" });
- if (!orgId) {
- throw new UnauthorizedError();
- }
-
- if (secretRequest.orgId !== orgId) {
- throw new ForbiddenRequestError({ name: "User does not have permission to access this secret request" });
- }
-
const user = await userDAL.findById(actorId);
if (!user) {
@@ -478,8 +476,14 @@ export const secretSharingServiceFactory = ({
? await secretSharingDAL.findOne({ id: sharedSecretId, type: deleteSharedSecretInput.type })
: await secretSharingDAL.findOne({ identifier: sharedSecretId, type: deleteSharedSecretInput.type });
- if (sharedSecret.orgId && sharedSecret.orgId !== orgId)
+ if (sharedSecret.userId !== actorId) {
+ throw new ForbiddenRequestError({
+ message: "User does not have permission to delete shared secret"
+ });
+ }
+ if (sharedSecret.orgId && sharedSecret.orgId !== orgId) {
throw new ForbiddenRequestError({ message: "User does not have permission to delete shared secret" });
+ }
const deletedSharedSecret = await secretSharingDAL.deleteById(sharedSecretId);
diff --git a/backend/src/services/secret-sharing/secret-sharing-types.ts b/backend/src/services/secret-sharing/secret-sharing-types.ts
index 0d2dd23933..835d70eff0 100644
--- a/backend/src/services/secret-sharing/secret-sharing-types.ts
+++ b/backend/src/services/secret-sharing/secret-sharing-types.ts
@@ -57,12 +57,12 @@ export type TRevealSecretRequestValueDTO = {
export type TGetSecretRequestByIdDTO = {
id: string;
-} & TOrgPermission;
+} & Omit<TOrgPermission, "orgId">;
export type TSetSecretRequestValueDTO = {
id: string;
secretValue: string;
-} & TOrgPermission;
+} & Omit<TOrgPermission, "orgId">;
export type TDeleteSharedSecretDTO = {
sharedSecretId: string;
diff --git a/frontend/src/hooks/api/secretSharing/mutations.ts b/frontend/src/hooks/api/secretSharing/mutations.ts
index 8b14851298..89390d5320 100644
--- a/frontend/src/hooks/api/secretSharing/mutations.ts
+++ b/frontend/src/hooks/api/secretSharing/mutations.ts
@@ -5,7 +5,7 @@ import { apiRequest } from "@app/config/request";
import { secretSharingKeys } from "./queries";
import {
TCreatedSharedSecret,
- TCreateSecretRequestRequest,
+ TCreateSecretRequestRequestDTO,
TCreateSharedSecretRequest,
TDeleteSecretRequestDTO,
TDeleteSharedSecretRequestDTO,
@@ -48,7 +48,7 @@ export const useCreatePublicSharedSecret = () => {
export const useCreateSecretRequest = () => {
const queryClient = useQueryClient();
return useMutation({
- mutationFn: async (inputData: TCreateSecretRequestRequest) => {
+ mutationFn: async (inputData: TCreateSecretRequestRequestDTO) => {
const { data } = await apiRequest.post<TCreatedSharedSecret>(
"/api/v1/secret-sharing/requests",
inputData
diff --git a/frontend/src/hooks/api/secretSharing/types.ts b/frontend/src/hooks/api/secretSharing/types.ts
index 6461a1911a..ab819cfb6b 100644
--- a/frontend/src/hooks/api/secretSharing/types.ts
+++ b/frontend/src/hooks/api/secretSharing/types.ts
@@ -6,6 +6,7 @@ export type TSharedSecret = {
updatedAt: Date;
name: string | null;
lastViewedAt?: Date;
+ accessType: SecretSharingAccessType;
expiresAt: Date;
expiresAfterViews: number | null;
encryptedValue: string;
@@ -33,7 +34,7 @@ export type TCreateSharedSecretRequest = {
accessType?: SecretSharingAccessType;
};
-export type TCreateSecretRequestRequest = {
+export type TCreateSecretRequestRequestDTO = {
name?: string;
accessType?: SecretSharingAccessType;
expiresAt: Date;
diff --git a/frontend/src/pages/organization/SecretSharingPage/ShareSecretSection.tsx b/frontend/src/pages/organization/SecretSharingPage/ShareSecretSection.tsx
index 81461040e5..cce4f0a3df 100644
--- a/frontend/src/pages/organization/SecretSharingPage/ShareSecretSection.tsx
+++ b/frontend/src/pages/organization/SecretSharingPage/ShareSecretSection.tsx
@@ -3,7 +3,6 @@ import { useNavigate, useSearch } from "@tanstack/react-router";
import { Badge, Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
import { ROUTE_PATHS } from "@app/const/routes";
-import { usePopUp } from "@app/hooks";
import { RequestSecretTab } from "./components/RequestSecret/RequestSecretTab";
import { ShareSecretTab } from "./components/ShareSecret/ShareSecretTab";
@@ -14,14 +13,6 @@ enum SecretSharingPageTabs {
}
export const ShareSecretSection = () => {
- const { popUp, handlePopUpToggle, handlePopUpClose, handlePopUpOpen } = usePopUp([
- "createSharedSecret",
- "deleteSharedSecretConfirmation",
- "createSecretRequest",
- "deleteSecretRequestConfirmation",
- "revealSecretRequestValue"
- ] as const);
-
const navigate = useNavigate();
const { selectedTab } = useSearch({
@@ -54,20 +45,10 @@ export const ShareSecretSection = () => {
</Tab>
</TabList>
<TabPanel value={SecretSharingPageTabs.ShareSecret}>
- <ShareSecretTab
- handlePopUpOpen={handlePopUpOpen}
- popUp={popUp}
- handlePopUpToggle={handlePopUpToggle}
- handlePopUpClose={handlePopUpClose}
- />
+ <ShareSecretTab />
</TabPanel>
<TabPanel value={SecretSharingPageTabs.RequestSecret}>
- <RequestSecretTab
- handlePopUpOpen={handlePopUpOpen}
- popUp={popUp}
- handlePopUpToggle={handlePopUpToggle}
- handlePopUpClose={handlePopUpClose}
- />
+ <RequestSecretTab />
</TabPanel>
</Tabs>
</div>
diff --git a/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestSecretForm.tsx b/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestSecretForm.tsx
index 8b6d1e0b72..d8286b7662 100644
--- a/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestSecretForm.tsx
+++ b/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestSecretForm.tsx
@@ -98,7 +98,12 @@ export const RequestSecretForm = () => {
name="expiresIn"
defaultValue="3600000"
render={({ field: { onChange, ...field }, fieldState: { error } }) => (
- <FormControl label="Expires In" errorText={error?.message} isError={Boolean(error)}>
+ <FormControl
+ label="Expires In"
+ errorText={error?.message}
+ tooltipText="Select for how long someone is able to input the secret. If a secret is shared with you in time, it will remain available to you, even after the expiration."
+ isError={Boolean(error)}
+ >
<Select
defaultValue={field.value}
{...field}
diff --git a/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestSecretTab.tsx b/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestSecretTab.tsx
index 4a17267dd5..047172eaa8 100644
--- a/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestSecretTab.tsx
+++ b/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestSecretTab.tsx
@@ -4,41 +4,21 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { createNotification } from "@app/components/notifications";
import { Button, DeleteActionModal } from "@app/components/v2";
import { useDeleteSecretRequest } from "@app/hooks/api";
-import { UsePopUpState } from "@app/hooks/usePopUp";
+import { usePopUp } from "@app/hooks/usePopUp";
import { AddSecretRequestModal } from "./AddSecretRequestModal";
import { RequestedSecretsTable } from "./RequestedSecretsTable";
import { RevealSecretValueModal } from "./RevealSecretValueModal";
-type Props = {
- handlePopUpOpen: (
- popUpName: keyof UsePopUpState<
- ["createSecretRequest", "deleteSecretRequestConfirmation", "revealSecretRequestValue"]
- >,
- data?: any
- ) => void;
- popUp: UsePopUpState<
- ["createSecretRequest", "deleteSecretRequestConfirmation", "revealSecretRequestValue"]
- >;
- handlePopUpToggle: (
- popUpName: keyof UsePopUpState<
- ["createSecretRequest", "deleteSecretRequestConfirmation", "revealSecretRequestValue"]
- >,
- state?: boolean
- ) => void;
- handlePopUpClose: (
- popUpName: keyof UsePopUpState<["deleteSecretRequestConfirmation", "revealSecretRequestValue"]>
- ) => void;
-};
-
type DeleteModalData = { name: string; id: string };
-export const RequestSecretTab = ({
- handlePopUpOpen,
- popUp,
- handlePopUpToggle,
- handlePopUpClose
-}: Props) => {
+export const RequestSecretTab = () => {
+ const { popUp, handlePopUpToggle, handlePopUpClose, handlePopUpOpen } = usePopUp([
+ "createSecretRequest",
+ "deleteSecretRequestConfirmation",
+ "revealSecretRequestValue"
+ ] as const);
+
const { mutateAsync: deleteSecretRequest } = useDeleteSecretRequest();
const onDeleteApproved = async () => {
diff --git a/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestedSecretsRow.tsx b/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestedSecretsRow.tsx
index c421e48da5..a4a0f8e152 100644
--- a/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestedSecretsRow.tsx
+++ b/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestedSecretsRow.tsx
@@ -4,7 +4,11 @@ import { format } from "date-fns";
import { createNotification } from "@app/components/notifications";
import { Badge, IconButton, Td, Tooltip, Tr } from "@app/components/v2";
-import { TSharedSecret, useRevealSecretRequestValue } from "@app/hooks/api/secretSharing";
+import {
+ SecretSharingAccessType,
+ TSharedSecret,
+ useRevealSecretRequestValue
+} from "@app/hooks/api/secretSharing";
import { UsePopUpState } from "@app/hooks/usePopUp";
export const RequestedSecretsRow = ({
@@ -36,6 +40,23 @@ export const RequestedSecretsRow = ({
</Badge>
)}
</Td>
+ <Td>
+ <Badge variant="primary">
+ <Tooltip
+ content={
+ row.accessType === SecretSharingAccessType.Anyone
+ ? "Anyone can input the secret."
+ : "Only members of the organization can input the secret."
+ }
+ >
+ <div>
+ {row.accessType === SecretSharingAccessType.Anyone
+ ? "Anyone"
+ : "Organization Members"}
+ </div>
+ </Tooltip>
+ </Badge>
+ </Td>
<Td>{`${format(new Date(row.createdAt), "yyyy-MM-dd - HH:mm a")}`}</Td>
<Td>{row.expiresAt ? format(new Date(row.expiresAt), "yyyy-MM-dd - HH:mm a") : "-"}</Td>
<Td>
@@ -43,7 +64,7 @@ export const RequestedSecretsRow = ({
<Tooltip
content={
row.encryptedSecret
- ? "Reveal shared secret"
+ ? "Reveal secret"
: "Secret value must be provided before it can be viewed."
}
>
@@ -72,28 +93,30 @@ export const RequestedSecretsRow = ({
</IconButton>
</Tooltip>
- <IconButton
- isDisabled={Boolean(row.encryptedSecret) || isExpired}
- className={Boolean(row.encryptedSecret) || isExpired ? "opacity-50" : ""}
- onClick={async (e) => {
- e.stopPropagation();
+ <Tooltip content="Copy link">
+ <IconButton
+ isDisabled={Boolean(row.encryptedSecret) || isExpired}
+ className={Boolean(row.encryptedSecret) || isExpired ? "opacity-50" : ""}
+ onClick={async (e) => {
+ e.stopPropagation();
- navigator.clipboard.writeText(
- `${window.location.origin}/secret-request/secret/${row.id}`
- );
+ navigator.clipboard.writeText(
+ `${window.location.origin}/secret-request/secret/${row.id}`
+ );
- createNotification({
- text: "Shared secret link copied to clipboard.",
- type: "success"
- });
- }}
- variant="plain"
- ariaLabel="copy link"
- >
- <FontAwesomeIcon icon={faCopy} />
- </IconButton>
+ createNotification({
+ text: "Shared secret link copied to clipboard.",
+ type: "success"
+ });
+ }}
+ variant="plain"
+ ariaLabel="copy link"
+ >
+ <FontAwesomeIcon icon={faCopy} />
+ </IconButton>
+ </Tooltip>
- <Tooltip content="Delete Secret Request">
+ <Tooltip content="Delete">
<IconButton
onClick={(e) => {
e.stopPropagation();
diff --git a/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestedSecretsTable.tsx b/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestedSecretsTable.tsx
index 2392f2123d..5e9edca7b0 100644
--- a/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestedSecretsTable.tsx
+++ b/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RequestedSecretsTable.tsx
@@ -38,6 +38,7 @@ export const RequestedSecretsTable = ({ handlePopUpOpen }: Props) => {
<Tr>
<Th>Name</Th>
<Th>Status</Th>
+ <Th>Access Type</Th>
<Th>Created At</Th>
<Th>Valid Until</Th>
<Th aria-label="button" className="w-5" />
@@ -64,7 +65,7 @@ export const RequestedSecretsTable = ({ handlePopUpOpen }: Props) => {
/>
)}
{!isPending && !data?.secrets?.length && (
- <EmptyState title="No secrets shared yet" icon={faKey} />
+ <EmptyState title="No secrets requested yet" icon={faKey} />
)}
</TableContainer>
);
diff --git a/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RevealSecretValueModal.tsx b/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RevealSecretValueModal.tsx
index 4c353f5c77..5aa529e77b 100644
--- a/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RevealSecretValueModal.tsx
+++ b/frontend/src/pages/organization/SecretSharingPage/components/RequestSecret/RevealSecretValueModal.tsx
@@ -27,7 +27,7 @@ const Content = ({ secretValue, secretRequestName }: ContentProps) => {
</p>
)}
- <div className="mb-8 flex items-center justify-between rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <div className="mb-8 flex items-center justify-between rounded-md bg-mineshaft-700 p-2 text-base text-gray-400">
<p className="mr-4 break-all">{secretValue}</p>
<Tooltip content="Click to copy">
<IconButton
@@ -46,7 +46,7 @@ const Content = ({ secretValue, secretRequestName }: ContentProps) => {
<div className="mt-8 flex w-full items-center justify-between gap-2">
<ModalClose asChild>
- <Button colorSchema="primary">Close</Button>
+ <Button colorSchema="secondary">Close</Button>
</ModalClose>
</div>
</>
diff --git a/frontend/src/pages/organization/SecretSharingPage/components/ShareSecret/ShareSecretTab.tsx b/frontend/src/pages/organization/SecretSharingPage/components/ShareSecret/ShareSecretTab.tsx
index 115fbfe0ba..5fa4039098 100644
--- a/frontend/src/pages/organization/SecretSharingPage/components/ShareSecret/ShareSecretTab.tsx
+++ b/frontend/src/pages/organization/SecretSharingPage/components/ShareSecret/ShareSecretTab.tsx
@@ -4,32 +4,19 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { createNotification } from "@app/components/notifications";
import { Button, DeleteActionModal } from "@app/components/v2";
import { useDeleteSharedSecret } from "@app/hooks/api";
-import { UsePopUpState } from "@app/hooks/usePopUp";
+import { usePopUp } from "@app/hooks/usePopUp";
import { AddShareSecretModal } from "./AddShareSecretModal";
import { ShareSecretsTable } from "./ShareSecretsTable";
-type Props = {
- handlePopUpOpen: (
- popUpName: keyof UsePopUpState<["createSharedSecret", "deleteSharedSecretConfirmation"]>,
- data?: any
- ) => void;
- popUp: UsePopUpState<["createSharedSecret", "deleteSharedSecretConfirmation"]>;
- handlePopUpToggle: (
- popUpName: keyof UsePopUpState<["createSharedSecret", "deleteSharedSecretConfirmation"]>,
- state?: boolean
- ) => void;
- handlePopUpClose: (popUpName: keyof UsePopUpState<["deleteSharedSecretConfirmation"]>) => void;
-};
-
type DeleteModalData = { name: string; id: string };
-export const ShareSecretTab = ({
- handlePopUpOpen,
- popUp,
- handlePopUpToggle,
- handlePopUpClose
-}: Props) => {
+export const ShareSecretTab = () => {
+ const { popUp, handlePopUpToggle, handlePopUpClose, handlePopUpOpen } = usePopUp([
+ "createSharedSecret",
+ "deleteSharedSecretConfirmation"
+ ] as const);
+
const deleteSecretShare = useDeleteSharedSecret();
const onDeleteApproved = async () => {
diff --git a/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretErrorContainer.tsx b/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretErrorContainer.tsx
index 421cbc68be..c2e9ce4758 100644
--- a/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretErrorContainer.tsx
+++ b/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretErrorContainer.tsx
@@ -6,7 +6,7 @@ export const SecretRequestErrorContainer = () => {
<div className="rounded-lg border border-mineshaft-600 bg-mineshaft-800 p-8">
<div className="text-center">
<FontAwesomeIcon icon={faKey} size="2x" />
- <p className="mt-4">The secret request you are looking is missing or has expired.</p>
+ <p className="mt-4">The secret request you are looking for is missing or has expired.</p>
</div>
</div>
);