mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 18:27:19 +00:00
Add dns made easy UI
This commit is contained in:
@@ -26,14 +26,14 @@ interface DNSMadeEasyApiResponse {
|
|||||||
|
|
||||||
export const makeDNSMadeEasyAuthHeaders = (
|
export const makeDNSMadeEasyAuthHeaders = (
|
||||||
apiKey: string,
|
apiKey: string,
|
||||||
apiSecret: string,
|
secretKey: string,
|
||||||
currentDate: Date = new Date()
|
currentDate: Date = new Date()
|
||||||
): Record<string, string> => {
|
): Record<string, string> => {
|
||||||
// Format date as "Day, DD Mon YYYY HH:MM:SS GMT" (e.g., "Mon, 01 Jan 2024 12:00:00 GMT")
|
// Format date as "Day, DD Mon YYYY HH:MM:SS GMT" (e.g., "Mon, 01 Jan 2024 12:00:00 GMT")
|
||||||
const requestDate = currentDate.toUTCString();
|
const requestDate = currentDate.toUTCString();
|
||||||
|
|
||||||
// Generate HMAC-SHA1 signature
|
// Generate HMAC-SHA1 signature
|
||||||
const hmac = crypto.nativeCrypto.createHmac("sha1", apiSecret);
|
const hmac = crypto.nativeCrypto.createHmac("sha1", secretKey);
|
||||||
hmac.update(requestDate);
|
hmac.update(requestDate);
|
||||||
const hmacSignature = hmac.digest("hex");
|
const hmacSignature = hmac.digest("hex");
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ export const listDNSMadeEasyZones = async (appConnection: TDNSMadeEasyConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
credentials: { apiKey, apiSecret }
|
credentials: { apiKey, secretKey }
|
||||||
} = appConnection;
|
} = appConnection;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -89,12 +89,12 @@ export const validateDNSMadeEasyConnectionCredentials = async (config: TDNSMadeE
|
|||||||
throw new Error("Unsupported DNS Made Easy connection method");
|
throw new Error("Unsupported DNS Made Easy connection method");
|
||||||
}
|
}
|
||||||
|
|
||||||
const { apiKey, apiSecret } = config.credentials;
|
const { apiKey, secretKey } = config.credentials;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await request.get(`${IntegrationUrls.DNS_MADE_EASY_API_URL}/V2.0/dns/managed/`, {
|
const resp = await request.get(`${IntegrationUrls.DNS_MADE_EASY_API_URL}/V2.0/dns/managed/`, {
|
||||||
headers: {
|
headers: {
|
||||||
...makeDNSMadeEasyAuthHeaders(apiKey, apiSecret),
|
...makeDNSMadeEasyAuthHeaders(apiKey, secretKey),
|
||||||
Accept: "application/json"
|
Accept: "application/json"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ import { DNSMadeEasyConnectionMethod } from "./dns-made-easy-connection-enum";
|
|||||||
|
|
||||||
export const DNSMadeEasyConnectionApiKeyCredentialsSchema = z.object({
|
export const DNSMadeEasyConnectionApiKeyCredentialsSchema = z.object({
|
||||||
apiKey: z.string().trim().min(1, "API key required").max(256, "API key cannot exceed 256 characters"),
|
apiKey: z.string().trim().min(1, "API key required").max(256, "API key cannot exceed 256 characters"),
|
||||||
apiSecret: z.string().trim().min(1, "API secret required").max(256, "API secret cannot exceed 256 characters")
|
secretKey: z.string().trim().min(1, "Secret key required").max(256, "Secret key cannot exceed 256 characters")
|
||||||
});
|
});
|
||||||
|
|
||||||
const BaseDNSMadeEasyConnectionSchema = BaseAppConnectionSchema.extend({
|
const BaseDNSMadeEasyConnectionSchema = BaseAppConnectionSchema.extend({
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export const APP_CONNECTION_MAP: Record<
|
|||||||
[AppConnection.Flyio]: { name: "Fly.io", image: "Flyio.svg" },
|
[AppConnection.Flyio]: { name: "Fly.io", image: "Flyio.svg" },
|
||||||
[AppConnection.GitLab]: { name: "GitLab", image: "GitLab.png" },
|
[AppConnection.GitLab]: { name: "GitLab", image: "GitLab.png" },
|
||||||
[AppConnection.Cloudflare]: { name: "Cloudflare", image: "Cloudflare.png" },
|
[AppConnection.Cloudflare]: { name: "Cloudflare", image: "Cloudflare.png" },
|
||||||
[AppConnection.DNSMadeEasy]: { name: "DNS Made Easy", image: "DNSMadeEasy.svg" },
|
[AppConnection.DNSMadeEasy]: { name: "DNS Made Easy", image: "DNSMadeEasy.svg", size: 120 },
|
||||||
[AppConnection.Zabbix]: { name: "Zabbix", image: "Zabbix.png" },
|
[AppConnection.Zabbix]: { name: "Zabbix", image: "Zabbix.png" },
|
||||||
[AppConnection.Railway]: { name: "Railway", image: "Railway.png" },
|
[AppConnection.Railway]: { name: "Railway", image: "Railway.png" },
|
||||||
[AppConnection.Bitbucket]: { name: "Bitbucket", image: "Bitbucket.png" },
|
[AppConnection.Bitbucket]: { name: "Bitbucket", image: "Bitbucket.png" },
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export enum DNSMadeEasyConnectionMethod {
|
|||||||
export type TDNSMadeEasyConnection = TRootAppConnection & { app: AppConnection.DNSMadeEasy } & {
|
export type TDNSMadeEasyConnection = TRootAppConnection & { app: AppConnection.DNSMadeEasy } & {
|
||||||
method: DNSMadeEasyConnectionMethod.APIKeySecret;
|
method: DNSMadeEasyConnectionMethod.APIKeySecret;
|
||||||
credentials: {
|
credentials: {
|
||||||
apiToken: string;
|
apiKey: string;
|
||||||
accountId: string;
|
secretKey: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ export * from "./camunda-connection";
|
|||||||
export * from "./checkly-connection";
|
export * from "./checkly-connection";
|
||||||
export * from "./chef-connection";
|
export * from "./chef-connection";
|
||||||
export * from "./cloudflare-connection";
|
export * from "./cloudflare-connection";
|
||||||
|
export * from "./dns-made-easy-connection";
|
||||||
export * from "./databricks-connection";
|
export * from "./databricks-connection";
|
||||||
export * from "./flyio-connection";
|
export * from "./flyio-connection";
|
||||||
export * from "./gcp-connection";
|
export * from "./gcp-connection";
|
||||||
|
|||||||
+5
@@ -24,6 +24,7 @@ import { ChefConnectionForm } from "./ChefConnectionForm";
|
|||||||
import { CloudflareConnectionForm } from "./CloudflareConnectionForm";
|
import { CloudflareConnectionForm } from "./CloudflareConnectionForm";
|
||||||
import { DatabricksConnectionForm } from "./DatabricksConnectionForm";
|
import { DatabricksConnectionForm } from "./DatabricksConnectionForm";
|
||||||
import { DigitalOceanConnectionForm } from "./DigitalOceanConnectionForm";
|
import { DigitalOceanConnectionForm } from "./DigitalOceanConnectionForm";
|
||||||
|
import { DNSMadeEasyConnectionForm } from "./DNSMadeEasyConnectionForm";
|
||||||
import { FlyioConnectionForm } from "./FlyioConnectionForm";
|
import { FlyioConnectionForm } from "./FlyioConnectionForm";
|
||||||
import { GcpConnectionForm } from "./GcpConnectionForm";
|
import { GcpConnectionForm } from "./GcpConnectionForm";
|
||||||
import { GitHubConnectionForm } from "./GitHubConnectionForm";
|
import { GitHubConnectionForm } from "./GitHubConnectionForm";
|
||||||
@@ -148,6 +149,8 @@ const CreateForm = ({ app, onComplete, projectId }: CreateFormProps) => {
|
|||||||
return <GitLabConnectionForm onSubmit={onSubmit} projectId={projectId} />;
|
return <GitLabConnectionForm onSubmit={onSubmit} projectId={projectId} />;
|
||||||
case AppConnection.Cloudflare:
|
case AppConnection.Cloudflare:
|
||||||
return <CloudflareConnectionForm onSubmit={onSubmit} />;
|
return <CloudflareConnectionForm onSubmit={onSubmit} />;
|
||||||
|
case AppConnection.DNSMadeEasy:
|
||||||
|
return <DNSMadeEasyConnectionForm onSubmit={onSubmit} />;
|
||||||
case AppConnection.Bitbucket:
|
case AppConnection.Bitbucket:
|
||||||
return <BitbucketConnectionForm onSubmit={onSubmit} />;
|
return <BitbucketConnectionForm onSubmit={onSubmit} />;
|
||||||
case AppConnection.Zabbix:
|
case AppConnection.Zabbix:
|
||||||
@@ -306,6 +309,8 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {
|
|||||||
);
|
);
|
||||||
case AppConnection.Cloudflare:
|
case AppConnection.Cloudflare:
|
||||||
return <CloudflareConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
return <CloudflareConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
||||||
|
case AppConnection.DNSMadeEasy:
|
||||||
|
return <DNSMadeEasyConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
||||||
case AppConnection.Bitbucket:
|
case AppConnection.Bitbucket:
|
||||||
return <BitbucketConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
return <BitbucketConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
||||||
case AppConnection.Zabbix:
|
case AppConnection.Zabbix:
|
||||||
|
|||||||
+157
@@ -0,0 +1,157 @@
|
|||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { Controller, FormProvider, useForm } from "react-hook-form";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
FormControl,
|
||||||
|
Input,
|
||||||
|
ModalClose,
|
||||||
|
SecretInput,
|
||||||
|
Select,
|
||||||
|
SelectItem
|
||||||
|
} from "@app/components/v2";
|
||||||
|
import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections";
|
||||||
|
import { TDNSMadeEasyConnection } from "@app/hooks/api/appConnections";
|
||||||
|
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||||
|
|
||||||
|
import { DNSMadeEasyConnectionMethod } from "@app/hooks/api/appConnections/types/dns-made-easy-connection";
|
||||||
|
import {
|
||||||
|
genericAppConnectionFieldsSchema,
|
||||||
|
GenericAppConnectionsFields
|
||||||
|
} from "./GenericAppConnectionFields";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
appConnection?: TDNSMadeEasyConnection;
|
||||||
|
onSubmit: (formData: FormData) => Promise<void>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const rootSchema = genericAppConnectionFieldsSchema.extend({
|
||||||
|
app: z.literal(AppConnection.DNSMadeEasy)
|
||||||
|
});
|
||||||
|
|
||||||
|
const formSchema = z.discriminatedUnion("method", [
|
||||||
|
rootSchema.extend({
|
||||||
|
method: z.literal(DNSMadeEasyConnectionMethod.APIKeySecret),
|
||||||
|
credentials: z.object({
|
||||||
|
apiKey: z.string().trim().min(1, "API Key required"),
|
||||||
|
secretKey: z.string().trim().min(1, "Secret Key required")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
|
type FormData = z.infer<typeof formSchema>;
|
||||||
|
|
||||||
|
export const DNSMadeEasyConnectionForm = ({ appConnection, onSubmit }: Props) => {
|
||||||
|
const isUpdate = Boolean(appConnection);
|
||||||
|
|
||||||
|
const form = useForm<FormData>({
|
||||||
|
resolver: zodResolver(formSchema),
|
||||||
|
defaultValues: appConnection ?? {
|
||||||
|
app: AppConnection.DNSMadeEasy,
|
||||||
|
method: DNSMadeEasyConnectionMethod.APIKeySecret,
|
||||||
|
credentials: {
|
||||||
|
apiKey: "",
|
||||||
|
secretKey: ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
|
handleSubmit,
|
||||||
|
control,
|
||||||
|
formState: { isSubmitting, isDirty }
|
||||||
|
} = form;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FormProvider {...form}>
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
{!isUpdate && <GenericAppConnectionsFields />}
|
||||||
|
<Controller
|
||||||
|
name="method"
|
||||||
|
control={control}
|
||||||
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
tooltipText={`The method you would like to use to connect with ${
|
||||||
|
APP_CONNECTION_MAP[AppConnection.DNSMadeEasy].name
|
||||||
|
}. This field cannot be changed after creation.`}
|
||||||
|
errorText={error?.message}
|
||||||
|
isError={Boolean(error?.message)}
|
||||||
|
label="Method"
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
isDisabled={isUpdate}
|
||||||
|
value={value}
|
||||||
|
onValueChange={(val) => onChange(val)}
|
||||||
|
className="w-full border border-mineshaft-500"
|
||||||
|
position="popper"
|
||||||
|
dropdownContainerClassName="max-w-none"
|
||||||
|
>
|
||||||
|
{Object.values(DNSMadeEasyConnectionMethod).map((method) => {
|
||||||
|
return (
|
||||||
|
<SelectItem value={method} key={method}>
|
||||||
|
{getAppConnectionMethodDetails(method).name}{" "}
|
||||||
|
</SelectItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Controller
|
||||||
|
name="credentials.apiKey"
|
||||||
|
control={control}
|
||||||
|
shouldUnregister
|
||||||
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
errorText={error?.message}
|
||||||
|
isError={Boolean(error?.message)}
|
||||||
|
label="API Key"
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => onChange(e.target.value)}
|
||||||
|
placeholder="af1b628f-3272-46aa-9cde-837d0c59155d"
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Controller
|
||||||
|
name="credentials.secretKey"
|
||||||
|
control={control}
|
||||||
|
shouldUnregister
|
||||||
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
errorText={error?.message}
|
||||||
|
isError={Boolean(error?.message)}
|
||||||
|
label="Secret Key"
|
||||||
|
>
|
||||||
|
<SecretInput
|
||||||
|
containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => onChange(e.target.value)}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<div className="mt-8 flex items-center">
|
||||||
|
<Button
|
||||||
|
className="mr-4"
|
||||||
|
size="sm"
|
||||||
|
type="submit"
|
||||||
|
colorSchema="secondary"
|
||||||
|
isLoading={isSubmitting}
|
||||||
|
isDisabled={isSubmitting || !isDirty}
|
||||||
|
>
|
||||||
|
{isUpdate ? "Update Credentials" : "Connect to DNS Made Easy"}
|
||||||
|
</Button>
|
||||||
|
<ModalClose asChild>
|
||||||
|
<Button colorSchema="secondary" variant="plain">
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</ModalClose>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</FormProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user