Skip to content

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

fix: general access accessible only from private creation

Alfonso Hernandez224368b172c7
diff --git a/backend/src/server/routes/v1/secret-sharing-router.ts b/backend/src/server/routes/v1/secret-sharing-router.ts
index 9e5fe1f792..d5c6a98842 100644
--- a/backend/src/server/routes/v1/secret-sharing-router.ts
+++ b/backend/src/server/routes/v1/secret-sharing-router.ts
@@ -95,8 +95,7 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>
tag: z.string(),
hashedHex: z.string(),
expiresAt: z.string(),
- expiresAfterViews: z.number(),
- accessType: z.nativeEnum(SecretSharingAccessType).default(SecretSharingAccessType.Organization)
+ expiresAfterViews: z.number()
}),
response: {
200: z.object({
@@ -105,7 +104,7 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>
}
},
handler: async (req) => {
- const { encryptedValue, iv, tag, hashedHex, expiresAt, expiresAfterViews, accessType } = req.body;
+ const { encryptedValue, iv, tag, hashedHex, expiresAt, expiresAfterViews } = req.body;
const sharedSecret = await req.server.services.secretSharing.createPublicSharedSecret({
encryptedValue,
iv,
@@ -113,7 +112,7 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>
hashedHex,
expiresAt: new Date(expiresAt),
expiresAfterViews,
- accessType
+ accessType: SecretSharingAccessType.Anyone
});
return { id: sharedSecret.id };
}
diff --git a/frontend/src/views/ShareSecretPage/components/AddShareSecretForm.tsx b/frontend/src/views/ShareSecretPage/components/AddShareSecretForm.tsx
index bbc896460d..47da21693a 100644
--- a/frontend/src/views/ShareSecretPage/components/AddShareSecretForm.tsx
+++ b/frontend/src/views/ShareSecretPage/components/AddShareSecretForm.tsx
@@ -1,5 +1,6 @@
import crypto from "crypto";
+import { useEffect, useRef } from "react";
import { Controller } from "react-hook-form";
import { AxiosError } from "axios";
import * as yup from "yup";
@@ -36,6 +37,14 @@ export const AddShareSecretForm = ({
setNewSharedSecret: (value: string) => void;
isInputDisabled?: boolean;
}) => {
+ const isMounted = useRef(true);
+
+ useEffect(() => {
+ return () => {
+ isMounted.current = false;
+ };
+ }, []);
+
const publicSharedSecretCreator = useCreatePublicSharedSecret();
const privateSharedSecretCreator = useCreateSharedSecret();
const createSharedSecret = isPublic ? publicSharedSecretCreator : privateSharedSecretCreator;
@@ -94,16 +103,18 @@ export const AddShareSecretForm = ({
expiresAfterViews: expiresAfterSingleView ? 1 : 1000,
accessType: accessType as SecretSharingAccessType
});
- setNewSharedSecret(
- `${window.location.origin}/shared/secret/${id}?key=${encodeURIComponent(
- hashedHex
- )}-${encodeURIComponent(key)}`
- );
- createNotification({
- text: "Successfully created a shared secret",
- type: "success"
- });
+ if (isMounted.current) {
+ setNewSharedSecret(
+ `${window.location.origin}/shared/secret/${id}?key=${encodeURIComponent(
+ hashedHex
+ )}-${encodeURIComponent(key)}`
+ );
+ createNotification({
+ text: "Successfully created a shared secret",
+ type: "success"
+ });
+ }
} catch (err) {
console.error(err);
const axiosError = err as AxiosError;
@@ -146,7 +157,7 @@ export const AddShareSecretForm = ({
)}
/>
</div>
- <div className="flex w-full flex-col md:flex-row justify-strech">
+ <div className="flex w-full flex-col md:flex-row justify-stretch">
<div className="flex justify-start">
<div className="flex justify-start">
<div className="flex w-full justify-center pr-2">
@@ -230,23 +241,25 @@ export const AddShareSecretForm = ({
</div>
</div>
</div>
- <Controller
- control={control}
- name="accessType"
- defaultValue="organization"
- render={({ field: { onChange, ...field } }) => (
- <FormControl label="General Access">
- <Select
- {...field}
- onValueChange={(e) => onChange(e)}
- >
- <SelectItem value="organization">People within your organization</SelectItem>
- <SelectItem value="anyone">Anyone</SelectItem>
- </Select>
- </FormControl>
- )}
- />
- <div className={`flex items-center space-x-4 mt-6 ${!inModal && "justify-start pt-2"}`}>
+ {!isPublic && (
+ <Controller
+ control={control}
+ name="accessType"
+ defaultValue="organization"
+ render={({ field: { onChange, ...field } }) => (
+ <FormControl label="General Access">
+ <Select
+ {...field}
+ onValueChange={(e) => onChange(e)}
+ >
+ <SelectItem value="organization">People within your organization</SelectItem>
+ <SelectItem value="anyone">Anyone</SelectItem>
+ </Select>
+ </FormControl>
+ )}
+ />
+ )}
+ <div className={`flex items-center space-x-4 pt-2 ${!inModal && ""}`}>
<Button className="mr-0" type="submit" isDisabled={isSubmitting} isLoading={isSubmitting}>
{inModal ? "Create" : "Share Secret"}
</Button>