mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 08:34:52 +00:00
Merge remote-tracking branch 'origin/main' into feat/kmip-client-management
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
export * from "./queries";
|
||||
export * from "./types";
|
||||
@@ -0,0 +1,37 @@
|
||||
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { appConnectionKeys } from "@app/hooks/api/appConnections";
|
||||
|
||||
import { TDatabricksConnectionListSecretScopesResponse, TDatabricksSecretScope } from "./types";
|
||||
|
||||
const databricksConnectionKeys = {
|
||||
all: [...appConnectionKeys.all, "databricks"] as const,
|
||||
listSecretScopes: (connectionId: string) =>
|
||||
[...databricksConnectionKeys.all, "workspace-scopes", connectionId] as const
|
||||
};
|
||||
|
||||
export const useDatabricksConnectionListSecretScopes = (
|
||||
connectionId: string,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
TDatabricksSecretScope[],
|
||||
unknown,
|
||||
TDatabricksSecretScope[],
|
||||
ReturnType<typeof databricksConnectionKeys.listSecretScopes>
|
||||
>,
|
||||
"queryKey" | "queryFn"
|
||||
>
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: databricksConnectionKeys.listSecretScopes(connectionId),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<TDatabricksConnectionListSecretScopesResponse>(
|
||||
`/api/v1/app-connections/databricks/${connectionId}/secret-scopes`
|
||||
);
|
||||
|
||||
return data.secretScopes;
|
||||
},
|
||||
...options
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
export type TDatabricksSecretScope = {
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type TDatabricksConnectionListSecretScopesResponse = {
|
||||
secretScopes: TDatabricksSecretScope[];
|
||||
};
|
||||
@@ -1,5 +1,8 @@
|
||||
export enum AppConnection {
|
||||
AWS = "aws",
|
||||
GitHub = "github",
|
||||
GCP = "gcp"
|
||||
GCP = "gcp",
|
||||
AzureKeyVault = "azure-key-vault",
|
||||
AzureAppConfiguration = "azure-app-configuration",
|
||||
Databricks = "databricks"
|
||||
}
|
||||
|
||||
@@ -20,10 +20,33 @@ export type TGcpConnectionOption = TAppConnectionOptionBase & {
|
||||
app: AppConnection.GCP;
|
||||
};
|
||||
|
||||
export type TAppConnectionOption = TAwsConnectionOption | TGitHubConnectionOption;
|
||||
export type TAzureKeyVaultConnectionOption = TAppConnectionOptionBase & {
|
||||
app: AppConnection.AzureKeyVault;
|
||||
oauthClientId?: string;
|
||||
};
|
||||
|
||||
export type TAzureAppConfigurationConnectionOption = TAppConnectionOptionBase & {
|
||||
app: AppConnection.AzureKeyVault;
|
||||
oauthClientId?: string;
|
||||
};
|
||||
|
||||
export type TDatabricksConnectionOption = TAppConnectionOptionBase & {
|
||||
app: AppConnection.Databricks;
|
||||
};
|
||||
|
||||
export type TAppConnectionOption =
|
||||
| TAwsConnectionOption
|
||||
| TGitHubConnectionOption
|
||||
| TGcpConnectionOption
|
||||
| TAzureAppConfigurationConnectionOption
|
||||
| TAzureKeyVaultConnectionOption
|
||||
| TDatabricksConnectionOption;
|
||||
|
||||
export type TAppConnectionOptionMap = {
|
||||
[AppConnection.AWS]: TAwsConnectionOption;
|
||||
[AppConnection.GitHub]: TGitHubConnectionOption;
|
||||
[AppConnection.GCP]: TGcpConnectionOption;
|
||||
[AppConnection.AzureKeyVault]: TAzureKeyVaultConnectionOption;
|
||||
[AppConnection.AzureAppConfiguration]: TAzureAppConfigurationConnectionOption;
|
||||
[AppConnection.Databricks]: TDatabricksConnectionOption;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||
import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
|
||||
|
||||
export enum AzureAppConfigurationConnectionMethod {
|
||||
OAuth = "oauth"
|
||||
}
|
||||
|
||||
export type TAzureAppConfigurationConnection = TRootAppConnection & {
|
||||
app: AppConnection.AzureAppConfiguration;
|
||||
} & {
|
||||
method: AzureAppConfigurationConnectionMethod.OAuth;
|
||||
credentials: {
|
||||
code: string;
|
||||
tenantId?: string;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||
import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
|
||||
|
||||
export enum AzureKeyVaultConnectionMethod {
|
||||
OAuth = "oauth"
|
||||
}
|
||||
|
||||
export type TAzureKeyVaultConnection = TRootAppConnection & { app: AppConnection.AzureKeyVault } & {
|
||||
method: AzureKeyVaultConnectionMethod.OAuth;
|
||||
credentials: {
|
||||
code: string;
|
||||
tenantId?: string;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
import { AppConnection } from "../enums";
|
||||
import { TRootAppConnection } from "./root-connection";
|
||||
|
||||
export enum DatabricksConnectionMethod {
|
||||
ServicePrincipal = "service-principal"
|
||||
}
|
||||
|
||||
export type TDatabricksConnection = TRootAppConnection & { app: AppConnection.Databricks } & {
|
||||
method: DatabricksConnectionMethod.ServicePrincipal;
|
||||
credentials: {
|
||||
workspaceUrl: string;
|
||||
clientId: string;
|
||||
clientSecret: string;
|
||||
};
|
||||
};
|
||||
@@ -1,17 +1,28 @@
|
||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||
import { TAppConnectionOption } from "@app/hooks/api/appConnections/types/app-options";
|
||||
import { TAwsConnection } from "@app/hooks/api/appConnections/types/aws-connection";
|
||||
import { TDatabricksConnection } from "@app/hooks/api/appConnections/types/databricks-connection";
|
||||
import { TGitHubConnection } from "@app/hooks/api/appConnections/types/github-connection";
|
||||
|
||||
import { TAzureAppConfigurationConnection } from "./azure-app-configuration-connection";
|
||||
import { TAzureKeyVaultConnection } from "./azure-key-vault-connection";
|
||||
import { TGcpConnection } from "./gcp-connection";
|
||||
|
||||
export * from "./aws-connection";
|
||||
export * from "./azure-app-configuration-connection";
|
||||
export * from "./azure-key-vault-connection";
|
||||
export * from "./gcp-connection";
|
||||
export * from "./github-connection";
|
||||
|
||||
export type TAppConnection = TAwsConnection | TGitHubConnection | TGcpConnection;
|
||||
export type TAppConnection =
|
||||
| TAwsConnection
|
||||
| TGitHubConnection
|
||||
| TGcpConnection
|
||||
| TAzureKeyVaultConnection
|
||||
| TAzureAppConfigurationConnection
|
||||
| TDatabricksConnection;
|
||||
|
||||
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "app" | "id">;
|
||||
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id">;
|
||||
|
||||
export type TListAppConnections<T extends TAppConnection> = { appConnections: T[] };
|
||||
export type TGetAppConnection<T extends TAppConnection> = { appConnection: T };
|
||||
@@ -40,4 +51,7 @@ export type TAppConnectionMap = {
|
||||
[AppConnection.AWS]: TAwsConnection;
|
||||
[AppConnection.GitHub]: TGitHubConnection;
|
||||
[AppConnection.GCP]: TGcpConnection;
|
||||
[AppConnection.AzureKeyVault]: TAzureKeyVaultConnection;
|
||||
[AppConnection.AzureAppConfiguration]: TAzureAppConfigurationConnection;
|
||||
[AppConnection.Databricks]: TDatabricksConnection;
|
||||
};
|
||||
|
||||
@@ -4,6 +4,8 @@ export const eventToNameMap: { [K in EventType]: string } = {
|
||||
[EventType.GET_SECRETS]: "List secrets",
|
||||
[EventType.GET_SECRET]: "Read secret",
|
||||
[EventType.DELETE_SECRETS]: "Delete secrets",
|
||||
[EventType.CREATE_SECRETS]: "Create secrets",
|
||||
[EventType.UPDATE_SECRETS]: "Update secrets",
|
||||
[EventType.CREATE_SECRET]: "Create secret",
|
||||
[EventType.UPDATE_SECRET]: "Update secret",
|
||||
[EventType.DELETE_SECRET]: "Delete secret",
|
||||
@@ -90,6 +92,7 @@ export const eventToNameMap: { [K in EventType]: string } = {
|
||||
[EventType.UPDATE_CMEK]: "Update KMS key",
|
||||
[EventType.DELETE_CMEK]: "Delete KMS key",
|
||||
[EventType.GET_CMEKS]: "List KMS keys",
|
||||
[EventType.GET_CMEK]: "Get KMS key",
|
||||
[EventType.CMEK_ENCRYPT]: "Encrypt with KMS key",
|
||||
[EventType.CMEK_DECRYPT]: "Decrypt with KMS key",
|
||||
[EventType.UPDATE_EXTERNAL_GROUP_ORG_ROLE_MAPPINGS]:
|
||||
|
||||
@@ -20,6 +20,8 @@ export enum UserAgentType {
|
||||
export enum EventType {
|
||||
GET_SECRETS = "get-secrets",
|
||||
DELETE_SECRETS = "delete-secrets",
|
||||
CREATE_SECRETS = "create-secrets",
|
||||
UPDATE_SECRETS = "update-secrets",
|
||||
GET_SECRET = "get-secret",
|
||||
CREATE_SECRET = "create-secret",
|
||||
UPDATE_SECRET = "update-secret",
|
||||
@@ -105,6 +107,7 @@ export enum EventType {
|
||||
UPDATE_CMEK = "update-cmek",
|
||||
DELETE_CMEK = "delete-cmek",
|
||||
GET_CMEKS = "get-cmeks",
|
||||
GET_CMEK = "get-cmek",
|
||||
CMEK_ENCRYPT = "cmek-encrypt",
|
||||
CMEK_DECRYPT = "cmek-decrypt",
|
||||
UPDATE_EXTERNAL_GROUP_ORG_ROLE_MAPPINGS = "update-external-group-org-role-mapping",
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
export enum SecretSync {
|
||||
AWSParameterStore = "aws-parameter-store",
|
||||
AWSSecretsManager = "aws-secrets-manager",
|
||||
GitHub = "github",
|
||||
GCPSecretManager = "gcp-secret-manager"
|
||||
GCPSecretManager = "gcp-secret-manager",
|
||||
AzureKeyVault = "azure-key-vault",
|
||||
AzureAppConfiguration = "azure-app-configuration",
|
||||
Databricks = "databricks"
|
||||
}
|
||||
|
||||
export enum SecretSyncStatus {
|
||||
|
||||
@@ -23,7 +23,8 @@ export const useCreateSecretSync = () => {
|
||||
|
||||
return data.secretSync;
|
||||
},
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: secretSyncKeys.list() })
|
||||
onSuccess: (_, { projectId }) =>
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.list(projectId) })
|
||||
});
|
||||
};
|
||||
|
||||
@@ -38,8 +39,8 @@ export const useUpdateSecretSync = () => {
|
||||
|
||||
return data.secretSync;
|
||||
},
|
||||
onSuccess: (_, { syncId, destination }) => {
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.list() });
|
||||
onSuccess: (_, { syncId, destination, projectId }) => {
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.list(projectId) });
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.byId(destination, syncId) });
|
||||
}
|
||||
});
|
||||
@@ -55,8 +56,8 @@ export const useDeleteSecretSync = () => {
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { syncId, destination }) => {
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.list() });
|
||||
onSuccess: (_, { syncId, destination, projectId }) => {
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.list(projectId) });
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.byId(destination, syncId) });
|
||||
}
|
||||
});
|
||||
@@ -72,8 +73,8 @@ export const useTriggerSecretSyncSyncSecrets = () => {
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { syncId, destination }) => {
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.list() });
|
||||
onSuccess: (_, { syncId, destination, projectId }) => {
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.list(projectId) });
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.byId(destination, syncId) });
|
||||
}
|
||||
});
|
||||
@@ -93,8 +94,8 @@ export const useTriggerSecretSyncImportSecrets = () => {
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { syncId, destination }) => {
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.list() });
|
||||
onSuccess: (_, { syncId, destination, projectId }) => {
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.list(projectId) });
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.byId(destination, syncId) });
|
||||
}
|
||||
});
|
||||
@@ -110,8 +111,8 @@ export const useTriggerSecretSyncRemoveSecrets = () => {
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { syncId, destination }) => {
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.list() });
|
||||
onSuccess: (_, { syncId, destination, projectId }) => {
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.list(projectId) });
|
||||
queryClient.invalidateQueries({ queryKey: secretSyncKeys.byId(destination, syncId) });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
export const secretSyncKeys = {
|
||||
all: ["secret-sync"] as const,
|
||||
options: () => [...secretSyncKeys.all, "options"] as const,
|
||||
list: () => [...secretSyncKeys.all, "list"] as const,
|
||||
list: (projectId: string) => [...secretSyncKeys.all, "list", projectId] as const,
|
||||
byId: (destination: SecretSync, syncId: string) =>
|
||||
[...secretSyncKeys.all, destination, "by-id", syncId] as const
|
||||
};
|
||||
@@ -46,6 +46,14 @@ export const useSecretSyncOption = (destination: SecretSync) => {
|
||||
return { syncOption, isPending };
|
||||
};
|
||||
|
||||
export const fetchSecretSyncsByProjectId = async (projectId: string) => {
|
||||
const { data } = await apiRequest.get<TListSecretSyncs>("/api/v1/secret-syncs", {
|
||||
params: { projectId }
|
||||
});
|
||||
|
||||
return data.secretSyncs;
|
||||
};
|
||||
|
||||
export const useListSecretSyncs = (
|
||||
projectId: string,
|
||||
options?: Omit<
|
||||
@@ -54,14 +62,8 @@ export const useListSecretSyncs = (
|
||||
>
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: secretSyncKeys.list(),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<TListSecretSyncs>("/api/v1/secret-syncs", {
|
||||
params: { projectId }
|
||||
});
|
||||
|
||||
return data.secretSyncs;
|
||||
},
|
||||
queryKey: secretSyncKeys.list(projectId),
|
||||
queryFn: () => fetchSecretSyncsByProjectId(projectId),
|
||||
...options
|
||||
});
|
||||
};
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||
import { TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
|
||||
|
||||
export type TAwsSecretsManagerSync = TRootSecretSync & {
|
||||
destination: SecretSync.AWSSecretsManager;
|
||||
destinationConfig:
|
||||
| {
|
||||
mappingBehavior: AwsSecretsManagerSyncMappingBehavior.OneToOne;
|
||||
region: string;
|
||||
}
|
||||
| {
|
||||
region: string;
|
||||
mappingBehavior: AwsSecretsManagerSyncMappingBehavior.ManyToOne;
|
||||
secretName: string;
|
||||
};
|
||||
connection: {
|
||||
app: AppConnection.AWS;
|
||||
name: string;
|
||||
id: string;
|
||||
};
|
||||
};
|
||||
export enum AwsSecretsManagerSyncMappingBehavior {
|
||||
OneToOne = "one-to-one",
|
||||
ManyToOne = "many-to-one"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||
import { TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
|
||||
|
||||
export type TAzureAppConfigurationSync = TRootSecretSync & {
|
||||
destination: SecretSync.AzureAppConfiguration;
|
||||
destinationConfig: {
|
||||
configurationUrl: string;
|
||||
label?: string;
|
||||
};
|
||||
connection: {
|
||||
app: AppConnection.AzureAppConfiguration;
|
||||
name: string;
|
||||
id: string;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||
import { TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
|
||||
|
||||
export type TAzureKeyVaultSync = TRootSecretSync & {
|
||||
destination: SecretSync.AzureKeyVault;
|
||||
destinationConfig: {
|
||||
vaultBaseUrl: string;
|
||||
};
|
||||
connection: {
|
||||
app: AppConnection.AzureKeyVault;
|
||||
name: string;
|
||||
id: string;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||
import { TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
|
||||
|
||||
export type TDatabricksSync = TRootSecretSync & {
|
||||
destination: SecretSync.Databricks;
|
||||
destinationConfig: {
|
||||
scope: string;
|
||||
};
|
||||
connection: {
|
||||
app: AppConnection.Databricks;
|
||||
name: string;
|
||||
id: string;
|
||||
};
|
||||
};
|
||||
@@ -1,8 +1,12 @@
|
||||
import { SecretSync, SecretSyncImportBehavior } from "@app/hooks/api/secretSyncs";
|
||||
import { TAwsParameterStoreSync } from "@app/hooks/api/secretSyncs/types/aws-parameter-store-sync";
|
||||
import { TDatabricksSync } from "@app/hooks/api/secretSyncs/types/databricks-sync";
|
||||
import { TGitHubSync } from "@app/hooks/api/secretSyncs/types/github-sync";
|
||||
import { DiscriminativePick } from "@app/types";
|
||||
|
||||
import { TAwsSecretsManagerSync } from "./aws-secrets-manager-sync";
|
||||
import { TAzureAppConfigurationSync } from "./azure-app-configuration-sync";
|
||||
import { TAzureKeyVaultSync } from "./azure-key-vault-sync";
|
||||
import { TGcpSync } from "./gcp-sync";
|
||||
|
||||
export type TSecretSyncOption = {
|
||||
@@ -11,7 +15,14 @@ export type TSecretSyncOption = {
|
||||
canImportSecrets: boolean;
|
||||
};
|
||||
|
||||
export type TSecretSync = TAwsParameterStoreSync | TGitHubSync | TGcpSync;
|
||||
export type TSecretSync =
|
||||
| TAwsParameterStoreSync
|
||||
| TAwsSecretsManagerSync
|
||||
| TGitHubSync
|
||||
| TGcpSync
|
||||
| TAzureKeyVaultSync
|
||||
| TAzureAppConfigurationSync
|
||||
| TDatabricksSync;
|
||||
|
||||
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
|
||||
|
||||
@@ -34,26 +45,31 @@ export type TUpdateSecretSyncDTO = Partial<
|
||||
> & {
|
||||
destination: SecretSync;
|
||||
syncId: string;
|
||||
projectId: string;
|
||||
};
|
||||
|
||||
export type TDeleteSecretSyncDTO = {
|
||||
destination: SecretSync;
|
||||
syncId: string;
|
||||
removeSecrets: boolean;
|
||||
projectId: string;
|
||||
};
|
||||
|
||||
export type TTriggerSecretSyncSyncSecretsDTO = {
|
||||
destination: SecretSync;
|
||||
syncId: string;
|
||||
projectId: string;
|
||||
};
|
||||
|
||||
export type TTriggerSecretSyncImportSecretsDTO = {
|
||||
destination: SecretSync;
|
||||
syncId: string;
|
||||
importBehavior: SecretSyncImportBehavior;
|
||||
projectId: string;
|
||||
};
|
||||
|
||||
export type TTriggerSecretSyncRemoveSecretsDTO = {
|
||||
destination: SecretSync;
|
||||
syncId: string;
|
||||
projectId: string;
|
||||
};
|
||||
|
||||
@@ -206,7 +206,7 @@ export const useGetWorkspaceAuthorizations = <TData = IntegrationAuth[],>(
|
||||
select
|
||||
});
|
||||
|
||||
const fetchWorkspaceIntegrations = async (workspaceId: string) => {
|
||||
export const fetchWorkspaceIntegrations = async (workspaceId: string) => {
|
||||
const { data } = await apiRequest.get<{ integrations: TIntegration[] }>(
|
||||
`/api/v1/workspace/${workspaceId}/integrations`
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user