This commit is contained in:
Scott Wilson
2025-04-11 12:25:26 -07:00
parent 27fdf68e42
commit 581e4b35f9
120 changed files with 1963 additions and 423 deletions
@@ -9,5 +9,6 @@ export enum AppConnection {
Vercel = "vercel",
Postgres = "postgres",
MsSql = "mssql",
Camunda = "camunda"
Camunda = "camunda",
Auth0 = "auth0"
}
@@ -59,7 +59,7 @@ export const useGetAppConnectionOption = <T extends AppConnection>(app: T) => {
option: (options.find((opt) => opt.app === app) as TAppConnectionOptionMap[T]) ?? {},
isLoading: isPending
}),
[options, app]
[options, app, isPending]
);
};
@@ -55,6 +55,10 @@ export type TCamundaConnectionOption = TAppConnectionOptionBase & {
app: AppConnection.Camunda;
};
export type TAuth0ConnectionOption = TAppConnectionOptionBase & {
app: AppConnection.Auth0;
};
export type TAppConnectionOption =
| TAwsConnectionOption
| TGitHubConnectionOption
@@ -66,7 +70,8 @@ export type TAppConnectionOption =
| TVercelConnectionOption
| TPostgresConnectionOption
| TMsSqlConnectionOption
| TCamundaConnectionOption;
| TCamundaConnectionOption
| TAuth0ConnectionOption;
export type TAppConnectionOptionMap = {
[AppConnection.AWS]: TAwsConnectionOption;
@@ -80,4 +85,5 @@ export type TAppConnectionOptionMap = {
[AppConnection.Postgres]: TPostgresConnectionOption;
[AppConnection.MsSql]: TMsSqlConnectionOption;
[AppConnection.Camunda]: TCamundaConnectionOption;
[AppConnection.Auth0]: TAuth0ConnectionOption;
};
@@ -0,0 +1,17 @@
import { AppConnection } from "../enums";
import { TRootAppConnection } from "./root-connection";
export enum Auth0ConnectionMethod {
ClientCredentials = "client-credentials"
}
export type TAuth0Connection = TRootAppConnection & {
app: AppConnection.Auth0;
} & {
method: Auth0ConnectionMethod.ClientCredentials;
credentials: {
domain: string;
clientId: string;
audience: string;
};
};
@@ -1,5 +1,6 @@
import { AppConnection } from "../enums";
import { TAppConnectionOption } from "./app-options";
import { TAuth0Connection } from "./auth0-connection";
import { TAwsConnection } from "./aws-connection";
import { TAzureAppConfigurationConnection } from "./azure-app-configuration-connection";
import { TAzureKeyVaultConnection } from "./azure-key-vault-connection";
@@ -12,6 +13,7 @@ import { TMsSqlConnection } from "./mssql-connection";
import { TPostgresConnection } from "./postgres-connection";
import { TVercelConnection } from "./vercel-connection";
export * from "./auth0-connection";
export * from "./aws-connection";
export * from "./azure-app-configuration-connection";
export * from "./azure-key-vault-connection";
@@ -35,7 +37,8 @@ export type TAppConnection =
| TVercelConnection
| TPostgresConnection
| TMsSqlConnection
| TCamundaConnection;
| TCamundaConnection
| TAuth0Connection;
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id">;
@@ -74,4 +77,5 @@ export type TAppConnectionMap = {
[AppConnection.Postgres]: TPostgresConnection;
[AppConnection.MsSql]: TMsSqlConnection;
[AppConnection.Camunda]: TCamundaConnection;
[AppConnection.Auth0]: TAuth0Connection;
};
@@ -1,6 +1,7 @@
export enum SecretRotation {
PostgresCredentials = "postgres-credentials",
MsSqlCredentials = "mssql-credentials"
MsSqlCredentials = "mssql-credentials",
Auth0ClientSecret = "auth0-client-secret"
}
export enum SecretRotationStatus {
@@ -1,9 +1,12 @@
import { useMemo } from "react";
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { SecretRotation } from "@app/hooks/api/secretRotationsV2/enums";
import {
TListSecretRotationV2Options,
TSecretRotationGeneratedCredentialsResponseMap,
TSecretRotationOptionMap,
TSecretRotationV2Option,
TViewSecretRotationGeneratedCredentialsResponse,
TViewSecretRotationV2GeneratedCredentialsDTO
@@ -40,15 +43,21 @@ export const useSecretRotationV2Options = (
});
};
export const useSecretRotationV2Option = (type: SecretRotation) => {
export const useSecretRotationV2Option = <T extends SecretRotation>(type: T) => {
const { data: rotationOptions, isPending } = useSecretRotationV2Options();
const rotationOption = rotationOptions?.find((option) => option.type === type);
return { rotationOption, isPending };
return useMemo(
() => ({
rotationOption:
(rotationOptions?.find((opt) => opt.type === type) as TSecretRotationOptionMap[T]) ??
undefined,
isLoading: isPending
}),
[rotationOptions, type, isPending]
);
};
export const useViewSecretRotationV2GeneratedCredentials = (
{ rotationId, type }: TViewSecretRotationV2GeneratedCredentialsDTO,
export const useViewSecretRotationV2GeneratedCredentials = <T extends SecretRotation>(
{ rotationId, type }: { rotationId: string; type: T },
options?: Omit<
UseQueryOptions<
TViewSecretRotationGeneratedCredentialsResponse,
@@ -66,7 +75,7 @@ export const useViewSecretRotationV2GeneratedCredentials = (
`/api/v2/secret-rotations/${type}/${rotationId}/generated-credentials`
);
return data;
return data as TSecretRotationGeneratedCredentialsResponseMap[T];
},
...options
});
@@ -0,0 +1,37 @@
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
import {
TSecretRotationV2Base,
TSecretRotationV2GeneratedCredentialsResponseBase
} from "@app/hooks/api/secretRotationsV2/types/shared";
export type TAuth0ClientSecretRotation = TSecretRotationV2Base & {
type: SecretRotation.Auth0ClientSecret;
parameters: {
clientId: string;
};
secretsMapping: {
clientId: string;
clientSecret: string;
};
};
export type TAuth0ClientSecretRotationGeneratedCredentials = {
clientId: string;
clientSecret: string;
};
export type TAuth0ClientSecretRotationGeneratedCredentialsResponse =
TSecretRotationV2GeneratedCredentialsResponseBase<
SecretRotation.Auth0ClientSecret,
TAuth0ClientSecretRotationGeneratedCredentials
>;
export type TAuth0ClientSecretRotationOption = {
name: string;
type: SecretRotation.Auth0ClientSecret;
connection: AppConnection.Auth0;
template: {
secretsMapping: TAuth0ClientSecretRotation["secretsMapping"];
};
};
@@ -1,5 +1,9 @@
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
import {
TAuth0ClientSecretRotation,
TAuth0ClientSecretRotationGeneratedCredentialsResponse,
TAuth0ClientSecretRotationOption
} from "@app/hooks/api/secretRotationsV2/types/auth0-client-secret-rotation";
import {
TMsSqlCredentialsRotation,
TMsSqlCredentialsRotationGeneratedCredentialsResponse
@@ -8,20 +12,21 @@ import {
TPostgresCredentialsRotation,
TPostgresCredentialsRotationGeneratedCredentialsResponse
} from "@app/hooks/api/secretRotationsV2/types/postgres-credentials-rotation";
import { TSqlOptionTemplate } from "@app/hooks/api/secretRotationsV2/types/shared";
import { TSqlCredentialsRotationOption } from "@app/hooks/api/secretRotationsV2/types/shared";
import { SecretV3RawSanitized } from "@app/hooks/api/secrets/types";
import { DiscriminativePick } from "@app/types";
export type TSecretRotationV2 = (TPostgresCredentialsRotation | TMsSqlCredentialsRotation) & {
export type TSecretRotationV2 = (
| TPostgresCredentialsRotation
| TMsSqlCredentialsRotation
| TAuth0ClientSecretRotation
) & {
secrets: (SecretV3RawSanitized | null)[];
};
export type TSecretRotationV2Option = {
name: string;
type: SecretRotation;
connection: AppConnection;
template: TSqlOptionTemplate;
};
export type TSecretRotationV2Option =
| TSqlCredentialsRotationOption
| TAuth0ClientSecretRotationOption;
export type TListSecretRotationV2Options = { secretRotationOptions: TSecretRotationV2Option[] };
@@ -29,7 +34,8 @@ export type TSecretRotationV2Response = { secretRotation: TSecretRotationV2 };
export type TViewSecretRotationGeneratedCredentialsResponse =
| TPostgresCredentialsRotationGeneratedCredentialsResponse
| TMsSqlCredentialsRotationGeneratedCredentialsResponse;
| TMsSqlCredentialsRotationGeneratedCredentialsResponse
| TAuth0ClientSecretRotationGeneratedCredentialsResponse;
export type TCreateSecretRotationV2DTO = DiscriminativePick<
TSecretRotationV2,
@@ -71,3 +77,15 @@ export type TViewSecretRotationV2GeneratedCredentialsDTO = {
rotationId: string;
type: SecretRotation;
};
export type TSecretRotationOptionMap = {
[SecretRotation.PostgresCredentials]: TSqlCredentialsRotationOption;
[SecretRotation.MsSqlCredentials]: TSqlCredentialsRotationOption;
[SecretRotation.Auth0ClientSecret]: TAuth0ClientSecretRotationOption;
};
export type TSecretRotationGeneratedCredentialsResponseMap = {
[SecretRotation.PostgresCredentials]: TPostgresCredentialsRotationGeneratedCredentialsResponse;
[SecretRotation.MsSqlCredentials]: TMsSqlCredentialsRotationGeneratedCredentialsResponse;
[SecretRotation.Auth0ClientSecret]: TAuth0ClientSecretRotationGeneratedCredentialsResponse;
};
@@ -1,3 +1,6 @@
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
export type TSqlCredentialsRotationProperties = {
parameters: {
username1: string;
@@ -9,9 +12,14 @@ export type TSqlCredentialsRotationProperties = {
};
};
export type TSqlOptionTemplate = {
secretsMapping: TSqlCredentialsRotationProperties["secretsMapping"];
createUserStatement: string;
export type TSqlCredentialsRotationOption = {
name: string;
type: SecretRotation.PostgresCredentials | SecretRotation.MsSqlCredentials;
connection: AppConnection.Postgres | AppConnection.MsSql;
template: {
secretsMapping: TSqlCredentialsRotationProperties["secretsMapping"];
createUserStatement: string;
};
};
export type TSqlCredentialsRotationGeneratedCredentials = {