mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 04:14:38 +00:00
improvements: address feedback
This commit is contained in:
+3
-35
@@ -1,10 +1,8 @@
|
||||
import { Controller, useFormContext } from "react-hook-form";
|
||||
import { faCircleInfo } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
|
||||
import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
|
||||
import { DEFAULT_PASSWORD_REQUIREMENTS } from "@app/components/secret-rotations-v2/forms/schemas/shared";
|
||||
import { FormControl, Input, Tooltip } from "@app/components/v2";
|
||||
import { FormControl, Input } from "@app/components/v2";
|
||||
import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
|
||||
|
||||
export const LdapPasswordRotationParametersFields = () => {
|
||||
@@ -24,37 +22,7 @@ export const LdapPasswordRotationParametersFields = () => {
|
||||
isError={Boolean(error)}
|
||||
errorText={error?.message}
|
||||
label="Distinguished Name (DN)"
|
||||
helperText={
|
||||
<Tooltip
|
||||
className="max-w-md"
|
||||
content={
|
||||
<>
|
||||
Ensure that your connection has the{" "}
|
||||
<span className="font-semibold">read_clients</span> permission and the
|
||||
application exists in the connection's audience.
|
||||
</>
|
||||
}
|
||||
>
|
||||
<div>
|
||||
<span>Don't see the application you're looking for?</span>{" "}
|
||||
<FontAwesomeIcon icon={faCircleInfo} className="text-mineshaft-400" />
|
||||
</div>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{/* <FilterableSelect
|
||||
menuPlacement="top"
|
||||
isLoading={isClientsPending && Boolean(connectionId)}
|
||||
isDisabled={!connectionId}
|
||||
value={clients?.find((client) => client.id === value) ?? null}
|
||||
onChange={(option) => {
|
||||
onChange((option as SingleValue<TAuth0Client>)?.id ?? null);
|
||||
}}
|
||||
options={clients}
|
||||
placeholder="Select an application..."
|
||||
getOptionLabel={(option) => option.name}
|
||||
getOptionValue={(option) => option.id}
|
||||
/> */}
|
||||
<Input
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
@@ -74,7 +42,7 @@ export const LdapPasswordRotationParametersFields = () => {
|
||||
defaultValue={DEFAULT_PASSWORD_REQUIREMENTS.length}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<FormControl
|
||||
label="Passsword Length"
|
||||
label="Password Length"
|
||||
isError={Boolean(error)}
|
||||
errorText={error?.message}
|
||||
helperText="The length of the password to generate"
|
||||
@@ -189,7 +157,7 @@ export const LdapPasswordRotationParametersFields = () => {
|
||||
placeholder="-_.~!*"
|
||||
size="sm"
|
||||
{...field}
|
||||
onChange={(e) => field.onChange(Number(e.target.value))}
|
||||
onChange={(e) => field.onChange(e.target.value)}
|
||||
/>
|
||||
</FormControl>
|
||||
)}
|
||||
|
||||
+10
-1
@@ -15,8 +15,17 @@ export const PasswordRequirementsSchema = z
|
||||
allowedSymbols: z
|
||||
.string()
|
||||
.optional()
|
||||
.transform((value) => value ?? "-_.~!*")
|
||||
.transform((value) => value || "-_.~!*")
|
||||
})
|
||||
.refine(
|
||||
(data) => {
|
||||
return Object.values(data.required).some((count) => count > 0);
|
||||
},
|
||||
{
|
||||
message: "At least one character type must be required",
|
||||
path: ["required.digits"]
|
||||
}
|
||||
)
|
||||
.refine(
|
||||
(data) => {
|
||||
const total = Object.values(data.required).reduce((sum, count) => sum + count, 0);
|
||||
|
||||
@@ -52,7 +52,7 @@ export const APP_CONNECTION_MAP: Record<
|
||||
[AppConnection.Camunda]: { name: "Camunda", image: "Camunda.png" },
|
||||
[AppConnection.Windmill]: { name: "Windmill", image: "Windmill.png" },
|
||||
[AppConnection.Auth0]: { name: "Auth0", image: "Auth0.png", size: 40 },
|
||||
[AppConnection.Ldap]: { name: "LDAP", image: "LDAP.png", size: 65 }
|
||||
[AppConnection.LDAP]: { name: "LDAP", image: "LDAP.png", size: 65 }
|
||||
};
|
||||
|
||||
export const getAppConnectionMethodDetails = (method: TAppConnection["method"]) => {
|
||||
|
||||
@@ -31,7 +31,7 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio
|
||||
[SecretRotation.PostgresCredentials]: AppConnection.Postgres,
|
||||
[SecretRotation.MsSqlCredentials]: AppConnection.MsSql,
|
||||
[SecretRotation.Auth0ClientSecret]: AppConnection.Auth0,
|
||||
[SecretRotation.LdapPassword]: AppConnection.Ldap
|
||||
[SecretRotation.LdapPassword]: AppConnection.LDAP
|
||||
};
|
||||
|
||||
// if a rotation can potentially have downtime due to rotating a single credential set this to false
|
||||
|
||||
@@ -13,5 +13,5 @@ export enum AppConnection {
|
||||
Camunda = "camunda",
|
||||
Windmill = "windmill",
|
||||
Auth0 = "auth0",
|
||||
Ldap = "ldap"
|
||||
LDAP = "ldap"
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ export type TAuth0ConnectionOption = TAppConnectionOptionBase & {
|
||||
};
|
||||
|
||||
export type TLdapConnectionOption = TAppConnectionOptionBase & {
|
||||
app: AppConnection.Ldap;
|
||||
app: AppConnection.LDAP;
|
||||
};
|
||||
|
||||
export type TAppConnectionOption =
|
||||
@@ -102,5 +102,5 @@ export type TAppConnectionOptionMap = {
|
||||
[AppConnection.Camunda]: TCamundaConnectionOption;
|
||||
[AppConnection.Windmill]: TWindmillConnectionOption;
|
||||
[AppConnection.Auth0]: TAuth0ConnectionOption;
|
||||
[AppConnection.Ldap]: TLdapConnectionOption;
|
||||
[AppConnection.LDAP]: TLdapConnectionOption;
|
||||
};
|
||||
|
||||
@@ -89,5 +89,5 @@ export type TAppConnectionMap = {
|
||||
[AppConnection.Camunda]: TCamundaConnection;
|
||||
[AppConnection.Windmill]: TWindmillConnection;
|
||||
[AppConnection.Auth0]: TAuth0Connection;
|
||||
[AppConnection.Ldap]: TLdapConnection;
|
||||
[AppConnection.LDAP]: TLdapConnection;
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ export enum LdapConnectionProvider {
|
||||
ActiveDirectory = "active-directory"
|
||||
}
|
||||
|
||||
export type TLdapConnection = TRootAppConnection & { app: AppConnection.Ldap } & {
|
||||
export type TLdapConnection = TRootAppConnection & { app: AppConnection.LDAP } & {
|
||||
method: LdapConnectionMethod.SimpleBind;
|
||||
credentials: {
|
||||
provider: LdapConnectionProvider;
|
||||
|
||||
@@ -30,7 +30,7 @@ export type TLdapPasswordRotationGeneratedCredentialsResponse =
|
||||
export type TLdapPasswordRotationOption = {
|
||||
name: string;
|
||||
type: SecretRotation.LdapPassword;
|
||||
connection: AppConnection.Ldap;
|
||||
connection: AppConnection.LDAP;
|
||||
template: {
|
||||
secretsMapping: TLdapPasswordRotation["secretsMapping"];
|
||||
};
|
||||
|
||||
+2
-2
@@ -90,7 +90,7 @@ const CreateForm = ({ app, onComplete }: CreateFormProps) => {
|
||||
return <WindmillConnectionForm onSubmit={onSubmit} />;
|
||||
case AppConnection.Auth0:
|
||||
return <Auth0ConnectionForm onSubmit={onSubmit} />;
|
||||
case AppConnection.Ldap:
|
||||
case AppConnection.LDAP:
|
||||
return <LdapConnectionForm onSubmit={onSubmit} />;
|
||||
default:
|
||||
throw new Error(`Unhandled App ${app}`);
|
||||
@@ -156,7 +156,7 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {
|
||||
return <WindmillConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
||||
case AppConnection.Auth0:
|
||||
return <Auth0ConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
||||
case AppConnection.Ldap:
|
||||
case AppConnection.LDAP:
|
||||
return <LdapConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
||||
default:
|
||||
throw new Error(`Unhandled App ${(appConnection as TAppConnection).app}`);
|
||||
|
||||
+12
-7
@@ -37,7 +37,7 @@ type Props = {
|
||||
};
|
||||
|
||||
const rootSchema = genericAppConnectionFieldsSchema.extend({
|
||||
app: z.literal(AppConnection.Ldap)
|
||||
app: z.literal(AppConnection.LDAP)
|
||||
});
|
||||
|
||||
const formSchema = z.discriminatedUnion("method", [
|
||||
@@ -45,7 +45,12 @@ const formSchema = z.discriminatedUnion("method", [
|
||||
method: z.literal(LdapConnectionMethod.SimpleBind),
|
||||
credentials: z.object({
|
||||
provider: z.nativeEnum(LdapConnectionProvider),
|
||||
url: z.string().url().trim().min(1, "LDAP URL required"),
|
||||
url: z
|
||||
.string()
|
||||
.regex(/^ldaps?:\/\//, 'Must start with "ldaps://" or "ldap://"')
|
||||
.url()
|
||||
.trim()
|
||||
.min(1, "LDAP URL required"),
|
||||
dn: z.string().trim().min(1, "Distinguished Name (DN) required"),
|
||||
password: z.string().trim().min(1, "Password required"),
|
||||
sslRejectUnauthorized: z.boolean(),
|
||||
@@ -67,7 +72,7 @@ export const LdapConnectionForm = ({ appConnection, onSubmit }: Props) => {
|
||||
const form = useForm<FormData>({
|
||||
resolver: zodResolver(formSchema),
|
||||
defaultValues: appConnection ?? {
|
||||
app: AppConnection.Ldap,
|
||||
app: AppConnection.LDAP,
|
||||
method: LdapConnectionMethod.SimpleBind,
|
||||
credentials: {
|
||||
provider: LdapConnectionProvider.ActiveDirectory,
|
||||
@@ -88,7 +93,7 @@ export const LdapConnectionForm = ({ appConnection, onSubmit }: Props) => {
|
||||
} = form;
|
||||
|
||||
const selectedProvider = watch("credentials.provider");
|
||||
const sslEnabled = watch("credentials.url").startsWith("ldaps://");
|
||||
const sslEnabled = watch("credentials.url")?.startsWith("ldaps://") ?? false;
|
||||
|
||||
return (
|
||||
<FormProvider {...form}>
|
||||
@@ -106,7 +111,7 @@ export const LdapConnectionForm = ({ appConnection, onSubmit }: Props) => {
|
||||
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||
<FormControl
|
||||
tooltipText={`The method you would like to use to connect with ${
|
||||
APP_CONNECTION_MAP[AppConnection.Ldap].name
|
||||
APP_CONNECTION_MAP[AppConnection.LDAP].name
|
||||
}. This field cannot be changed after creation.`}
|
||||
errorText={error?.message}
|
||||
isError={Boolean(error?.message)}
|
||||
@@ -213,7 +218,7 @@ export const LdapConnectionForm = ({ appConnection, onSubmit }: Props) => {
|
||||
<FormControl
|
||||
errorText={error?.message}
|
||||
isError={Boolean(error?.message)}
|
||||
label="Binding Distinguised Name (DN)"
|
||||
label="Binding Distinguished Name (DN)"
|
||||
>
|
||||
<Input {...field} placeholder="CN=John,OU=Users,DC=example,DC=com" />
|
||||
</FormControl>
|
||||
@@ -263,7 +268,7 @@ export const LdapConnectionForm = ({ appConnection, onSubmit }: Props) => {
|
||||
control={control}
|
||||
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||
<FormControl
|
||||
className={` ${sslEnabled ? "" : "opacity-50"}`}
|
||||
className={sslEnabled ? "" : "opacity-50"}
|
||||
isError={Boolean(error?.message)}
|
||||
errorText={error?.message}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user