Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
move list services to app connection
adilson03e1b11dfc9e
diff --git a/backend/src/ee/services/secret-rotation-v2/datadog-application-key-secret/datadog-application-key-secret-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/datadog-application-key-secret/datadog-application-key-secret-rotation-fns.tsindex a0e2161807..40a0400c0f 100644--- a/backend/src/ee/services/secret-rotation-v2/datadog-application-key-secret/datadog-application-key-secret-rotation-fns.ts+++ b/backend/src/ee/services/secret-rotation-v2/datadog-application-key-secret/datadog-application-key-secret-rotation-fns.ts@@ -10,36 +10,13 @@ import {import { request } from "@app/lib/config/request";import { BadRequestError } from "@app/lib/errors";import { logger } from "@app/lib/logger";-import {- getDatadogAuthHeaders,- getDatadogBaseUrl,- getDatadogErrorMessage,- TDatadogConnection-} from "@app/services/app-connection/datadog";+import { getDatadogAuthHeaders, getDatadogBaseUrl, getDatadogErrorMessage } from "@app/services/app-connection/datadog";import {TDatadogApplicationKeySecretRotationGeneratedCredentials,TDatadogApplicationKeySecretRotationWithConnection} from "./datadog-application-key-secret-rotation-types";-export type TDatadogServiceAccount = {- id: string;- name: string;-};--type TDatadogServiceAccountResponse = {- data: Array<{- id: string;- type: string;- attributes?: {- name?: string | null;- email?: string | null;- handle?: string | null;- disabled?: boolean;- };- }>;-};-type TDatadogCreateApplicationKeyResponse = {data: {id: string;@@ -53,31 +30,6 @@ type TDatadogCreateApplicationKeyResponse = {};};-export const listDatadogServiceAccounts = async (connection: TDatadogConnection): Promise<TDatadogServiceAccount[]> => {- const baseUrl = await getDatadogBaseUrl(connection);-- try {- const { data } = await request.get<TDatadogServiceAccountResponse>(`${baseUrl}/api/v2/users`, {- params: {- "filter[service_account]": "true",- "page[size]": 100- },- headers: getDatadogAuthHeaders(connection.credentials)- });-- return (data.data ?? [])- .filter((entry) => !entry.attributes?.disabled)- .map((entry) => ({- id: entry.id,- name: entry.attributes?.name || entry.attributes?.email || entry.attributes?.handle || entry.id- }));- } catch (error: unknown) {- throw new BadRequestError({- message: `Failed to list Datadog service accounts: ${getDatadogErrorMessage(error)}`- });- }-};-export const datadogApplicationKeySecretRotationFactory: TRotationFactory<TDatadogApplicationKeySecretRotationWithConnection,TDatadogApplicationKeySecretRotationGeneratedCredentialsdiff --git a/backend/src/services/app-connection/datadog/datadog-connection-fns.ts b/backend/src/services/app-connection/datadog/datadog-connection-fns.tsindex 361b718028..244b585cde 100644--- a/backend/src/services/app-connection/datadog/datadog-connection-fns.ts+++ b/backend/src/services/app-connection/datadog/datadog-connection-fns.ts@@ -7,7 +7,7 @@ import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";import { AppConnection } from "../app-connection-enums";import { DatadogConnectionMethod } from "./datadog-connection-enums";-import { TDatadogConnectionConfig } from "./datadog-connection-types";+import { TDatadogConnection, TDatadogConnectionConfig, TDatadogServiceAccount } from "./datadog-connection-types";const DATADOG_ALLOWED_DOMAINS = ["datadoghq", "ddog-gov"];@@ -77,3 +77,41 @@ export const validateDatadogConnectionCredentials = async (config: TDatadogConnereturn config.credentials;};++type TDatadogServiceAccountResponse = {+ data: Array<{+ id: string;+ type: string;+ attributes?: {+ name?: string | null;+ email?: string | null;+ handle?: string | null;+ disabled?: boolean;+ };+ }>;+};++export const listDatadogServiceAccounts = async (connection: TDatadogConnection): Promise<TDatadogServiceAccount[]> => {+ const baseUrl = await getDatadogBaseUrl(connection);++ try {+ const { data } = await request.get<TDatadogServiceAccountResponse>(`${baseUrl}/api/v2/users`, {+ params: {+ "filter[service_account]": "true",+ "page[size]": 100+ },+ headers: getDatadogAuthHeaders(connection.credentials)+ });++ return (data.data ?? [])+ .filter((entry) => !entry.attributes?.disabled)+ .map((entry) => ({+ id: entry.id,+ name: entry.attributes?.name || entry.attributes?.email || entry.attributes?.handle || entry.id+ }));+ } catch (error: unknown) {+ throw new BadRequestError({+ message: `Failed to list Datadog service accounts: ${getDatadogErrorMessage(error)}`+ });+ }+};diff --git a/backend/src/services/app-connection/datadog/datadog-connection-service.ts b/backend/src/services/app-connection/datadog/datadog-connection-service.tsindex ad72d7270a..45c2b78c4c 100644--- a/backend/src/services/app-connection/datadog/datadog-connection-service.ts+++ b/backend/src/services/app-connection/datadog/datadog-connection-service.ts@@ -1,7 +1,7 @@-import { listDatadogServiceAccounts } from "@app/ee/services/secret-rotation-v2/datadog-application-key-secret/datadog-application-key-secret-rotation-fns";import { OrgServiceActor } from "@app/lib/types";import { AppConnection } from "../app-connection-enums";+import { listDatadogServiceAccounts } from "./datadog-connection-fns";import { TDatadogConnection } from "./datadog-connection-types";type TGetAppConnectionFunc = (diff --git a/backend/src/services/app-connection/datadog/datadog-connection-types.ts b/backend/src/services/app-connection/datadog/datadog-connection-types.tsindex 4c6dbad629..9a398e7d9f 100644--- a/backend/src/services/app-connection/datadog/datadog-connection-types.ts+++ b/backend/src/services/app-connection/datadog/datadog-connection-types.ts@@ -18,3 +18,8 @@ export type TDatadogConnectionInput = z.infer<typeof CreateDatadogConnectionScheexport type TValidateDatadogConnectionCredentialsSchema = typeof ValidateDatadogConnectionCredentialsSchema;export type TDatadogConnectionConfig = DiscriminativePick<TDatadogConnectionInput, "method" | "app" | "credentials">;++export type TDatadogServiceAccount = {+ id: string;+ name: string;+};