feat(infisical-pg): completed secret rotation with queue service

This commit is contained in:
Akhil Mohan
2024-01-27 12:38:23 +05:30
parent 17e61bfc68
commit 784cdb4201
64 changed files with 3093 additions and 459 deletions
@@ -14,7 +14,7 @@ export const useCreateSecretRotation = () => {
return useMutation<{}, {}, TCreateSecretRotationDTO>({
mutationFn: async (dto) => {
const { data } = await apiRequest.post("/api/v1/secret-rotations", dto);
const { data } = await apiRequest.post("/api/ee/v1/secret-rotations", dto);
return data;
},
onSuccess: (_, { workspaceId }) => {
@@ -28,7 +28,7 @@ export const useDeleteSecretRotation = () => {
return useMutation<{}, {}, TDeleteSecretRotationDTO>({
mutationFn: async (dto) => {
const { data } = await apiRequest.delete(`/api/v1/secret-rotations/${dto.id}`);
const { data } = await apiRequest.delete(`/api/ee/v1/secret-rotations/${dto.id}`);
return data;
},
onSuccess: (_, { workspaceId }) => {
@@ -42,7 +42,7 @@ export const useRestartSecretRotation = () => {
return useMutation<{}, {}, TRestartSecretRotationDTO>({
mutationFn: async (dto) => {
const { data } = await apiRequest.post("/api/v1/secret-rotations/restart", { id: dto.id });
const { data } = await apiRequest.post("/api/ee/v1/secret-rotations/restart", { id: dto.id });
return data;
},
onSuccess: (_, { workspaceId }) => {
@@ -25,7 +25,7 @@ export const secretRotationKeys = {
const fetchSecretRotationProviders = async ({ workspaceId }: TGetSecretRotationProviders) => {
const { data } = await apiRequest.get<TSecretRotationProviderList>(
`/api/v1/secret-rotation-providers/${workspaceId}`
`/api/ee/v1/secret-rotation-providers/${workspaceId}`
);
return data;
};
@@ -55,7 +55,7 @@ const fetchSecretRotations = async ({
workspaceId
}: Omit<TGetSecretRotationList, "decryptFileKey">) => {
const { data } = await apiRequest.get<{ secretRotations: TSecretRotation[] }>(
"/api/v1/secret-rotations",
"/api/ee/v1/secret-rotations",
{ params: { workspaceId } }
);
return data.secretRotations;
+27 -30
View File
@@ -1,5 +1,6 @@
import { UserWsKeyPair } from "../keys/types";
import { EncryptedSecret } from "../secrets/types";
import { WorkspaceEnv } from "../workspace/types";
export enum TProviderFunctionTypes {
HTTP = "http",
@@ -31,7 +32,6 @@ export type TDirectAssignOp = {
export type TAssignFunction = TJmesPathAssignOp | TDirectAssignOp;
export type THttpProviderFunction = {
type: TProviderFunctionTypes.HTTP;
url: string;
method: string;
header?: Record<string, string>;
@@ -41,42 +41,47 @@ export type THttpProviderFunction = {
pre?: Record<string, TDirectAssignOp>;
};
export type TDbProviderFunction = {
type: TProviderFunctionTypes.DB;
client: TDbProviderClients;
username: string;
password: string;
host: string;
database: string;
port: string;
query: string;
setter?: Record<string, TAssignFunction>;
pre?: Record<string, TDirectAssignOp>;
export type TSecretRotationProviderTemplate = {
name: string;
title: string;
image?: string;
description?: string;
template: THttpProviderTemplate | TDbProviderTemplate;
};
export type TProviderFunction = THttpProviderFunction | TDbProviderFunction;
export type TProviderTemplate = {
export type THttpProviderTemplate = {
type: TProviderFunctionTypes.HTTP;
inputs: {
properties: Record<string, { type: string; helperText?: string; defaultValue?: string }>;
type: "object";
properties: Record<string, { type: string; [x: string]: unknown; desc?: string }>;
required: string[];
};
outputs: Record<string, unknown>;
functions: {
set: TProviderFunction;
remove?: TProviderFunction;
test: TProviderFunction;
set: THttpProviderFunction;
remove?: THttpProviderFunction;
test: THttpProviderFunction;
};
};
export type TDbProviderTemplate = {
type: TProviderFunctionTypes.DB;
inputs: {
type: "object";
properties: Record<string, { type: string; [x: string]: unknown; desc?: string }>;
required: string[];
};
outputs: Record<string, unknown>;
};
export type TSecretRotation<T extends unknown = EncryptedSecret> = {
id: string;
interval: number;
provider: string;
customProvider: string;
workspace: string;
environment: string;
envId: string;
environment: WorkspaceEnv;
secretPath: string;
outputs: Array<{
key: string;
@@ -89,17 +94,9 @@ export type TSecretRotation<T extends unknown = EncryptedSecret> = {
keyEncoding: string;
};
export type TSecretRotationProvider = {
name: string;
image: string;
title: string;
description: string;
template: TProviderTemplate;
};
export type TSecretRotationProviderList = {
custom: TSecretRotationProvider[];
providers: TSecretRotationProvider[];
custom: TSecretRotationProviderTemplate[];
providers: TSecretRotationProviderTemplate[];
};
export type TGetSecretRotationProviders = {