-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(dns): PowerDNS Integration #5912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JustinBack
wants to merge
29
commits into
Infisical:main
Choose a base branch
from
JustinBack:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
92bd782
Add PowerDNS Connection Service
fa3018b
Implement Connection Router
f6a6710
Implement PowerDNS API Calls
796bb7f
Add PowerDNS integration image
3e068ff
Add IP address validation to PowerDNS connection credentials
3dddfe0
Add IP address validation to PowerDNS record operations
b1a56f6
Remove unused parameter 'value' from PowerDNS TXT record deletion fun…
38ac731
Add validation for PowerDNS app connection in AcmeCertificateAuthorit…
cbf8679
Add PowerDNS integration documentation and connection setup instructions
68c03a7
Remove unused 'value' parameter from PowerDNS TXT record deletion log…
4c69d91
Increase DNS propagation maximum retries from 5 to 30
74850e4
Add error handling for DNS propagation failure in waitForDnsPropagati…
0a1490f
Update backend/src/services/certificate-authority/acme/acme-certifica…
JustinBack a81d241
Remove duplicate delay call in waitForDnsPropagation function
d36e0c1
Merge branch 'main' into main
JustinBack c01d4dc
Merge branch 'main' into main
JustinBack 73be340
Fix syntax error in app connection routers
JustinBack f3173c6
Update app-connection-enums.ts
JustinBack bf8937b
Update app-connection-fns.ts
JustinBack 86b34a0
Fix formatting of PowerDNS in app connection options
JustinBack 63f57b9
Fix formatting for PowerDNS and NetScaler entries
JustinBack f097d8e
Update app-connection-service.ts
JustinBack adfa4ef
Update appConnections.ts
JustinBack c6f7331
Fix formatting of TPowerDNSConnection type
JustinBack f00b472
Update enums.ts
JustinBack af523d4
Update app-connection-router.ts
JustinBack d53f81a
Fix formatting in app-connection-routers index
JustinBack b8c6939
Merge branch 'Infisical:main' into main
JustinBack e534326
Merge branch 'Infisical:main' into main
JustinBack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
backend/src/server/routes/v1/app-connection-routers/powerdns-connection-router.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { AppConnection } from "@app/services/app-connection/app-connection-enums"; | ||
| import { | ||
| CreatePowerDNSConnectionSchema, | ||
| SanitizedPowerDNSConnectionSchema, | ||
| UpdatePowerDNSConnectionSchema | ||
| } from "@app/services/app-connection/powerdns/powerdns-connection-schema"; | ||
|
|
||
| import { registerAppConnectionEndpoints } from "./app-connection-endpoints"; | ||
|
|
||
| export const registerPowerDNSConnectionRouter = async (server: FastifyZodProvider) => { | ||
| registerAppConnectionEndpoints({ | ||
| app: AppConnection.PowerDNS, | ||
| server, | ||
| sanitizedResponseSchema: SanitizedPowerDNSConnectionSchema, | ||
| createSchema: CreatePowerDNSConnectionSchema, | ||
| updateSchema: UpdatePowerDNSConnectionSchema | ||
| }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
backend/src/services/app-connection/powerdns/powerdns-connection-enum.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export enum PowerDNSConnectionMethod { | ||
| APIKey = "api-key" | ||
| } |
65 changes: 65 additions & 0 deletions
65
backend/src/services/app-connection/powerdns/powerdns-connection-fns.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { AxiosError } from "axios"; | ||
|
|
||
| import { request } from "@app/lib/config/request"; | ||
| import { BadRequestError } from "@app/lib/errors"; | ||
| import { logger } from "@app/lib/logger"; | ||
| import { AppConnection } from "@app/services/app-connection/app-connection-enums"; | ||
| import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator"; | ||
|
|
||
|
|
||
| import { PowerDNSConnectionMethod } from "./powerdns-connection-enum"; | ||
| import { TPowerDNSConnectionConfig } from "./powerdns-connection-types"; | ||
|
|
||
| export const getPowerDNSConnectionListItem = () => { | ||
| return { | ||
| name: "PowerDNS" as const, | ||
| app: AppConnection.PowerDNS as const, | ||
| methods: Object.values(PowerDNSConnectionMethod) as [PowerDNSConnectionMethod.APIKey] | ||
| }; | ||
| }; | ||
|
|
||
| export const validatePowerDNSConnectionCredentials = async (config: TPowerDNSConnectionConfig) => { | ||
| if (config.method !== PowerDNSConnectionMethod.APIKey) { | ||
| throw new BadRequestError({ message: "Unsupported PowerDNS connection method" }); | ||
| } | ||
|
|
||
| const { apiKey, baseUrl } = config.credentials; | ||
|
|
||
| try { | ||
|
|
||
| await blockLocalAndPrivateIpAddresses(baseUrl); | ||
|
|
||
|
|
||
| // Use /servers/localhost/zones as the validation endpoint — it is supported by both | ||
| // direct PowerDNS Server and PowerDNS-Admin proxy configurations. | ||
| const resp = await request.get(`${baseUrl}/servers/localhost/zones`, { | ||
| headers: { | ||
| "x-api-key": apiKey, | ||
| Accept: "application/json" | ||
| } | ||
| }); | ||
|
|
||
| if (resp.status !== 200) { | ||
| throw new BadRequestError({ | ||
| message: "Unable to validate connection: Invalid API credentials provided." | ||
| }); | ||
| } | ||
| } catch (error: unknown) { | ||
| if (error instanceof BadRequestError) { | ||
| throw error; | ||
| } | ||
| if (error instanceof AxiosError) { | ||
| throw new BadRequestError({ | ||
| message: `Failed to validate credentials: ${ | ||
| (error.response?.data as { error?: string })?.error || error.message || "Unknown error" | ||
| }` | ||
| }); | ||
| } | ||
| logger.error(error, "Error validating PowerDNS connection credentials"); | ||
| throw new BadRequestError({ | ||
| message: "Unable to validate connection: verify credentials and base URL" | ||
| }); | ||
| } | ||
|
|
||
| return config.credentials; | ||
| }; | ||
69 changes: 69 additions & 0 deletions
69
backend/src/services/app-connection/powerdns/powerdns-connection-schema.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import z from "zod"; | ||
|
|
||
| import { AppConnections } from "@app/lib/api-docs"; | ||
| import { AppConnection } from "@app/services/app-connection/app-connection-enums"; | ||
| import { | ||
| BaseAppConnectionSchema, | ||
| GenericCreateAppConnectionFieldsSchema, | ||
| GenericUpdateAppConnectionFieldsSchema | ||
| } from "@app/services/app-connection/app-connection-schemas"; | ||
|
|
||
| import { APP_CONNECTION_NAME_MAP } from "../app-connection-maps"; | ||
| import { PowerDNSConnectionMethod } from "./powerdns-connection-enum"; | ||
|
|
||
| export const PowerDNSConnectionApiKeyCredentialsSchema = z.object({ | ||
| apiKey: z.string().trim().min(1, "API key required").max(256, "API key cannot exceed 256 characters"), | ||
| baseUrl: z | ||
| .string() | ||
| .trim() | ||
| .url("Base URL must be a valid URL") | ||
| .min(1, "Base URL required") | ||
| .max(1024, "Base URL cannot exceed 1024 characters") | ||
| }); | ||
|
|
||
| const BasePowerDNSConnectionSchema = BaseAppConnectionSchema.extend({ | ||
| app: z.literal(AppConnection.PowerDNS) | ||
| }); | ||
|
|
||
| export const PowerDNSConnectionSchema = BasePowerDNSConnectionSchema.extend({ | ||
| method: z.literal(PowerDNSConnectionMethod.APIKey), | ||
| credentials: PowerDNSConnectionApiKeyCredentialsSchema | ||
| }); | ||
|
|
||
| export const SanitizedPowerDNSConnectionSchema = z.discriminatedUnion("method", [ | ||
| BasePowerDNSConnectionSchema.extend({ | ||
| method: z.literal(PowerDNSConnectionMethod.APIKey), | ||
| credentials: PowerDNSConnectionApiKeyCredentialsSchema.pick({ baseUrl: true }) | ||
| }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.PowerDNS]} (API Key)` })) | ||
| ]); | ||
|
|
||
| export const ValidatePowerDNSConnectionCredentialsSchema = z.discriminatedUnion("method", [ | ||
| z.object({ | ||
| method: z | ||
| .literal(PowerDNSConnectionMethod.APIKey) | ||
| .describe(AppConnections.CREATE(AppConnection.PowerDNS).method), | ||
| credentials: PowerDNSConnectionApiKeyCredentialsSchema.describe( | ||
| AppConnections.CREATE(AppConnection.PowerDNS).credentials | ||
| ) | ||
| }) | ||
| ]); | ||
|
|
||
| export const CreatePowerDNSConnectionSchema = ValidatePowerDNSConnectionCredentialsSchema.and( | ||
| GenericCreateAppConnectionFieldsSchema(AppConnection.PowerDNS) | ||
| ); | ||
|
|
||
| export const UpdatePowerDNSConnectionSchema = z | ||
| .object({ | ||
| credentials: PowerDNSConnectionApiKeyCredentialsSchema.optional().describe( | ||
| AppConnections.UPDATE(AppConnection.PowerDNS).credentials | ||
| ) | ||
| }) | ||
| .and(GenericUpdateAppConnectionFieldsSchema(AppConnection.PowerDNS)); | ||
|
|
||
| export const PowerDNSConnectionListItemSchema = z | ||
| .object({ | ||
| name: z.literal("PowerDNS"), | ||
| app: z.literal(AppConnection.PowerDNS), | ||
| methods: z.nativeEnum(PowerDNSConnectionMethod).array() | ||
| }) | ||
| .describe(JSON.stringify({ title: APP_CONNECTION_NAME_MAP[AppConnection.PowerDNS] })); |
3 changes: 3 additions & 0 deletions
3
backend/src/services/app-connection/powerdns/powerdns-connection-service.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export const powerDnsConnectionService = () => { | ||
| return {}; | ||
| }; |
25 changes: 25 additions & 0 deletions
25
backend/src/services/app-connection/powerdns/powerdns-connection-types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import z from "zod"; | ||
|
|
||
| import { DiscriminativePick } from "@app/lib/types"; | ||
|
|
||
| import { AppConnection } from "../app-connection-enums"; | ||
| import { | ||
| CreatePowerDNSConnectionSchema, | ||
| PowerDNSConnectionSchema, | ||
| ValidatePowerDNSConnectionCredentialsSchema | ||
| } from "./powerdns-connection-schema"; | ||
|
|
||
| export type TPowerDNSConnection = z.infer<typeof PowerDNSConnectionSchema>; | ||
|
|
||
| export type TPowerDNSConnectionInput = z.infer<typeof CreatePowerDNSConnectionSchema> & { | ||
| app: AppConnection.PowerDNS; | ||
| }; | ||
|
|
||
| export type TValidatePowerDNSConnectionCredentialsSchema = typeof ValidatePowerDNSConnectionCredentialsSchema; | ||
|
|
||
| export type TPowerDNSConnectionConfig = DiscriminativePick< | ||
| TPowerDNSConnectionInput, | ||
| "method" | "app" | "credentials" | ||
| > & { | ||
| orgId: string; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.