mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 06:45:28 +00:00
Merge branch 'auth0-connection-and-secret-rotation' into feat/azureClientSecretsRotation
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user