mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 21:37:59 +00:00
feature secret rotations v2
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
export * from "./postgres-connection-enums";
|
||||
export * from "./postgres-connection-fns";
|
||||
export * from "./postgres-connection-schemas";
|
||||
export * from "./postgres-connection-types";
|
||||
@@ -0,0 +1,3 @@
|
||||
export enum PostgresConnectionMethod {
|
||||
UsernameAndPassword = "username-and-password"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||
|
||||
import { PostgresConnectionMethod } from "./postgres-connection-enums";
|
||||
|
||||
export const getPostgresConnectionListItem = () => {
|
||||
return {
|
||||
name: "PostgreSQL" as const,
|
||||
app: AppConnection.Postgres as const,
|
||||
methods: Object.values(PostgresConnectionMethod) as [PostgresConnectionMethod.UsernameAndPassword],
|
||||
supportsPlatformManagement: true as const
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
import z from "zod";
|
||||
|
||||
import { AppConnections } from "@app/lib/api-docs";
|
||||
import {
|
||||
BaseAppConnectionSchema,
|
||||
GenericCreateAppConnectionFieldsSchema,
|
||||
GenericUpdateAppConnectionFieldsSchema
|
||||
} from "@app/services/app-connection/app-connection-schemas";
|
||||
|
||||
import { AppConnection } from "../app-connection-enums";
|
||||
import { BaseSqlUsernameAndPasswordConnectionSchema } from "../shared/sql";
|
||||
import { PostgresConnectionMethod } from "./postgres-connection-enums";
|
||||
|
||||
export const PostgresConnectionAccessTokenCredentialsSchema = BaseSqlUsernameAndPasswordConnectionSchema;
|
||||
|
||||
const BasePostgresConnectionSchema = BaseAppConnectionSchema.extend({ app: z.literal(AppConnection.Postgres) });
|
||||
|
||||
export const PostgresConnectionSchema = BasePostgresConnectionSchema.extend({
|
||||
method: z.literal(PostgresConnectionMethod.UsernameAndPassword),
|
||||
credentials: PostgresConnectionAccessTokenCredentialsSchema
|
||||
});
|
||||
|
||||
export const SanitizedPostgresConnectionSchema = z.discriminatedUnion("method", [
|
||||
BasePostgresConnectionSchema.extend({
|
||||
method: z.literal(PostgresConnectionMethod.UsernameAndPassword),
|
||||
credentials: PostgresConnectionAccessTokenCredentialsSchema.pick({
|
||||
host: true,
|
||||
database: true,
|
||||
port: true,
|
||||
username: true
|
||||
})
|
||||
})
|
||||
]);
|
||||
|
||||
export const ValidatePostgresConnectionCredentialsSchema = z.discriminatedUnion("method", [
|
||||
z.object({
|
||||
method: z
|
||||
.literal(PostgresConnectionMethod.UsernameAndPassword)
|
||||
.describe(AppConnections.CREATE(AppConnection.Postgres).method),
|
||||
credentials: PostgresConnectionAccessTokenCredentialsSchema.describe(
|
||||
AppConnections.CREATE(AppConnection.Postgres).credentials
|
||||
)
|
||||
})
|
||||
]);
|
||||
|
||||
export const CreatePostgresConnectionSchema = ValidatePostgresConnectionCredentialsSchema.and(
|
||||
GenericCreateAppConnectionFieldsSchema(AppConnection.Postgres, { supportsPlatformManagedCredentials: true })
|
||||
);
|
||||
|
||||
export const UpdatePostgresConnectionSchema = z
|
||||
.object({
|
||||
credentials: PostgresConnectionAccessTokenCredentialsSchema.optional().describe(
|
||||
AppConnections.UPDATE(AppConnection.Postgres).credentials
|
||||
)
|
||||
})
|
||||
.and(GenericUpdateAppConnectionFieldsSchema(AppConnection.Postgres, { supportsPlatformManagedCredentials: true }));
|
||||
|
||||
export const PostgresConnectionListItemSchema = z.object({
|
||||
name: z.literal("PostgreSQL"),
|
||||
app: z.literal(AppConnection.Postgres),
|
||||
methods: z.nativeEnum(PostgresConnectionMethod).array(),
|
||||
supportsPlatformManagement: z.literal(true)
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
import z from "zod";
|
||||
|
||||
import { AppConnection } from "../app-connection-enums";
|
||||
import {
|
||||
CreatePostgresConnectionSchema,
|
||||
PostgresConnectionSchema,
|
||||
ValidatePostgresConnectionCredentialsSchema
|
||||
} from "./postgres-connection-schemas";
|
||||
|
||||
export type TPostgresConnection = z.infer<typeof PostgresConnectionSchema>;
|
||||
|
||||
export type TPostgresConnectionInput = z.infer<typeof CreatePostgresConnectionSchema> & {
|
||||
app: AppConnection.Postgres;
|
||||
};
|
||||
|
||||
export type TValidatePostgresConnectionCredentials = typeof ValidatePostgresConnectionCredentialsSchema;
|
||||
Reference in New Issue
Block a user