mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-02 20:25:47 +00:00
Only allow gateway for supported connections
This commit is contained in:
@@ -45,7 +45,10 @@ export const ValidateOracleDBConnectionCredentialsSchema = z.discriminatedUnion(
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
export const CreateOracleDBConnectionSchema = ValidateOracleDBConnectionCredentialsSchema.and(
|
export const CreateOracleDBConnectionSchema = ValidateOracleDBConnectionCredentialsSchema.and(
|
||||||
GenericCreateAppConnectionFieldsSchema(AppConnection.OracleDB, { supportsPlatformManagedCredentials: true })
|
GenericCreateAppConnectionFieldsSchema(AppConnection.OracleDB, {
|
||||||
|
supportsPlatformManagedCredentials: true,
|
||||||
|
supportsGateways: true
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
export const UpdateOracleDBConnectionSchema = z
|
export const UpdateOracleDBConnectionSchema = z
|
||||||
@@ -54,7 +57,12 @@ export const UpdateOracleDBConnectionSchema = z
|
|||||||
AppConnections.UPDATE(AppConnection.OracleDB).credentials
|
AppConnections.UPDATE(AppConnection.OracleDB).credentials
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.and(GenericUpdateAppConnectionFieldsSchema(AppConnection.OracleDB, { supportsPlatformManagedCredentials: true }));
|
.and(
|
||||||
|
GenericUpdateAppConnectionFieldsSchema(AppConnection.OracleDB, {
|
||||||
|
supportsPlatformManagedCredentials: true,
|
||||||
|
supportsGateways: true
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
export const OracleDBConnectionListItemSchema = z.object({
|
export const OracleDBConnectionListItemSchema = z.object({
|
||||||
name: z.literal("OracleDB"),
|
name: z.literal("OracleDB"),
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const BaseAppConnectionSchema = AppConnectionsSchema.omit({
|
|||||||
|
|
||||||
export const GenericCreateAppConnectionFieldsSchema = (
|
export const GenericCreateAppConnectionFieldsSchema = (
|
||||||
app: AppConnection,
|
app: AppConnection,
|
||||||
{ supportsPlatformManagedCredentials = false }: TAppConnectionBaseConfig = {}
|
{ supportsPlatformManagedCredentials = false, supportsGateways = false }: TAppConnectionBaseConfig = {}
|
||||||
) =>
|
) =>
|
||||||
z.object({
|
z.object({
|
||||||
name: slugSchema({ field: "name" }).describe(AppConnections.CREATE(app).name),
|
name: slugSchema({ field: "name" }).describe(AppConnections.CREATE(app).name),
|
||||||
@@ -31,12 +31,19 @@ export const GenericCreateAppConnectionFieldsSchema = (
|
|||||||
isPlatformManagedCredentials: supportsPlatformManagedCredentials
|
isPlatformManagedCredentials: supportsPlatformManagedCredentials
|
||||||
? z.boolean().optional().default(false).describe(AppConnections.CREATE(app).isPlatformManagedCredentials)
|
? z.boolean().optional().default(false).describe(AppConnections.CREATE(app).isPlatformManagedCredentials)
|
||||||
: z.literal(false).optional().describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`),
|
: z.literal(false).optional().describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`),
|
||||||
gatewayId: z.string().uuid().nullish().describe("The Gateway ID to use for this connection.")
|
gatewayId: supportsGateways
|
||||||
|
? z
|
||||||
|
.preprocess((val) => (val === "" ? null : val), z.string().uuid().nullish())
|
||||||
|
.describe("The Gateway ID to use for this connection.")
|
||||||
|
: z
|
||||||
|
.union([z.literal(undefined), z.literal("")])
|
||||||
|
.transform((v) => (v === "" ? undefined : v))
|
||||||
|
.describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`)
|
||||||
});
|
});
|
||||||
|
|
||||||
export const GenericUpdateAppConnectionFieldsSchema = (
|
export const GenericUpdateAppConnectionFieldsSchema = (
|
||||||
app: AppConnection,
|
app: AppConnection,
|
||||||
{ supportsPlatformManagedCredentials = false }: TAppConnectionBaseConfig = {}
|
{ supportsPlatformManagedCredentials = false, supportsGateways = false }: TAppConnectionBaseConfig = {}
|
||||||
) =>
|
) =>
|
||||||
z.object({
|
z.object({
|
||||||
name: slugSchema({ field: "name" }).describe(AppConnections.UPDATE(app).name).optional(),
|
name: slugSchema({ field: "name" }).describe(AppConnections.UPDATE(app).name).optional(),
|
||||||
@@ -49,5 +56,12 @@ export const GenericUpdateAppConnectionFieldsSchema = (
|
|||||||
isPlatformManagedCredentials: supportsPlatformManagedCredentials
|
isPlatformManagedCredentials: supportsPlatformManagedCredentials
|
||||||
? z.boolean().optional().describe(AppConnections.UPDATE(app).isPlatformManagedCredentials)
|
? z.boolean().optional().describe(AppConnections.UPDATE(app).isPlatformManagedCredentials)
|
||||||
: z.literal(false).optional().describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`),
|
: z.literal(false).optional().describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`),
|
||||||
gatewayId: z.string().uuid().nullish().describe("The Gateway ID to use for this connection.")
|
gatewayId: supportsGateways
|
||||||
|
? z
|
||||||
|
.preprocess((val) => (val === "" ? null : val), z.string().uuid().nullish())
|
||||||
|
.describe("The Gateway ID to use for this connection.")
|
||||||
|
: z
|
||||||
|
.union([z.literal(undefined), z.literal("")])
|
||||||
|
.transform((v) => (v === "" ? undefined : v))
|
||||||
|
.describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -382,4 +382,5 @@ export type TAppConnectionTransitionCredentialsToPlatform = (
|
|||||||
|
|
||||||
export type TAppConnectionBaseConfig = {
|
export type TAppConnectionBaseConfig = {
|
||||||
supportsPlatformManagedCredentials?: boolean;
|
supportsPlatformManagedCredentials?: boolean;
|
||||||
|
supportsGateways?: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,7 +49,10 @@ export const ValidateMsSqlConnectionCredentialsSchema = z.discriminatedUnion("me
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
export const CreateMsSqlConnectionSchema = ValidateMsSqlConnectionCredentialsSchema.and(
|
export const CreateMsSqlConnectionSchema = ValidateMsSqlConnectionCredentialsSchema.and(
|
||||||
GenericCreateAppConnectionFieldsSchema(AppConnection.MsSql, { supportsPlatformManagedCredentials: true })
|
GenericCreateAppConnectionFieldsSchema(AppConnection.MsSql, {
|
||||||
|
supportsPlatformManagedCredentials: true,
|
||||||
|
supportsGateways: true
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
export const UpdateMsSqlConnectionSchema = z
|
export const UpdateMsSqlConnectionSchema = z
|
||||||
@@ -58,7 +61,12 @@ export const UpdateMsSqlConnectionSchema = z
|
|||||||
AppConnections.UPDATE(AppConnection.MsSql).credentials
|
AppConnections.UPDATE(AppConnection.MsSql).credentials
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.and(GenericUpdateAppConnectionFieldsSchema(AppConnection.MsSql, { supportsPlatformManagedCredentials: true }));
|
.and(
|
||||||
|
GenericUpdateAppConnectionFieldsSchema(AppConnection.MsSql, {
|
||||||
|
supportsPlatformManagedCredentials: true,
|
||||||
|
supportsGateways: true
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
export const MsSqlConnectionListItemSchema = z.object({
|
export const MsSqlConnectionListItemSchema = z.object({
|
||||||
name: z.literal("Microsoft SQL Server"),
|
name: z.literal("Microsoft SQL Server"),
|
||||||
|
|||||||
@@ -47,7 +47,10 @@ export const ValidateMySqlConnectionCredentialsSchema = z.discriminatedUnion("me
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
export const CreateMySqlConnectionSchema = ValidateMySqlConnectionCredentialsSchema.and(
|
export const CreateMySqlConnectionSchema = ValidateMySqlConnectionCredentialsSchema.and(
|
||||||
GenericCreateAppConnectionFieldsSchema(AppConnection.MySql, { supportsPlatformManagedCredentials: true })
|
GenericCreateAppConnectionFieldsSchema(AppConnection.MySql, {
|
||||||
|
supportsPlatformManagedCredentials: true,
|
||||||
|
supportsGateways: true
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
export const UpdateMySqlConnectionSchema = z
|
export const UpdateMySqlConnectionSchema = z
|
||||||
@@ -56,7 +59,12 @@ export const UpdateMySqlConnectionSchema = z
|
|||||||
AppConnections.UPDATE(AppConnection.MySql).credentials
|
AppConnections.UPDATE(AppConnection.MySql).credentials
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.and(GenericUpdateAppConnectionFieldsSchema(AppConnection.MySql, { supportsPlatformManagedCredentials: true }));
|
.and(
|
||||||
|
GenericUpdateAppConnectionFieldsSchema(AppConnection.MySql, {
|
||||||
|
supportsPlatformManagedCredentials: true,
|
||||||
|
supportsGateways: true
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
export const MySqlConnectionListItemSchema = z.object({
|
export const MySqlConnectionListItemSchema = z.object({
|
||||||
name: z.literal("MySQL"),
|
name: z.literal("MySQL"),
|
||||||
|
|||||||
@@ -47,7 +47,10 @@ export const ValidatePostgresConnectionCredentialsSchema = z.discriminatedUnion(
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
export const CreatePostgresConnectionSchema = ValidatePostgresConnectionCredentialsSchema.and(
|
export const CreatePostgresConnectionSchema = ValidatePostgresConnectionCredentialsSchema.and(
|
||||||
GenericCreateAppConnectionFieldsSchema(AppConnection.Postgres, { supportsPlatformManagedCredentials: true })
|
GenericCreateAppConnectionFieldsSchema(AppConnection.Postgres, {
|
||||||
|
supportsPlatformManagedCredentials: true,
|
||||||
|
supportsGateways: true
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
export const UpdatePostgresConnectionSchema = z
|
export const UpdatePostgresConnectionSchema = z
|
||||||
@@ -56,7 +59,12 @@ export const UpdatePostgresConnectionSchema = z
|
|||||||
AppConnections.UPDATE(AppConnection.Postgres).credentials
|
AppConnections.UPDATE(AppConnection.Postgres).credentials
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.and(GenericUpdateAppConnectionFieldsSchema(AppConnection.Postgres, { supportsPlatformManagedCredentials: true }));
|
.and(
|
||||||
|
GenericUpdateAppConnectionFieldsSchema(AppConnection.Postgres, {
|
||||||
|
supportsPlatformManagedCredentials: true,
|
||||||
|
supportsGateways: true
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
export const PostgresConnectionListItemSchema = z.object({
|
export const PostgresConnectionListItemSchema = z.object({
|
||||||
name: z.literal("PostgreSQL"),
|
name: z.literal("PostgreSQL"),
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ import { slugSchema } from "@app/lib/schemas";
|
|||||||
export const genericAppConnectionFieldsSchema = z.object({
|
export const genericAppConnectionFieldsSchema = z.object({
|
||||||
name: slugSchema({ min: 1, max: 64, field: "Name" }),
|
name: slugSchema({ min: 1, max: 64, field: "Name" }),
|
||||||
description: z.string().trim().max(256, "Description cannot exceed 256 characters").nullish(),
|
description: z.string().trim().max(256, "Description cannot exceed 256 characters").nullish(),
|
||||||
gatewayId: z.string().uuid().nullish()
|
gatewayId: z.string().nullish()
|
||||||
});
|
});
|
||||||
|
|
||||||
export const GenericAppConnectionsFields = () => {
|
export const GenericAppConnectionsFields = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user