mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 21:28:18 +00:00
feat: ui for reindex secret reference
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
export {
|
export {
|
||||||
|
useBackfillSecretReference,
|
||||||
useCreateSecretBatch,
|
useCreateSecretBatch,
|
||||||
useCreateSecretV3,
|
useCreateSecretV3,
|
||||||
useDeleteSecretBatch,
|
useDeleteSecretBatch,
|
||||||
|
|||||||
@@ -87,11 +87,11 @@ export const useCreateSecretV3 = ({
|
|||||||
|
|
||||||
const randomBytes = latestFileKey
|
const randomBytes = latestFileKey
|
||||||
? decryptAssymmetric({
|
? decryptAssymmetric({
|
||||||
ciphertext: latestFileKey.encryptedKey,
|
ciphertext: latestFileKey.encryptedKey,
|
||||||
nonce: latestFileKey.nonce,
|
nonce: latestFileKey.nonce,
|
||||||
publicKey: latestFileKey.sender.publicKey,
|
publicKey: latestFileKey.sender.publicKey,
|
||||||
privateKey: PRIVATE_KEY
|
privateKey: PRIVATE_KEY
|
||||||
})
|
})
|
||||||
: crypto.randomBytes(16).toString("hex");
|
: crypto.randomBytes(16).toString("hex");
|
||||||
|
|
||||||
const reqBody = {
|
const reqBody = {
|
||||||
@@ -148,11 +148,11 @@ export const useUpdateSecretV3 = ({
|
|||||||
|
|
||||||
const randomBytes = latestFileKey
|
const randomBytes = latestFileKey
|
||||||
? decryptAssymmetric({
|
? decryptAssymmetric({
|
||||||
ciphertext: latestFileKey.encryptedKey,
|
ciphertext: latestFileKey.encryptedKey,
|
||||||
nonce: latestFileKey.nonce,
|
nonce: latestFileKey.nonce,
|
||||||
publicKey: latestFileKey.sender.publicKey,
|
publicKey: latestFileKey.sender.publicKey,
|
||||||
privateKey: PRIVATE_KEY
|
privateKey: PRIVATE_KEY
|
||||||
})
|
})
|
||||||
: crypto.randomBytes(16).toString("hex");
|
: crypto.randomBytes(16).toString("hex");
|
||||||
|
|
||||||
const reqBody = {
|
const reqBody = {
|
||||||
@@ -244,11 +244,11 @@ export const useCreateSecretBatch = ({
|
|||||||
const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY") as string;
|
const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY") as string;
|
||||||
const randomBytes = latestFileKey
|
const randomBytes = latestFileKey
|
||||||
? decryptAssymmetric({
|
? decryptAssymmetric({
|
||||||
ciphertext: latestFileKey.encryptedKey,
|
ciphertext: latestFileKey.encryptedKey,
|
||||||
nonce: latestFileKey.nonce,
|
nonce: latestFileKey.nonce,
|
||||||
publicKey: latestFileKey.sender.publicKey,
|
publicKey: latestFileKey.sender.publicKey,
|
||||||
privateKey: PRIVATE_KEY
|
privateKey: PRIVATE_KEY
|
||||||
})
|
})
|
||||||
: crypto.randomBytes(16).toString("hex");
|
: crypto.randomBytes(16).toString("hex");
|
||||||
|
|
||||||
const reqBody = {
|
const reqBody = {
|
||||||
@@ -297,11 +297,11 @@ export const useUpdateSecretBatch = ({
|
|||||||
const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY") as string;
|
const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY") as string;
|
||||||
const randomBytes = latestFileKey
|
const randomBytes = latestFileKey
|
||||||
? decryptAssymmetric({
|
? decryptAssymmetric({
|
||||||
ciphertext: latestFileKey.encryptedKey,
|
ciphertext: latestFileKey.encryptedKey,
|
||||||
nonce: latestFileKey.nonce,
|
nonce: latestFileKey.nonce,
|
||||||
publicKey: latestFileKey.sender.publicKey,
|
publicKey: latestFileKey.sender.publicKey,
|
||||||
privateKey: PRIVATE_KEY
|
privateKey: PRIVATE_KEY
|
||||||
})
|
})
|
||||||
: crypto.randomBytes(16).toString("hex");
|
: crypto.randomBytes(16).toString("hex");
|
||||||
|
|
||||||
const reqBody = {
|
const reqBody = {
|
||||||
@@ -379,3 +379,13 @@ export const createSecret = async (dto: CreateSecretDTO) => {
|
|||||||
const { data } = await apiRequest.post(`/api/v3/secrets/${dto.secretKey}`, dto);
|
const { data } = await apiRequest.post(`/api/v3/secrets/${dto.secretKey}`, dto);
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useBackfillSecretReference = () =>
|
||||||
|
useMutation<{ message: string }, {}, { projectId: string }>({
|
||||||
|
mutationFn: async ({ projectId }) => {
|
||||||
|
const { data } = await apiRequest.post("/api/v3/secrets/backfill-secret-references", {
|
||||||
|
projectId
|
||||||
|
});
|
||||||
|
return data.message;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
import { createNotification } from "@app/components/notifications";
|
||||||
|
import { Button } from "@app/components/v2";
|
||||||
|
import { useProjectPermission, useWorkspace } from "@app/context";
|
||||||
|
import { useBackfillSecretReference } from "@app/hooks/api";
|
||||||
|
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
|
||||||
|
|
||||||
|
export const BackfillSecretReferenceSecretion = () => {
|
||||||
|
const { currentWorkspace } = useWorkspace();
|
||||||
|
const { membership } = useProjectPermission();
|
||||||
|
const backfillSecretReferences = useBackfillSecretReference();
|
||||||
|
|
||||||
|
if (!currentWorkspace) return null;
|
||||||
|
|
||||||
|
const handleBackfill = async () => {
|
||||||
|
if (backfillSecretReferences.isLoading) return;
|
||||||
|
try {
|
||||||
|
await backfillSecretReferences.mutateAsync({ projectId: currentWorkspace.id || "" });
|
||||||
|
createNotification({ text: "Successfully re-indexed secret references", type: "success" });
|
||||||
|
} catch {
|
||||||
|
createNotification({ text: "Failed to re-index secret references", type: "error" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const isAdmin = membership.roles.includes(ProjectMembershipRole.Admin);
|
||||||
|
return (
|
||||||
|
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
|
||||||
|
<div className="flex w-full items-center justify-between">
|
||||||
|
<p className="text-xl font-semibold">Resync Secret References</p>
|
||||||
|
</div>
|
||||||
|
<p className="mb-4 mt-2 max-w-2xl text-sm text-gray-400">
|
||||||
|
Trigger this to reindex all your inline secret references to map integration
|
||||||
|
synchronization.
|
||||||
|
</p>
|
||||||
|
<Button
|
||||||
|
variant="outline_bg"
|
||||||
|
isLoading={backfillSecretReferences.isLoading}
|
||||||
|
onClick={handleBackfill}
|
||||||
|
isDisabled={!isAdmin}
|
||||||
|
>
|
||||||
|
Resync Secret References
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
export { BackfillSecretReferenceSecretion } from "./BackfillSecretReferenceSection";
|
||||||
+2
@@ -1,4 +1,5 @@
|
|||||||
import { AutoCapitalizationSection } from "../AutoCapitalizationSection";
|
import { AutoCapitalizationSection } from "../AutoCapitalizationSection";
|
||||||
|
import { BackfillSecretReferenceSecretion } from "../BackfillSecretReferenceSection";
|
||||||
import { DeleteProjectSection } from "../DeleteProjectSection";
|
import { DeleteProjectSection } from "../DeleteProjectSection";
|
||||||
import { E2EESection } from "../E2EESection";
|
import { E2EESection } from "../E2EESection";
|
||||||
import { EnvironmentSection } from "../EnvironmentSection";
|
import { EnvironmentSection } from "../EnvironmentSection";
|
||||||
@@ -13,6 +14,7 @@ export const ProjectGeneralTab = () => {
|
|||||||
<SecretTagsSection />
|
<SecretTagsSection />
|
||||||
<AutoCapitalizationSection />
|
<AutoCapitalizationSection />
|
||||||
<E2EESection />
|
<E2EESection />
|
||||||
|
<BackfillSecretReferenceSecretion />
|
||||||
<DeleteProjectSection />
|
<DeleteProjectSection />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export { AutoCapitalizationSection } from "./AutoCapitalizationSection";
|
export { AutoCapitalizationSection } from "./AutoCapitalizationSection";
|
||||||
|
export { BackfillSecretReferenceSecretion } from "./BackfillSecretReferenceSection";
|
||||||
export { DeleteProjectSection } from "./DeleteProjectSection";
|
export { DeleteProjectSection } from "./DeleteProjectSection";
|
||||||
export { E2EESection } from "./E2EESection";
|
export { E2EESection } from "./E2EESection";
|
||||||
export { EnvironmentSection } from "./EnvironmentSection";
|
export { EnvironmentSection } from "./EnvironmentSection";
|
||||||
|
|||||||
Reference in New Issue
Block a user