Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: dbt service token rotation

Daniel Hougaard773db6932285
diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/dbt-service-token-rotation-router.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/dbt-service-token-rotation-router.ts
new file mode 100644
index 0000000000..943b8d8d78
--- /dev/null
+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/dbt-service-token-rotation-router.ts
@@ -0,0 +1,19 @@
+import {
+ CreateDbtServiceTokenRotationSchema,
+ DbtServiceTokenRotationGeneratedCredentialsSchema,
+ DbtServiceTokenRotationSchema,
+ UpdateDbtServiceTokenRotationSchema
+} from "@app/ee/services/secret-rotation-v2/dbt-service-token";
+import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";
+
+import { registerSecretRotationEndpoints } from "./secret-rotation-v2-endpoints";
+
+export const registerDbtServiceTokenRotationRouter = async (server: FastifyZodProvider) =>
+ registerSecretRotationEndpoints({
+ type: SecretRotation.DbtServiceToken,
+ server,
+ responseSchema: DbtServiceTokenRotationSchema,
+ createSchema: CreateDbtServiceTokenRotationSchema,
+ updateSchema: UpdateDbtServiceTokenRotationSchema,
+ generatedCredentialsSchema: DbtServiceTokenRotationGeneratedCredentialsSchema
+ });
diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts
index f32a3d4b4c..e49d4f2744 100644
--- a/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts
+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts
@@ -4,6 +4,7 @@ import { registerAuth0ClientSecretRotationRouter } from "./auth0-client-secret-r
import { registerAwsIamUserSecretRotationRouter } from "./aws-iam-user-secret-rotation-router";
import { registerAzureClientSecretRotationRouter } from "./azure-client-secret-rotation-router";
import { registerDatabricksServicePrincipalSecretRotationRouter } from "./databricks-service-principal-secret-rotation-router";
+import { registerDbtServiceTokenRotationRouter } from "./dbt-service-token-rotation-router";
import { registerLdapPasswordRotationRouter } from "./ldap-password-rotation-router";
import { registerMongoDBCredentialsRotationRouter } from "./mongodb-credentials-rotation-router";
import { registerMsSqlCredentialsRotationRouter } from "./mssql-credentials-rotation-router";
@@ -32,5 +33,6 @@ export const SECRET_ROTATION_REGISTER_ROUTER_MAP: Record<
[SecretRotation.RedisCredentials]: registerRedisCredentialsRotationRouter,
[SecretRotation.MongoDBCredentials]: registerMongoDBCredentialsRotationRouter,
[SecretRotation.DatabricksServicePrincipalSecret]: registerDatabricksServicePrincipalSecretRotationRouter,
- [SecretRotation.UnixLinuxLocalAccount]: registerUnixLinuxLocalAccountRotationRouter
+ [SecretRotation.UnixLinuxLocalAccount]: registerUnixLinuxLocalAccountRotationRouter,
+ [SecretRotation.DbtServiceToken]: registerDbtServiceTokenRotationRouter
};
diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts
index 526e8c1451..88b8099d8a 100644
--- a/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts
+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts
@@ -5,6 +5,7 @@ import { Auth0ClientSecretRotationListItemSchema } from "@app/ee/services/secret
import { AwsIamUserSecretRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/aws-iam-user-secret";
import { AzureClientSecretRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/azure-client-secret";
import { DatabricksServicePrincipalSecretRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/databricks-service-principal-secret";
+import { DbtServiceTokenRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/dbt-service-token";
import { LdapPasswordRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/ldap-password";
import { MongoDBCredentialsRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/mongodb-credentials";
import { MsSqlCredentialsRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/mssql-credentials";
@@ -33,7 +34,8 @@ const SecretRotationV2OptionsSchema = z.discriminatedUnion("type", [
RedisCredentialsRotationListItemSchema,
MongoDBCredentialsRotationListItemSchema,
DatabricksServicePrincipalSecretRotationListItemSchema,
- UnixLinuxLocalAccountRotationListItemSchema
+ UnixLinuxLocalAccountRotationListItemSchema,
+ DbtServiceTokenRotationListItemSchema
]);
export const registerSecretRotationV2Router = async (server: FastifyZodProvider) => {
diff --git a/backend/src/ee/services/secret-rotation-v2/dbt-service-token/dbt-service-token-rotation-constants.ts b/backend/src/ee/services/secret-rotation-v2/dbt-service-token/dbt-service-token-rotation-constants.ts
new file mode 100644
index 0000000000..50df322b7d
--- /dev/null
+++ b/backend/src/ee/services/secret-rotation-v2/dbt-service-token/dbt-service-token-rotation-constants.ts
@@ -0,0 +1,14 @@
+import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";
+import { TSecretRotationV2ListItem } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-types";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+
+export const DBT_SERVICE_TOKEN_ROTATION_LIST_OPTION: TSecretRotationV2ListItem = {
+ name: "DBT Service Token",
+ type: SecretRotation.DbtServiceToken,
+ connection: AppConnection.Dbt,
+ template: {
+ secretsMapping: {
+ serviceToken: "DBT_SERVICE_TOKEN"
+ }
+ }
+};
diff --git a/backend/src/ee/services/secret-rotation-v2/dbt-service-token/dbt-service-token-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/dbt-service-token/dbt-service-token-rotation-fns.ts
new file mode 100644
index 0000000000..eaad45ca60
--- /dev/null
+++ b/backend/src/ee/services/secret-rotation-v2/dbt-service-token/dbt-service-token-rotation-fns.ts
@@ -0,0 +1,224 @@
+/* eslint-disable no-await-in-loop */
+import { AxiosError } from "axios";
+
+import {
+ TRotationFactory,
+ TRotationFactoryGetSecretsPayload,
+ TRotationFactoryIssueCredentials,
+ TRotationFactoryRevokeCredentials,
+ TRotationFactoryRotateCredentials
+} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-types";
+import { request } from "@app/lib/config/request";
+import { BadRequestError } from "@app/lib/errors";
+import { logger } from "@app/lib/logger";
+import { alphaNumericNanoId } from "@app/lib/nanoid";
+import { getDbtUrl } from "@app/services/app-connection/dbt";
+
+import {
+ TCreateDbtServiceTokenResponse,
+ TDbtErrorResponse,
+ TDbtServiceTokenRotationGeneratedCredentials,
+ TDbtServiceTokenRotationWithConnection,
+ TGetDbtServiceTokenResponse
+} from "./dbt-service-token-rotation-types";
+
+export const dbtServiceTokenRotationFactory: TRotationFactory<
+ TDbtServiceTokenRotationWithConnection,
+ TDbtServiceTokenRotationGeneratedCredentials
+> = (secretRotation) => {
+ const {
+ connection,
+ parameters: { permissionGrants },
+ secretsMapping
+ } = secretRotation;
+
+ /**
+ * Creates a new service token for the DBT account.
+ */
+ const $rotateServiceToken = async () => {
+ const instanceUrl = await getDbtUrl(connection);
+
+ try {
+ const { data } = await request.post<TCreateDbtServiceTokenResponse>(
+ `${instanceUrl}/api/v3/accounts/${connection.credentials.accountId}/service-tokens/`,
+ {
+ name: `infisical-service-token-${alphaNumericNanoId(12)}`,
+ permission_grants: permissionGrants.map((grant) => ({
+ permission_set: grant.permissionSet,
+ project_id: grant.projectId
+ }))
+ },
+ {
+ headers: {
+ Accept: "application/json",
+ Authorization: `Bearer ${connection.credentials.apiToken}`
+ }
+ }
+ );
+
+ if (!data.data.token_string || !data.data.id) {
+ logger.error(data || "Failed to create service token");
+ throw new BadRequestError({
+ message: "Failed to create service token, no token or token ID found"
+ });
+ }
+
+ return {
+ tokenId: data.data.id,
+ tokenName: data.data.name,
+ serviceToken: data.data.token_string
+ };
+ } catch (error: unknown) {
+ if (error instanceof BadRequestError) {
+ throw error;
+ }
+
+ logger.error(error, "Failed to create service token");
+ if (error instanceof AxiosError) {
+ const dbtErrorMessage = createDbtError(error);
+
+ if (dbtErrorMessage) {
+ throw new BadRequestError({
+ message: `Failed to create service token: ${dbtErrorMessage}`
+ });
+ }
+
+ throw new BadRequestError({
+ message: `Failed to create service token: ${error.message || "Unknown error"}`
+ });
+ }
+
+ throw new BadRequestError({
+ message: "Failed to create service token"
+ });
+ }
+ };
+
+ /**
+ * Checks if a credential with the given secretId exists.
+ */
+ const tokenExists = async (tokenId: number): Promise<boolean> => {
+ const instanceUrl = await getDbtUrl(connection);
+
+ try {
+ const { data } = await request.get<TGetDbtServiceTokenResponse>(
+ `${instanceUrl}/api/v3/accounts/${connection.credentials.accountId}/service-tokens/${tokenId}`,
+ {
+ headers: {
+ Accept: "application/json",
+ Authorization: `Bearer ${connection.credentials.apiToken}`
+ }
+ }
+ );
+
+ if (!data.status.is_success) {
+ throw new Error();
+ }
+
+ return data.data.id === tokenId;
+ } catch (_) {
+ return false;
+ }
+ };
+
+ /**
+ * Revokes a client secret from the Okta app using its secretId.
+ * First checks if the credential exists before attempting revocation.
+ */
+ const revokeCredential = async (tokenId: number) => {
+ // Check if credential exists before attempting revocation
+ const exists = await tokenExists(tokenId);
+ if (!exists) {
+ return; // Credential doesn't exist, nothing to revoke
+ }
+
+ const instanceUrl = await getDbtUrl(connection);
+
+ try {
+ await request.delete(
+ `${instanceUrl}/api/v3/accounts/${connection.credentials.accountId}/service-tokens/${tokenId}`,
+ {
+ headers: {
+ Authorization: `Bearer ${connection.credentials.apiToken}`
+ }
+ }
+ );
+ } catch (error: unknown) {
+ logger.error(
+ { error, responseData: (error as AxiosError)?.response?.data },
+ `Failed to remove service token with tokenId ${tokenId}`
+ );
+ if (error instanceof AxiosError) {
+ const dbtErrorMessage = createDbtError(error);
+
+ if (dbtErrorMessage) {
+ throw new BadRequestError({
+ message: `Failed to remove service token with tokenId ${tokenId}: ${dbtErrorMessage}`
+ });
+ }
+
+ throw new BadRequestError({
+ message: `Failed to remove service token with tokenId ${tokenId}: ${error.message || "Unknown error"}`
+ });
+ }
+
+ throw new BadRequestError({
+ message: `Failed to remove service token with tokenId ${tokenId}: Unknown error`
+ });
+ }
+ };
+
+ /**
+ * Issues a new set of credentials.
+ */
+ const issueCredentials: TRotationFactoryIssueCredentials<TDbtServiceTokenRotationGeneratedCredentials> = async (
+ callback
+ ) => {
+ const credentials = await $rotateServiceToken();
+ return callback(credentials);
+ };
+
+ /**
+ * Revokes a list of credentials.
+ */
+ const revokeCredentials: TRotationFactoryRevokeCredentials<TDbtServiceTokenRotationGeneratedCredentials> = async (
+ credentials,
+ callback
+ ) => {
+ if (!credentials?.length) return callback();
+
+ for (const { tokenId } of credentials) {
+ await revokeCredential(tokenId);
+ }
+ return callback();
+ };
+
+ /**
+ * Rotates credentials by issuing new ones and revoking the old.
+ */
+ const rotateCredentials: TRotationFactoryRotateCredentials<TDbtServiceTokenRotationGeneratedCredentials> = async (
+ oldCredentials,
+ callback
+ ) => {
+ if (oldCredentials?.tokenId) {
+ await revokeCredential(oldCredentials.tokenId);
+ }
+
+ const newCredentials = await $rotateServiceToken();
+ return callback(newCredentials);
+ };
+
+ /**
+ * Maps the generated credentials into the secret payload format.
+ */
+ const getSecretsPayload: TRotationFactoryGetSecretsPayload<TDbtServiceTokenRotationGeneratedCredentials> = ({
+ serviceToken
+ }) => [{ key: secretsMapping.serviceToken, value: serviceToken }];
+
+ return {
+ issueCredentials,
+ revokeCredentials,
+ rotateCredentials,
+ getSecretsPayload
+ };
+};
diff --git a/backend/src/ee/services/secret-rotation-v2/dbt-service-token/dbt-service-token-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/dbt-service-token/dbt-service-token-rotation-schemas.ts
new file mode 100644
index 0000000000..0ca3907e6c
--- /dev/null
+++ b/backend/src/ee/services/secret-rotation-v2/dbt-service-token/dbt-service-token-rotation-schemas.ts
@@ -0,0 +1,100 @@
+import { z } from "zod";
+
+import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";
+import {
+ BaseCreateSecretRotationSchema,
+ BaseSecretRotationSchema,
+ BaseUpdateSecretRotationSchema
+} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-schemas";
+import { SecretRotations } from "@app/lib/api-docs";
+import { SecretNameSchema } from "@app/server/lib/schemas";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+
+enum DbtPermissionsSet {
+ AccountAdmin = "account_admin",
+ AccountViewer = "account_viewer",
+ Admin = "admin",
+ Analyst = "analyst",
+ BillingAdmin = "billing_admin",
+ CostInsightsAdmin = "cost_insights_admin",
+ ConstInsightViewer = "cost_insights_viewer",
+ CostManagementAdmin = "cost_management_admin",
+ CostManagementViewer = "cost_management_viewer",
+ DatabaseAdmin = "database_admin",
+ Developer = "developer",
+ FusionAdmin = "fusion_admin",
+ GitAdmin = "git_admin",
+ JobAdmin = "job_admin",
+ JobRunner = "job_runner",
+ JobViewer = "job_viewer",
+ ManageMarketplaceApps = "manage_marketplace_apps",
+ Member = "member",
+ MetadataOnly = "metadata_only",
+ Owner = "owner",
+ ProjectCreator = "project_creator",
+ Readonly = "readonly",
+ ScimOnly = "scim_only",
+ SecurityAdmin = "security_admin",
+ SemanticLayerOnly = "semantic_layer_only",
+ Stakeholder = "stakeholder",
+ TeamAdmin = "team_admin",
+ WebhooksOnly = "webhooks_only"
+}
+
+export const DbtTokenPermissionsSchema = z.object({
+ permissionSet: z.nativeEnum(DbtPermissionsSet),
+ projectId: z.number().optional()
+});
+
+export const DbtServiceTokenRotationGeneratedCredentialsSchema = z
+ .object({
+ serviceToken: z.string(),
+ tokenId: z.number(),
+ tokenName: z.string()
+ })
+ .array()
+ .min(1)
+ .max(2);
+
+const DbtServiceTokenRotationParametersSchema = z.object({
+ permissionGrants: DbtTokenPermissionsSchema.array()
+ .min(1)
+ .describe(SecretRotations.PARAMETERS.DBT_SERVICE_TOKEN.permissionGrants)
+});
+
+const DbtServiceTokenRotationSecretsMappingSchema = z.object({
+ serviceToken: SecretNameSchema.describe(SecretRotations.SECRETS_MAPPING.DBT_SERVICE_TOKEN.serviceToken)
+});
+
+export const DbtServiceTokenRotationTemplateSchema = z.object({
+ secretsMapping: z.object({
+ serviceToken: z.string()
+ })
+});
+
+export const DbtServiceTokenRotationSchema = BaseSecretRotationSchema(SecretRotation.DbtServiceToken).extend({
+ type: z.literal(SecretRotation.DbtServiceToken),
+ parameters: DbtServiceTokenRotationParametersSchema,
+ secretsMapping: DbtServiceTokenRotationSecretsMappingSchema
+});
+
+export const CreateDbtServiceTokenRotationSchema = BaseCreateSecretRotationSchema(
+ SecretRotation.DbtServiceToken
+).extend({
+ parameters: DbtServiceTokenRotationParametersSchema,
+ secretsMapping: DbtServiceTokenRotationSecretsMappingSchema
+});
+
+export const UpdateDbtServiceTokenRotationSchema = BaseUpdateSecretRotationSchema(
+ SecretRotation.DbtServiceToken
+).extend({
+ parameters: DbtServiceTokenRotationParametersSchema.optional(),
+ secretsMapping: DbtServiceTokenRotationSecretsMappingSchema.optional()
+});
+
+export const DbtServiceTokenRotationListItemSchema = z.object({
+ name: z.literal("DBT Service Token"),
+ connection: z.literal(AppConnection.Dbt),
+ type: z.literal(SecretRotation.DbtServiceToken),
+ template: DbtServiceTokenRotationTemplateSchema
+});
diff --git a/backend/src/ee/services/secret-rotation-v2/dbt-service-token/dbt-service-token-rotation-types.ts b/backend/src/ee/services/secret-rotation-v2/dbt-service-token/dbt-service-token-rotation-types.ts
new file mode 100644
index 0000000000..bf5666ebbc
--- /dev/null
+++ b/backend/src/ee/services/secret-rotation-v2/dbt-service-token/dbt-service-token-rotation-types.ts
@@ -0,0 +1,49 @@
+import { z } from "zod";
+
+import { TDbtConnection, TDbtStatusResponse } from "@app/services/app-connection/dbt";
+
+import {
+ CreateDbtServiceTokenRotationSchema,
+ DbtServiceTokenRotationGeneratedCredentialsSchema,
+ DbtServiceTokenRotationListItemSchema,
+ DbtServiceTokenRotationSchema,
+ DbtTokenPermissionsSchema
+} from "./dbt-service-token-rotation-schemas";
+
+type DbtTokenPermissions = z.infer<typeof DbtTokenPermissionsSchema>;
+
+export type TDbtServiceTokenRotation = z.infer<typeof DbtServiceTokenRotationSchema>;
+
+export type TDbtServiceTokenRotationInput = z.infer<typeof CreateDbtServiceTokenRotationSchema>;
+
+export type TDbtServiceTokenRotationListItem = z.infer<typeof DbtServiceTokenRotationListItemSchema>;
+
+export type TDbtServiceTokenRotationWithConnection = TDbtServiceTokenRotation & {
+ connection: TDbtConnection;
+};
+
+export type TDbtServiceTokenRotationGeneratedCredentials = z.infer<
+ typeof DbtServiceTokenRotationGeneratedCredentialsSchema
+>;
+
+export interface TDbtServiceTokenRotationParameters {
+ permissionGrants: DbtTokenPermissions[];
+}
+
+export interface TDbtServiceTokenRotationSecretsMapping {
+ serviceToken: string;
+}
+
+export interface TCreateDbtServiceTokenResponse extends TDbtStatusResponse {
+ data: {
+ id: number; // token ID
+ token_string: string; // plaintext token
+ name: string; // token name
+ };
+}
+
+export interface TGetDbtServiceTokenResponse extends TDbtStatusResponse {
+ data: {
+ id: number;
+ };
+}
diff --git a/backend/src/ee/services/secret-rotation-v2/dbt-service-token/index.ts b/backend/src/ee/services/secret-rotation-v2/dbt-service-token/index.ts
new file mode 100644
index 0000000000..1067da4e14
--- /dev/null
+++ b/backend/src/ee/services/secret-rotation-v2/dbt-service-token/index.ts
@@ -0,0 +1,3 @@
+export * from "./dbt-service-token-rotation-constants";
+export * from "./dbt-service-token-rotation-schemas";
+export * from "./dbt-service-token-rotation-types";
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts
index f848876cf1..607723c58d 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts
@@ -11,7 +11,8 @@ export enum SecretRotation {
RedisCredentials = "redis-credentials",
MongoDBCredentials = "mongodb-credentials",
DatabricksServicePrincipalSecret = "databricks-service-principal-secret",
- UnixLinuxLocalAccount = "unix-linux-local-account"
+ UnixLinuxLocalAccount = "unix-linux-local-account",
+ DbtServiceToken = "dbt-service-token"
}
export enum SecretRotationStatus {
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts
index 4de49f6afe..7ac305c8ee 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts
@@ -9,6 +9,7 @@ import { AUTH0_CLIENT_SECRET_ROTATION_LIST_OPTION } from "./auth0-client-secret"
import { AWS_IAM_USER_SECRET_ROTATION_LIST_OPTION } from "./aws-iam-user-secret";
import { AZURE_CLIENT_SECRET_ROTATION_LIST_OPTION } from "./azure-client-secret";
import { DATABRICKS_SERVICE_PRINCIPAL_SECRET_ROTATION_LIST_OPTION } from "./databricks-service-principal-secret";
+import { DBT_SERVICE_TOKEN_ROTATION_LIST_OPTION } from "./dbt-service-token";
import { LDAP_PASSWORD_ROTATION_LIST_OPTION, TLdapPasswordRotation } from "./ldap-password";
import { MONGODB_CREDENTIALS_ROTATION_LIST_OPTION } from "./mongodb-credentials";
import { MSSQL_CREDENTIALS_ROTATION_LIST_OPTION } from "./mssql-credentials";
@@ -46,7 +47,8 @@ const SECRET_ROTATION_LIST_OPTIONS: Record<SecretRotation, TSecretRotationV2List
[SecretRotation.RedisCredentials]: REDIS_CREDENTIALS_ROTATION_LIST_OPTION,
[SecretRotation.MongoDBCredentials]: MONGODB_CREDENTIALS_ROTATION_LIST_OPTION,
[SecretRotation.DatabricksServicePrincipalSecret]: DATABRICKS_SERVICE_PRINCIPAL_SECRET_ROTATION_LIST_OPTION,
- [SecretRotation.UnixLinuxLocalAccount]: UNIX_LINUX_LOCAL_ACCOUNT_ROTATION_LIST_OPTION
+ [SecretRotation.UnixLinuxLocalAccount]: UNIX_LINUX_LOCAL_ACCOUNT_ROTATION_LIST_OPTION,
+ [SecretRotation.DbtServiceToken]: DBT_SERVICE_TOKEN_ROTATION_LIST_OPTION
};
export const listSecretRotationOptions = () => {
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts
index bfc39f39ec..112e2c858c 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts
@@ -14,7 +14,8 @@ export const SECRET_ROTATION_NAME_MAP: Record<SecretRotation, string> = {
[SecretRotation.RedisCredentials]: "Redis Credentials",
[SecretRotation.MongoDBCredentials]: "MongoDB Credentials",
[SecretRotation.DatabricksServicePrincipalSecret]: "Databricks Service Principal Secret",
- [SecretRotation.UnixLinuxLocalAccount]: "Unix/Linux Local Account"
+ [SecretRotation.UnixLinuxLocalAccount]: "Unix/Linux Local Account",
+ [SecretRotation.DbtServiceToken]: "DBT Service Token"
};
export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnection> = {
@@ -30,5 +31,6 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio
[SecretRotation.RedisCredentials]: AppConnection.Redis,
[SecretRotation.MongoDBCredentials]: AppConnection.MongoDB,
[SecretRotation.DatabricksServicePrincipalSecret]: AppConnection.Databricks,
- [SecretRotation.UnixLinuxLocalAccount]: AppConnection.SSH
+ [SecretRotation.UnixLinuxLocalAccount]: AppConnection.SSH,
+ [SecretRotation.DbtServiceToken]: AppConnection.Dbt
};
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts
index e99baaf8f6..026a15360d 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts
@@ -85,6 +85,7 @@ import { TSecretVersionV2TagDALFactory } from "@app/services/secret-v2-bridge/se
import { TGatewayV2ServiceFactory } from "../gateway-v2/gateway-v2-service";
import { awsIamUserSecretRotationFactory } from "./aws-iam-user-secret/aws-iam-user-secret-rotation-fns";
+import { dbtServiceTokenRotationFactory } from "./dbt-service-token/dbt-service-token-rotation-fns";
import { mongodbCredentialsRotationFactory } from "./mongodb-credentials/mongodb-credentials-rotation-fns";
import { oktaClientSecretRotationFactory } from "./okta-client-secret/okta-client-secret-rotation-fns";
import { redisCredentialsRotationFactory } from "./redis-credentials/redis-credentials-rotation-fns";
@@ -146,7 +147,8 @@ const SECRET_ROTATION_FACTORY_MAP: Record<SecretRotation, TRotationFactoryImplem
[SecretRotation.MongoDBCredentials]: mongodbCredentialsRotationFactory as TRotationFactoryImplementation,
[SecretRotation.DatabricksServicePrincipalSecret]:
databricksServicePrincipalSecretRotationFactory as TRotationFactoryImplementation,
- [SecretRotation.UnixLinuxLocalAccount]: unixLinuxLocalAccountRotationFactory as TRotationFactoryImplementation
+ [SecretRotation.UnixLinuxLocalAccount]: unixLinuxLocalAccountRotationFactory as TRotationFactoryImplementation,
+ [SecretRotation.DbtServiceToken]: dbtServiceTokenRotationFactory as TRotationFactoryImplementation
};
export const secretRotationV2ServiceFactory = ({
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts
index 9b6c89ad10..384bb06574 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts
@@ -35,6 +35,13 @@ import {
TDatabricksServicePrincipalSecretRotationListItem,
TDatabricksServicePrincipalSecretRotationWithConnection
} from "./databricks-service-principal-secret";
+import {
+ TDbtServiceTokenRotation,
+ TDbtServiceTokenRotationGeneratedCredentials,
+ TDbtServiceTokenRotationInput,
+ TDbtServiceTokenRotationListItem,
+ TDbtServiceTokenRotationWithConnection
+} from "./dbt-service-token/dbt-service-token-rotation-types";
import {
TLdapPasswordRotation,
TLdapPasswordRotationGeneratedCredentials,
@@ -109,7 +116,8 @@ export type TSecretRotationV2 =
| TRedisCredentialsRotation
| TMongoDBCredentialsRotation
| TDatabricksServicePrincipalSecretRotation
- | TUnixLinuxLocalAccountRotation;
+ | TUnixLinuxLocalAccountRotation
+ | TDbtServiceTokenRotation;
export type TSecretRotationV2WithConnection =
| TPostgresCredentialsRotationWithConnection
@@ -124,7 +132,8 @@ export type TSecretRotationV2WithConnection =
| TRedisCredentialsRotationWithConnection
| TMongoDBCredentialsRotationWithConnection
| TDatabricksServicePrincipalSecretRotationWithConnection
- | TUnixLinuxLocalAccountRotationWithConnection;
+ | TUnixLinuxLocalAccountRotationWithConnection
+ | TDbtServiceTokenRotationWithConnection;
export type TSecretRotationV2GeneratedCredentials =
| TSqlCredentialsRotationGeneratedCredentials
@@ -135,7 +144,8 @@ export type TSecretRotationV2GeneratedCredentials =
| TOktaClientSecretRotationGeneratedCredentials
| TRedisCredentialsRotationGeneratedCredentials
| TDatabricksServicePrincipalSecretRotationGeneratedCredentials
- | TUnixLinuxLocalAccountRotationGeneratedCredentials;
+ | TUnixLinuxLocalAccountRotationGeneratedCredentials
+ | TDbtServiceTokenRotationGeneratedCredentials;
export type TSecretRotationV2Input =
| TPostgresCredentialsRotationInput
@@ -150,7 +160,8 @@ export type TSecretRotationV2Input =
| TRedisCredentialsRotationInput
| TMongoDBCredentialsRotationInput
| TDatabricksServicePrincipalSecretRotationInput
- | TUnixLinuxLocalAccountRotationInput;
+ | TUnixLinuxLocalAccountRotationInput
+ | TDbtServiceTokenRotationInput;
export type TSecretRotationV2ListItem =
| TPostgresCredentialsRotationListItem
@@ -165,7 +176,8 @@ export type TSecretRotationV2ListItem =
| TRedisCredentialsRotationListItem
| TMongoDBCredentialsRotationListItem
| TDatabricksServicePrincipalSecretRotationListItem
- | TUnixLinuxLocalAccountRotationListItem;
+ | TUnixLinuxLocalAccountRotationListItem
+ | TDbtServiceTokenRotationListItem;
export type TSecretRotationV2TemporaryParameters =
| TLdapPasswordRotationInput["temporaryParameters"]
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts
index ef30328102..238466674e 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts
@@ -14,6 +14,8 @@ import { PostgresCredentialsRotationSchema } from "@app/ee/services/secret-rotat
import { RedisCredentialsRotationSchema } from "@app/ee/services/secret-rotation-v2/redis-credentials";
import { UnixLinuxLocalAccountRotationSchema } from "@app/ee/services/secret-rotation-v2/unix-linux-local-account-rotation";
+import { DbtServiceTokenRotationSchema } from "./dbt-service-token";
+
export const SecretRotationV2Schema = z.discriminatedUnion("type", [
PostgresCredentialsRotationSchema,
MsSqlCredentialsRotationSchema,
@@ -27,5 +29,6 @@ export const SecretRotationV2Schema = z.discriminatedUnion("type", [
RedisCredentialsRotationSchema,
MongoDBCredentialsRotationSchema,
DatabricksServicePrincipalSecretRotationSchema,
- UnixLinuxLocalAccountRotationSchema
+ UnixLinuxLocalAccountRotationSchema,
+ DbtServiceTokenRotationSchema
]);
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 8b38eda17c..ade1bc57c8 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -2625,6 +2625,11 @@ export const AppConnections = {
password: "The password for SSH authentication (required when authMethod is 'password').",
privateKey: "The private key in PEM format for SSH authentication (required when authMethod is 'ssh-key').",
passphrase: "The passphrase for the private key, if encrypted (optional, only for 'ssh-key' authMethod)."
+ },
+ DBT: {
+ apiToken: "The API token used to authenticate with DBT.",
+ accountId: "The account ID of your DBT account.",
+ instanceUrl: "The base URL of your DBT instance."
}
}
};
@@ -3011,6 +3016,9 @@ export const SecretRotations = {
servicePrincipalId: "The ID of the Databricks Service Principal to rotate the OAuth secret for.",
servicePrincipalName: "The name of the Databricks Service Principal to rotate the OAuth secret for.",
clientId: "The client ID of the Databricks Service Principal to rotate the OAuth secret for."
+ },
+ DBT_SERVICE_TOKEN: {
+ permissionGrants: "The permission grants to apply to the service token."
}
},
SECRETS_MAPPING: {
@@ -3057,6 +3065,9 @@ export const SecretRotations = {
DATABRICKS_SERVICE_ACCOUNT_SECRET: {
clientId: "The name of the secret that the client ID will be mapped to.",
clientSecret: "The name of the secret that the rotated OAuth client secret will be mapped to."
+ },
+ DBT_SERVICE_TOKEN: {
+ serviceToken: "The name of the secret that the service token will be mapped to."
}
}
};
diff --git a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
index e65dc88946..c503adcff9 100644
--- a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
@@ -57,6 +57,7 @@ import {
DatabricksConnectionListItemSchema,
SanitizedDatabricksConnectionSchema
} from "@app/services/app-connection/databricks";
+import { DbtConnectionListItemSchema, SanitizedDbtConnectionSchema } from "@app/services/app-connection/dbt";
import {
DigitalOceanConnectionListItemSchema,
SanitizedDigitalOceanConnectionSchema
@@ -187,7 +188,8 @@ const SanitizedAppConnectionSchema = z.union([
...SanitizedChefConnectionSchema.options,
...SanitizedDNSMadeEasyConnectionSchema.options,
...SanitizedOctopusDeployConnectionSchema.options,
- ...SanitizedSshConnectionSchema.options
+ ...SanitizedSshConnectionSchema.options,
+ ...SanitizedDbtConnectionSchema.options
]);
const AppConnectionOptionsSchema = z.discriminatedUnion("app", [
@@ -236,7 +238,8 @@ const AppConnectionOptionsSchema = z.discriminatedUnion("app", [
ChefConnectionListItemSchema,
DNSMadeEasyConnectionListItemSchema,
OctopusDeployConnectionListItemSchema,
- SshConnectionListItemSchema
+ SshConnectionListItemSchema,
+ DbtConnectionListItemSchema
]);
export const registerAppConnectionRouter = async (server: FastifyZodProvider) => {
diff --git a/backend/src/server/routes/v1/app-connection-routers/dbt-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/dbt-connection-router.ts
new file mode 100644
index 0000000000..b7ba2954e3
--- /dev/null
+++ b/backend/src/server/routes/v1/app-connection-routers/dbt-connection-router.ts
@@ -0,0 +1,59 @@
+import { z } from "zod";
+
+import { readLimit } from "@app/server/config/rateLimiter";
+import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+import {
+ CreateDbtConnectionSchema,
+ SanitizedDbtConnectionSchema,
+ UpdateDbtConnectionSchema
+} from "@app/services/app-connection/dbt";
+import { AuthMode } from "@app/services/auth/auth-type";
+
+import { registerAppConnectionEndpoints } from "./app-connection-endpoints";
+
+export const registerDbtConnectionRouter = async (server: FastifyZodProvider) => {
+ registerAppConnectionEndpoints({
+ app: AppConnection.Dbt,
+ server,
+ sanitizedResponseSchema: SanitizedDbtConnectionSchema,
+ createSchema: CreateDbtConnectionSchema,
+ updateSchema: UpdateDbtConnectionSchema
+ });
+
+ server.route({
+ method: "GET",
+ url: `/:connectionId/projects`,
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ operationId: "listDbtProjects",
+ params: z.object({
+ connectionId: z.string().uuid()
+ }),
+ response: {
+ 200: z.object({
+ projects: z
+ .object({
+ id: z.number(),
+ name: z.string(),
+ description: z.string(),
+ createdAt: z.string(),
+ updatedAt: z.string()
+ })
+ .array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const {
+ params: { connectionId }
+ } = req;
+
+ const projects = await server.services.appConnection.dbt.listProjects(connectionId, req.permission);
+ return { projects };
+ }
+ });
+};
diff --git a/backend/src/server/routes/v1/app-connection-routers/index.ts b/backend/src/server/routes/v1/app-connection-routers/index.ts
index 6a1ad4ad97..9ca5e57d87 100644
--- a/backend/src/server/routes/v1/app-connection-routers/index.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/index.ts
@@ -16,6 +16,7 @@ import { registerCamundaConnectionRouter } from "./camunda-connection-router";
import { registerChecklyConnectionRouter } from "./checkly-connection-router";
import { registerCloudflareConnectionRouter } from "./cloudflare-connection-router";
import { registerDatabricksConnectionRouter } from "./databricks-connection-router";
+import { registerDbtConnectionRouter } from "./dbt-connection-router";
import { registerDigitalOceanConnectionRouter } from "./digital-ocean-connection-router";
import { registerDNSMadeEasyConnectionRouter } from "./dns-made-easy-connection-router";
import { registerFlyioConnectionRouter } from "./flyio-connection-router";
@@ -96,5 +97,6 @@ export const APP_CONNECTION_REGISTER_ROUTER_MAP: Record<AppConnection, (server:
[AppConnection.MongoDB]: registerMongoDBConnectionRouter,
[AppConnection.Chef]: registerChefConnectionRouter,
[AppConnection.OctopusDeploy]: registerOctopusDeployConnectionRouter,
- [AppConnection.SSH]: registerSshConnectionRouter
+ [AppConnection.SSH]: registerSshConnectionRouter,
+ [AppConnection.Dbt]: registerDbtConnectionRouter
};
diff --git a/backend/src/services/app-connection/app-connection-enums.ts b/backend/src/services/app-connection/app-connection-enums.ts
index 3474914220..7700c574ae 100644
--- a/backend/src/services/app-connection/app-connection-enums.ts
+++ b/backend/src/services/app-connection/app-connection-enums.ts
@@ -44,7 +44,8 @@ export enum AppConnection {
Chef = "chef",
Northflank = "northflank",
OctopusDeploy = "octopus-deploy",
- SSH = "ssh"
+ SSH = "ssh",
+ Dbt = "dbt"
}
export enum AWSRegion {
diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.ts
index 2b9ce06e75..bb400d8c44 100644
--- a/backend/src/services/app-connection/app-connection-fns.ts
+++ b/backend/src/services/app-connection/app-connection-fns.ts
@@ -83,6 +83,7 @@ import {
getDatabricksConnectionListItem,
validateDatabricksConnectionCredentials
} from "./databricks";
+import { DbtConnectionMethod, getDbtConnectionListItem, validateDbtConnectionCredentials } from "./dbt";
import {
DigitalOceanConnectionMethod,
getDigitalOceanConnectionListItem,
@@ -234,7 +235,8 @@ export const listAppConnectionOptions = (projectType?: ProjectType) => {
getRedisConnectionListItem(),
getMongoDBConnectionListItem(),
getChefConnectionListItem(),
- getSshConnectionListItem()
+ getSshConnectionListItem(),
+ getDbtConnectionListItem()
]
.filter((option) => {
switch (projectType) {
@@ -370,7 +372,8 @@ export const validateAppConnectionCredentials = async (
[AppConnection.Redis]: validateRedisConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.MongoDB]: validateMongoDBConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.OctopusDeploy]: validateOctopusDeployConnectionCredentials as TAppConnectionCredentialsValidator,
- [AppConnection.SSH]: validateSshConnectionCredentials as TAppConnectionCredentialsValidator
+ [AppConnection.SSH]: validateSshConnectionCredentials as TAppConnectionCredentialsValidator,
+ [AppConnection.Dbt]: validateDbtConnectionCredentials as TAppConnectionCredentialsValidator
};
return VALIDATE_APP_CONNECTION_CREDENTIALS_MAP[appConnection.app](appConnection, gatewayService, gatewayV2Service);
@@ -415,6 +418,7 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>
case NorthflankConnectionMethod.ApiToken:
case OktaConnectionMethod.ApiToken:
case LaravelForgeConnectionMethod.ApiToken:
+ case DbtConnectionMethod.ApiToken:
return "API Token";
case DNSMadeEasyConnectionMethod.APIKeySecret:
return "API Key & Secret";
@@ -527,7 +531,8 @@ export const TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM: Record<
[AppConnection.LaravelForge]: platformManagedCredentialsNotSupported,
[AppConnection.Chef]: platformManagedCredentialsNotSupported,
[AppConnection.OctopusDeploy]: platformManagedCredentialsNotSupported,
- [AppConnection.SSH]: platformManagedCredentialsNotSupported
+ [AppConnection.SSH]: platformManagedCredentialsNotSupported,
+ [AppConnection.Dbt]: platformManagedCredentialsNotSupported
};
export const enterpriseAppCheck = async (
diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.ts
index 99b0bef3ae..4d40fe6417 100644
--- a/backend/src/services/app-connection/app-connection-service.ts
+++ b/backend/src/services/app-connection/app-connection-service.ts
@@ -73,6 +73,8 @@ import { ValidateCloudflareConnectionCredentialsSchema } from "./cloudflare/clou
import { cloudflareConnectionService } from "./cloudflare/cloudflare-connection-service";
import { ValidateDatabricksConnectionCredentialsSchema } from "./databricks";
import { databricksConnectionService } from "./databricks/databricks-connection-service";
+import { ValidateDbtConnectionCredentialsSchema } from "./dbt";
+import { dbtConnectionService } from "./dbt/dbt-connection-service";
import { ValidateDigitalOceanConnectionCredentialsSchema } from "./digital-ocean";
import { digitalOceanAppPlatformConnectionService } from "./digital-ocean/digital-ocean-connection-service";
import { ValidateDNSMadeEasyConnectionCredentialsSchema } from "./dns-made-easy/dns-made-easy-connection-schema";
@@ -187,7 +189,8 @@ const VALIDATE_APP_CONNECTION_CREDENTIALS_MAP: Record<AppConnection, TValidateAp
[AppConnection.MongoDB]: ValidateMongoDBConnectionCredentialsSchema,
[AppConnection.Chef]: ValidateChefConnectionCredentialsSchema,
[AppConnection.OctopusDeploy]: ValidateOctopusDeployConnectionCredentialsSchema,
- [AppConnection.SSH]: ValidateSshConnectionCredentialsSchema
+ [AppConnection.SSH]: ValidateSshConnectionCredentialsSchema,
+ [AppConnection.Dbt]: ValidateDbtConnectionCredentialsSchema
};
export const appConnectionServiceFactory = ({
@@ -905,6 +908,7 @@ export const appConnectionServiceFactory = ({
okta: oktaConnectionService(connectAppConnectionById),
laravelForge: laravelForgeConnectionService(connectAppConnectionById),
chef: chefConnectionService(connectAppConnectionById, licenseService),
- octopusDeploy: octopusDeployConnectionService(connectAppConnectionById)
+ octopusDeploy: octopusDeployConnectionService(connectAppConnectionById),
+ dbt: dbtConnectionService(connectAppConnectionById)
};
};
diff --git a/backend/src/services/app-connection/app-connection-types.ts b/backend/src/services/app-connection/app-connection-types.ts
index d40975d36b..67e34439a4 100644
--- a/backend/src/services/app-connection/app-connection-types.ts
+++ b/backend/src/services/app-connection/app-connection-types.ts
@@ -100,6 +100,12 @@ import {
TDatabricksConnectionInput,
TValidateDatabricksConnectionCredentialsSchema
} from "./databricks";
+import {
+ TDbtConnection,
+ TDbtConnectionConfig,
+ TDbtConnectionInput,
+ TValidateDbtConnectionCredentialsSchema
+} from "./dbt";
import {
TDigitalOceanConnection,
TDigitalOceanConnectionConfig,
@@ -317,6 +323,7 @@ export type TAppConnection = { id: string } & (
| TChefConnection
| TOctopusDeployConnection
| TSshConnection
+ | TDbtConnection
);
export type TAppConnectionRaw = NonNullable<Awaited<ReturnType<TAppConnectionDALFactory["findById"]>>>;
@@ -370,6 +377,7 @@ export type TAppConnectionInput = { id: string } & (
| TChefConnectionInput
| TOctopusDeployConnectionInput
| TSshConnectionInput
+ | TDbtConnectionInput
);
export type TSqlConnectionInput =
@@ -440,7 +448,8 @@ export type TAppConnectionConfig =
| TMongoDBConnectionConfig
| TChefConnectionConfig
| TOctopusDeployConnectionConfig
- | TSshConnectionConfig;
+ | TSshConnectionConfig
+ | TDbtConnectionConfig;
export type TValidateAppConnectionCredentialsSchema =
| TValidateAwsConnectionCredentialsSchema
@@ -488,7 +497,8 @@ export type TValidateAppConnectionCredentialsSchema =
| TValidateMongoDBConnectionCredentialsSchema
| TValidateChefConnectionCredentialsSchema
| TValidateOctopusDeployConnectionCredentialsSchema
- | TValidateSshConnectionCredentialsSchema;
+ | TValidateSshConnectionCredentialsSchema
+ | TValidateDbtConnectionCredentialsSchema;
export type TListAwsConnectionKmsKeys = {
connectionId: string;
diff --git a/backend/src/services/app-connection/dbt/dbt-connection-constants.ts b/backend/src/services/app-connection/dbt/dbt-connection-constants.ts
new file mode 100644
index 0000000000..67050be37e
--- /dev/null
+++ b/backend/src/services/app-connection/dbt/dbt-connection-constants.ts
@@ -0,0 +1,3 @@
+export enum DbtConnectionMethod {
+ ApiToken = "api-token"
+}
diff --git a/backend/src/services/app-connection/dbt/dbt-connection-fns.ts b/backend/src/services/app-connection/dbt/dbt-connection-fns.ts
new file mode 100644
index 0000000000..1eb296fac4
--- /dev/null
+++ b/backend/src/services/app-connection/dbt/dbt-connection-fns.ts
@@ -0,0 +1,133 @@
+/* eslint-disable no-await-in-loop */
+import axios, { AxiosError } from "axios";
+
+import { BadRequestError } from "@app/lib/errors";
+import { logger } from "@app/lib/logger";
+import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+
+import { DbtConnectionMethod } from "./dbt-connection-constants";
+import { TDbtConnectionConfig, TDbtErrorResponse, TDbtListProjectsResponse } from "./dbt-connection-types";
+
+export const getDbtConnectionListItem = () => {
+ return {
+ name: "DBT" as const,
+ app: AppConnection.Dbt as const,
+ methods: Object.values(DbtConnectionMethod)
+ };
+};
+
+export const getDbtUrl = async (config: {
+ credentials: Pick<TDbtConnectionConfig["credentials"], "instanceUrl">;
+}): Promise<string> => {
+ let hostname: string;
+ try {
+ const urlString = config.credentials.instanceUrl.includes("://")
+ ? config.credentials.instanceUrl
+ : `https://${config.credentials.instanceUrl}`;
+ const url = new URL(urlString);
+ hostname = url.hostname;
+ } catch {
+ throw new BadRequestError({ message: `Invalid DBT instance URL: ${config.credentials.instanceUrl}` });
+ }
+
+ const baseUrl = `https://${hostname}`;
+ await blockLocalAndPrivateIpAddresses(baseUrl);
+
+ return baseUrl;
+};
+
+export const createDbtError = (error: AxiosError) => {
+ if (error.response?.data) {
+ const response = error.response.data as TDbtErrorResponse;
+ if (response?.status?.is_success) {
+ return null;
+ }
+
+ return response?.data?.reason || response?.status?.user_message || response?.status?.developer_message || null;
+ }
+};
+
+const retrieveDbtAccount = async (config: TDbtConnectionConfig) => {
+ const { credentials } = config;
+
+ const dbtUrl = await getDbtUrl(config);
+
+ await axios.get(`${dbtUrl}/api/v2/accounts/${credentials.accountId}/`, {
+ headers: {
+ Authorization: `Bearer ${credentials.apiToken}`
+ }
+ });
+};
+
+export const validateDbtConnectionCredentials = async (config: TDbtConnectionConfig) => {
+ try {
+ // there's no explicit way of checking a tokens permissions,
+ // so we're just checking to see if we're able to retrieve the configured account using the configured api token
+ await retrieveDbtAccount(config);
+ } catch (error: unknown) {
+ if (error instanceof BadRequestError) {
+ throw error;
+ }
+
+ if (error instanceof AxiosError) {
+ throw new BadRequestError({
+ message: `Failed to validate credentials: ${error.message || "Unknown error"}`
+ });
+ }
+
+ throw new BadRequestError({
+ message: "Unable to validate connection - verify credentials"
+ });
+ }
+
+ return config.credentials;
+};
+
+export const listDbtProjects = async (config: TDbtConnectionConfig) => {
+ try {
+ const { credentials } = config;
+
+ const dbtUrl = await getDbtUrl(config);
+
+ const res = await axios.get<TDbtListProjectsResponse>(
+ `${dbtUrl}/api/v3/accounts/${credentials.accountId}/projects`,
+ {
+ headers: {
+ Authorization: `Bearer ${credentials.apiToken}`
+ }
+ }
+ );
+
+ return res.data.data.map((project) => ({
+ id: project.id,
+ name: project.name,
+ description: project.description || "",
+ createdAt: project.created_at,
+ updatedAt: project.updated_at
+ }));
+ } catch (error: unknown) {
+ if (error instanceof BadRequestError) {
+ throw error;
+ }
+
+ logger.error(error, "Failed to list DBT projects");
+
+ if (error instanceof AxiosError) {
+ const errorMessage = createDbtError(error);
+ if (errorMessage) {
+ throw new BadRequestError({
+ message: `Failed to list projects: ${errorMessage}`
+ });
+ }
+
+ throw new BadRequestError({
+ message: `Failed to list projects: ${error.message || "Unknown error"}`
+ });
+ }
+
+ throw new BadRequestError({
+ message: "Unable to list projects"
+ });
+ }
+};
diff --git a/backend/src/services/app-connection/dbt/dbt-connection-schemas.ts b/backend/src/services/app-connection/dbt/dbt-connection-schemas.ts
new file mode 100644
index 0000000000..c4b2a1a5a2
--- /dev/null
+++ b/backend/src/services/app-connection/dbt/dbt-connection-schemas.ts
@@ -0,0 +1,70 @@
+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 { DbtConnectionMethod } from "./dbt-connection-constants";
+
+export const DbtConnectionMethodSchema = z
+ .nativeEnum(DbtConnectionMethod)
+ .describe(AppConnections.CREATE(AppConnection.Dbt).method);
+
+export const DbtConnectionApiTokenCredentialsSchema = z.object({
+ apiToken: z.string().trim().min(1, "API Token required").max(255).describe(AppConnections.CREDENTIALS.DBT.apiToken),
+ instanceUrl: z
+ .string()
+ .trim()
+ .min(1, "Instance URL required")
+ .url("Invalid Instance URL")
+ .describe(AppConnections.CREDENTIALS.DBT.instanceUrl),
+ accountId: z.string().trim().min(1, "Account ID required").max(255).describe(AppConnections.CREDENTIALS.DBT.accountId)
+});
+
+const BaseDbtConnectionSchema = BaseAppConnectionSchema.extend({
+ app: z.literal(AppConnection.Dbt)
+});
+
+export const DbtConnectionSchema = BaseDbtConnectionSchema.extend({
+ method: DbtConnectionMethodSchema,
+ credentials: DbtConnectionApiTokenCredentialsSchema
+});
+
+export const SanitizedDbtConnectionSchema = z.discriminatedUnion("method", [
+ BaseDbtConnectionSchema.extend({
+ method: DbtConnectionMethodSchema,
+ credentials: DbtConnectionApiTokenCredentialsSchema.pick({ instanceUrl: true, accountId: true })
+ }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.Dbt]} (API Token)` }))
+]);
+
+export const ValidateDbtConnectionCredentialsSchema = z.discriminatedUnion("method", [
+ z.object({
+ method: DbtConnectionMethodSchema,
+ credentials: DbtConnectionApiTokenCredentialsSchema.describe(AppConnections.CREATE(AppConnection.Dbt).credentials)
+ })
+]);
+
+export const CreateDbtConnectionSchema = ValidateDbtConnectionCredentialsSchema.and(
+ GenericCreateAppConnectionFieldsSchema(AppConnection.Dbt)
+);
+
+export const UpdateDbtConnectionSchema = z
+ .object({
+ credentials: DbtConnectionApiTokenCredentialsSchema.optional().describe(
+ AppConnections.UPDATE(AppConnection.Dbt).credentials
+ )
+ })
+ .and(GenericUpdateAppConnectionFieldsSchema(AppConnection.Dbt));
+
+export const DbtConnectionListItemSchema = z
+ .object({
+ name: z.literal("DBT"),
+ app: z.literal(AppConnection.Dbt),
+ methods: z.nativeEnum(DbtConnectionMethod).array()
+ })
+ .describe(JSON.stringify({ title: APP_CONNECTION_NAME_MAP[AppConnection.Dbt] }));
diff --git a/backend/src/services/app-connection/dbt/dbt-connection-service.ts b/backend/src/services/app-connection/dbt/dbt-connection-service.ts
new file mode 100644
index 0000000000..6c49b43d4a
--- /dev/null
+++ b/backend/src/services/app-connection/dbt/dbt-connection-service.ts
@@ -0,0 +1,23 @@
+import { OrgServiceActor } from "@app/lib/types";
+
+import { AppConnection } from "../app-connection-enums";
+import { listDbtProjects } from "./dbt-connection-fns";
+import { TDbtConnection } from "./dbt-connection-types";
+
+type TGetAppConnectionFunc = (
+ app: AppConnection,
+ connectionId: string,
+ actor: OrgServiceActor
+) => Promise<TDbtConnection>;
+
+export const dbtConnectionService = (getAppConnection: TGetAppConnectionFunc) => {
+ const listProjects = async (connectionId: string, actor: OrgServiceActor) => {
+ const appConnection = await getAppConnection(AppConnection.Dbt, connectionId, actor);
+ const projects = await listDbtProjects(appConnection);
+ return projects;
+ };
+
+ return {
+ listProjects
+ };
+};
diff --git a/backend/src/services/app-connection/dbt/dbt-connection-types.ts b/backend/src/services/app-connection/dbt/dbt-connection-types.ts
new file mode 100644
index 0000000000..2d0f6aae01
--- /dev/null
+++ b/backend/src/services/app-connection/dbt/dbt-connection-types.ts
@@ -0,0 +1,49 @@
+import z from "zod";
+
+import { DiscriminativePick } from "@app/lib/types";
+
+import { AppConnection } from "../app-connection-enums";
+import {
+ CreateDbtConnectionSchema,
+ DbtConnectionSchema,
+ ValidateDbtConnectionCredentialsSchema
+} from "./dbt-connection-schemas";
+
+export type TDbtConnection = z.infer<typeof DbtConnectionSchema>;
+
+export type TDbtConnectionInput = z.infer<typeof CreateDbtConnectionSchema> & {
+ app: AppConnection.Dbt;
+};
+
+export type TValidateDbtConnectionCredentialsSchema = typeof ValidateDbtConnectionCredentialsSchema;
+
+export type TDbtConnectionConfig = DiscriminativePick<TDbtConnection, "method" | "app" | "credentials"> & {
+ orgId: string;
+};
+
+export interface TDbtStatusResponse {
+ status: {
+ code: number;
+ is_success: boolean;
+ user_message: string;
+ developer_message: string;
+ };
+}
+
+export interface TDbtErrorResponse extends TDbtStatusResponse {
+ data: {
+ reason?: string;
+ };
+}
+
+export interface TDbtProject {
+ id: number;
+ name: string;
+ description?: string;
+ created_at: string;
+ updated_at: string;
+}
+
+export interface TDbtListProjectsResponse extends TDbtStatusResponse {
+ data: TDbtProject[];
+}
diff --git a/backend/src/services/app-connection/dbt/index.ts b/backend/src/services/app-connection/dbt/index.ts
new file mode 100644
index 0000000000..93638900f6
--- /dev/null
+++ b/backend/src/services/app-connection/dbt/index.ts
@@ -0,0 +1,4 @@
+export * from "./dbt-connection-constants";
+export * from "./dbt-connection-fns";
+export * from "./dbt-connection-schemas";
+export * from "./dbt-connection-types";
diff --git a/frontend/public/images/integrations/DBT.png b/frontend/public/images/integrations/DBT.png
new file mode 100644
index 0000000000..ddd2f21a6f
Binary files /dev/null and b/frontend/public/images/integrations/DBT.png differ
diff --git a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewDbtSeviceTokenRotationGeneratedCredentials.tsx b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewDbtSeviceTokenRotationGeneratedCredentials.tsx
new file mode 100644
index 0000000000..6f7026bbf5
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewDbtSeviceTokenRotationGeneratedCredentials.tsx
@@ -0,0 +1,44 @@
+import { CredentialDisplay } from "@app/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/shared/CredentialDisplay";
+import { TDbtServiceTokenRotationGeneratedCredentialsResponse } from "@app/hooks/api/secretRotationsV2/types/dbt-service-token-rotation";
+
+import { ViewRotationGeneratedCredentialsDisplay } from "./shared";
+
+type Props = {
+ generatedCredentialsResponse: TDbtServiceTokenRotationGeneratedCredentialsResponse;
+};
+
+export const ViewDbtServiceTokenRotationGeneratedCredentials = ({
+ generatedCredentialsResponse: { generatedCredentials, activeIndex }
+}: Props) => {
+ const inactiveIndex = activeIndex === 0 ? 1 : 0;
+
+ const activeCredentials = generatedCredentials[activeIndex];
+ const inactiveCredentials = generatedCredentials[inactiveIndex];
+
+ return (
+ <ViewRotationGeneratedCredentialsDisplay
+ activeCredentials={
+ <>
+ <CredentialDisplay label="Token Name">{activeCredentials?.tokenName}</CredentialDisplay>
+ <CredentialDisplay label="Token ID">
+ {(activeCredentials?.tokenId || "")?.toString()}
+ </CredentialDisplay>
+ <CredentialDisplay label="Service Token">
+ {activeCredentials?.serviceToken}
+ </CredentialDisplay>
+ </>
+ }
+ inactiveCredentials={
+ <>
+ <CredentialDisplay label="Token Name">{inactiveCredentials?.tokenName}</CredentialDisplay>
+ <CredentialDisplay label="Token ID">
+ {(inactiveCredentials?.tokenId || "")?.toString()}
+ </CredentialDisplay>
+ <CredentialDisplay label="Service Token">
+ {inactiveCredentials?.serviceToken}
+ </CredentialDisplay>
+ </>
+ }
+ />
+ );
+};
diff --git a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx
index ec71f1d436..9163b6f51a 100644
--- a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx
+++ b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx
@@ -23,6 +23,7 @@ import {
import { ViewSqlCredentialsRotationGeneratedCredentials } from "./shared";
import { ViewAwsIamUserSecretRotationGeneratedCredentials } from "./ViewAwsIamUserSecretRotationGeneratedCredentials";
+import { ViewDbtServiceTokenRotationGeneratedCredentials } from "./ViewDbtSeviceTokenRotationGeneratedCredentials";
import { ViewOktaClientSecretRotationGeneratedCredentials } from "./ViewOktaClientSecretRotationGeneratedCredentials";
import { ViewRedisCredentialsRotationGeneratedCredentials } from "./ViewRedisCredentialsRotationGeneratedCredentials";
import { ViewUnixLinuxLocalAccountRotationGeneratedCredentials } from "./ViewUnixLinuxLocalAccountRotationGeneratedCredentials";
@@ -132,6 +133,13 @@ const Content = ({ secretRotation }: ContentProps) => {
/>
);
break;
+ case SecretRotation.DbtServiceToken:
+ Component = (
+ <ViewDbtServiceTokenRotationGeneratedCredentials
+ generatedCredentialsResponse={generatedCredentialsResponse}
+ />
+ );
+ break;
default:
throw new Error("Unhandled View Generated Credential Rotation Type");
}
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/DbtServiceTokenRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/DbtServiceTokenRotationParametersFields.tsx
new file mode 100644
index 0000000000..4d02500083
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/DbtServiceTokenRotationParametersFields.tsx
@@ -0,0 +1,163 @@
+import { useEffect, useMemo } from "react";
+import { Controller, useFieldArray, useFormContext } from "react-hook-form";
+import { SingleValue } from "react-select";
+import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
+import {
+ Button,
+ FilterableSelect,
+ FormControl,
+ FormLabel,
+ IconButton,
+ Select,
+ SelectItem
+} from "@app/components/v2";
+import { TDbtProject, useDbtConnectionListProjects } from "@app/hooks/api/appConnections/dbt";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+
+import {
+ DBT_PERMISSION_SET_MAP,
+ DbtPermissionsSet
+} from "../schemas/dbt-service-token-rotation-schema";
+
+export const DbtServiceTokenRotationParametersFields = () => {
+ const { control, watch, setValue, getValues } = useFormContext<
+ TSecretRotationV2Form & {
+ type: SecretRotation.DbtServiceToken;
+ }
+ >();
+
+ const connectionId = watch("connection.id");
+
+ const { data: projects, isPending: isProjectsPending } = useDbtConnectionListProjects(
+ connectionId,
+ {
+ enabled: Boolean(connectionId)
+ }
+ );
+
+ const selectableProjects = useMemo(() => {
+ if (!projects) return [];
+ return [
+ {
+ id: undefined,
+ name: "All projects"
+ } as unknown as TDbtProject,
+ ...projects
+ ];
+ }, [projects]);
+
+ const permissionGrantsFields = useFieldArray({
+ control,
+ name: "parameters.permissionGrants"
+ });
+
+ useEffect(() => {
+ if (permissionGrantsFields.fields.length === 0) {
+ setValue("parameters.permissionGrants", [
+ { permissionSet: DbtPermissionsSet.AccountAdmin, projectId: undefined }
+ ]);
+ }
+ }, []);
+
+ const permissionGrants = watch("parameters.permissionGrants");
+
+ console.log(permissionGrants);
+
+ return (
+ <>
+ <FormLabel label="Roles" />
+ <div className="mb-3 flex w-full flex-col space-y-2">
+ {permissionGrantsFields.fields.map(({ id: roleFieldId }, i) => (
+ <div key={roleFieldId} className="flex items-end space-x-2">
+ <div className="w-72">
+ {i === 0 && <span className="text-xs text-mineshaft-400">Permission set</span>}
+ <Controller
+ control={control}
+ name={`parameters.permissionGrants.${i}.permissionSet`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0"
+ >
+ <Select className="w-72" value={field.value} onValueChange={field.onChange}>
+ {Object.entries(DBT_PERMISSION_SET_MAP).map(([permissionSet, label]) => (
+ <SelectItem key={permissionSet} value={permissionSet}>
+ {label}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="grow">
+ {i === 0 && <FormLabel label="Projects" className="text-xs text-mineshaft-400" />}
+ <Controller
+ control={control}
+ name={`parameters.permissionGrants.${i}.projectId`}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0 w-full"
+ >
+ <FilterableSelect
+ isLoading={isProjectsPending && Boolean(connectionId)}
+ isDisabled={!connectionId}
+ options={selectableProjects}
+ getOptionLabel={(option) => option.name}
+ getOptionValue={(option) =>
+ typeof option.id === "undefined" ? option.id : option.id.toString()
+ }
+ value={selectableProjects?.find((p) => p.id === value) ?? undefined}
+ onChange={(option) => {
+ const v = (option as SingleValue<TDbtProject>)?.id;
+ onChange(v ? Number(v) : undefined);
+ }}
+ />
+ </FormControl>
+ )}
+ />
+ </div>
+ <IconButton
+ ariaLabel="delete key"
+ className="bottom-0.5 h-9"
+ variant="outline_bg"
+ onClick={() => {
+ const roles = getValues("parameters.permissionGrants");
+ if (roles && roles?.length > 1) {
+ permissionGrantsFields.remove(i);
+ } else {
+ setValue("parameters.permissionGrants", [
+ { permissionSet: DbtPermissionsSet.AccountAdmin, projectId: undefined }
+ ]);
+ }
+ }}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </div>
+ ))}
+ <div>
+ <Button
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ variant="outline_bg"
+ onClick={() =>
+ permissionGrantsFields.append({
+ permissionSet: DbtPermissionsSet.AccountAdmin,
+ projectId: undefined
+ })
+ }
+ >
+ Add grant
+ </Button>
+ </div>
+ </div>
+ </>
+ );
+};
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx
index 70654f2fe7..33be2022db 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx
@@ -7,6 +7,7 @@ import { Auth0ClientSecretRotationParametersFields } from "./Auth0ClientSecretRo
import { AwsIamUserSecretRotationParametersFields } from "./AwsIamUserSecretRotationParametersFields";
import { AzureClientSecretRotationParametersFields } from "./AzureClientSecretRotationParametersFields";
import { DatabricksServicePrincipalSecretRotationParametersFields } from "./DatabricksServicePrincipalSecretRotationParametersFields";
+import { DbtServiceTokenRotationParametersFields } from "./DbtServiceTokenRotationParametersFields";
import { LdapPasswordRotationParametersFields } from "./LdapPasswordRotationParametersFields";
import { MongoRotationParametersFields } from "./MongoRotationParametersFields";
import { OktaClientSecretRotationParametersFields } from "./OktaClientSecretRotationParametersFields";
@@ -28,7 +29,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.MongoDBCredentials]: MongoRotationParametersFields,
[SecretRotation.DatabricksServicePrincipalSecret]:
DatabricksServicePrincipalSecretRotationParametersFields,
- [SecretRotation.UnixLinuxLocalAccount]: UnixLinuxLocalAccountRotationParametersFields
+ [SecretRotation.UnixLinuxLocalAccount]: UnixLinuxLocalAccountRotationParametersFields,
+ [SecretRotation.DbtServiceToken]: DbtServiceTokenRotationParametersFields
};
export const SecretRotationV2ParametersFields = () => {
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/DbtServiceTokenRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/DbtServiceTokenRotationReviewFields.tsx
new file mode 100644
index 0000000000..8a35ad485d
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/DbtServiceTokenRotationReviewFields.tsx
@@ -0,0 +1,39 @@
+import { useFormContext } from "react-hook-form";
+
+import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
+import { GenericFieldLabel } from "@app/components/v2";
+import { Badge } from "@app/components/v3";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+
+import { DBT_PERMISSION_SET_MAP } from "../schemas/dbt-service-token-rotation-schema";
+import { SecretRotationReviewSection } from "./shared";
+
+export const DbtServiceTokenRotationReviewFields = () => {
+ const { watch } = useFormContext<
+ TSecretRotationV2Form & {
+ type: SecretRotation.DbtServiceToken;
+ }
+ >();
+
+ const [parameters, { serviceToken }] = watch(["parameters", "secretsMapping"]);
+
+ return (
+ <>
+ <SecretRotationReviewSection label="Parameters">
+ {parameters.permissionGrants.map((grant, i) => (
+ <GenericFieldLabel key={`grant-${i + 1}`} label={`Permission Grant ${i + 1}`}>
+ <div className="flex items-center gap-2">
+ <span>{DBT_PERMISSION_SET_MAP[grant.permissionSet]}</span>
+ <Badge variant={grant.projectId ? "neutral" : "info"}>
+ {grant.projectId ? `Project: ${grant.projectId}` : "All Projects"}
+ </Badge>
+ </div>
+ </GenericFieldLabel>
+ ))}
+ </SecretRotationReviewSection>
+ <SecretRotationReviewSection label="Secrets Mapping">
+ <GenericFieldLabel label="Service Token">{serviceToken}</GenericFieldLabel>
+ </SecretRotationReviewSection>
+ </>
+ );
+};
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx
index e361156b13..5cc365d49b 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx
@@ -10,6 +10,7 @@ import { Auth0ClientSecretRotationReviewFields } from "./Auth0ClientSecretRotati
import { AwsIamUserSecretRotationReviewFields } from "./AwsIamUserSecretRotationReviewFields";
import { AzureClientSecretRotationReviewFields } from "./AzureClientSecretRotationReviewFields";
import { DatabricksServicePrincipalSecretRotationReviewFields } from "./DatabricksServicePrincipalSecretRotationReviewFields";
+import { DbtServiceTokenRotationReviewFields } from "./DbtServiceTokenRotationReviewFields";
import { LdapPasswordRotationReviewFields } from "./LdapPasswordRotationReviewFields";
import { OktaClientSecretRotationReviewFields } from "./OktaClientSecretRotationReviewFields";
import { RedisCredentialsRotationReviewFields } from "./RedisCredentialsRotationReviewFields";
@@ -30,7 +31,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.MongoDBCredentials]: SqlCredentialsRotationReviewFields,
[SecretRotation.DatabricksServicePrincipalSecret]:
DatabricksServicePrincipalSecretRotationReviewFields,
- [SecretRotation.UnixLinuxLocalAccount]: UnixLinuxLocalAccountRotationReviewFields
+ [SecretRotation.UnixLinuxLocalAccount]: UnixLinuxLocalAccountRotationReviewFields,
+ [SecretRotation.DbtServiceToken]: DbtServiceTokenRotationReviewFields
};
export const SecretRotationV2ReviewFields = () => {
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/DbtServiceTokenRotationSecretsMappingFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/DbtServiceTokenRotationSecretsMappingFields.tsx
new file mode 100644
index 0000000000..816bbcdc6c
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/DbtServiceTokenRotationSecretsMappingFields.tsx
@@ -0,0 +1,40 @@
+import { Controller, useFormContext } from "react-hook-form";
+
+import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
+import { FormControl, Input } from "@app/components/v2";
+import { SecretRotation, useSecretRotationV2Option } from "@app/hooks/api/secretRotationsV2";
+
+import { SecretsMappingTable } from "./shared";
+
+export const DbtServiceTokenRotationSecretsMappingFields = () => {
+ const { control } = useFormContext<
+ TSecretRotationV2Form & {
+ type: SecretRotation.DbtServiceToken;
+ }
+ >();
+
+ const { rotationOption } = useSecretRotationV2Option(SecretRotation.DbtServiceToken);
+
+ const items = [
+ {
+ name: "Service Token",
+ input: (
+ <Controller
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl isError={Boolean(error)} errorText={error?.message}>
+ <Input
+ value={value}
+ onChange={onChange}
+ placeholder={rotationOption?.template.secretsMapping.serviceToken}
+ />
+ </FormControl>
+ )}
+ control={control}
+ name="secretsMapping.serviceToken"
+ />
+ )
+ }
+ ];
+
+ return <SecretsMappingTable items={items} />;
+};
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx
index 1f8506a4af..34964d12cc 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx
@@ -7,6 +7,7 @@ import { Auth0ClientSecretRotationSecretsMappingFields } from "./Auth0ClientSecr
import { AwsIamUserSecretRotationSecretsMappingFields } from "./AwsIamUserSecretRotationSecretsMappingFields";
import { AzureClientSecretRotationSecretsMappingFields } from "./AzureClientSecretRotationSecretsMappingFields";
import { DatabricksServicePrincipalSecretRotationSecretsMappingFields } from "./DatabricksServicePrincipalSecretRotationSecretsMappingFields";
+import { DbtServiceTokenRotationSecretsMappingFields } from "./DbtServiceTokenRotationSecretsMappingFields";
import { LdapPasswordRotationSecretsMappingFields } from "./LdapPasswordRotationSecretsMappingFields";
import { OktaClientSecretRotationSecretsMappingFields } from "./OktaClientSecretRotationSecretsMappingFields";
import { RedisCredentialsRotationSecretsMappingFields } from "./RedisCredentialsRotationSecretsMappingFields";
@@ -27,7 +28,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.MongoDBCredentials]: SqlCredentialsRotationSecretsMappingFields,
[SecretRotation.DatabricksServicePrincipalSecret]:
DatabricksServicePrincipalSecretRotationSecretsMappingFields,
- [SecretRotation.UnixLinuxLocalAccount]: UnixLinuxLocalAccountRotationSecretsMappingFields
+ [SecretRotation.UnixLinuxLocalAccount]: UnixLinuxLocalAccountRotationSecretsMappingFields,
+ [SecretRotation.DbtServiceToken]: DbtServiceTokenRotationSecretsMappingFields
};
export const SecretRotationV2SecretsMappingFields = () => {
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/dbt-service-token-rotation-schema.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/dbt-service-token-rotation-schema.ts
new file mode 100644
index 0000000000..d0711b6129
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/dbt-service-token-rotation-schema.ts
@@ -0,0 +1,83 @@
+import { z } from "zod";
+
+import { BaseSecretRotationSchema } from "@app/components/secret-rotations-v2/forms/schemas/base-secret-rotation-v2-schema";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+
+export enum DbtPermissionsSet {
+ AccountAdmin = "account_admin",
+ AccountViewer = "account_viewer",
+ Admin = "admin",
+ Analyst = "analyst",
+ BillingAdmin = "billing_admin",
+ CostInsightsAdmin = "cost_insights_admin",
+ ConstInsightViewer = "cost_insights_viewer",
+ CostManagementAdmin = "cost_management_admin",
+ CostManagementViewer = "cost_management_viewer",
+ DatabaseAdmin = "database_admin",
+ Developer = "developer",
+ FusionAdmin = "fusion_admin",
+ GitAdmin = "git_admin",
+ JobAdmin = "job_admin",
+ JobRunner = "job_runner",
+ JobViewer = "job_viewer",
+ ManageMarketplaceApps = "manage_marketplace_apps",
+ Member = "member",
+ MetadataOnly = "metadata_only",
+ Owner = "owner",
+ ProjectCreator = "project_creator",
+ Readonly = "readonly",
+ ScimOnly = "scim_only",
+ SecurityAdmin = "security_admin",
+ SemanticLayerOnly = "semantic_layer_only",
+ Stakeholder = "stakeholder",
+ TeamAdmin = "team_admin",
+ WebhooksOnly = "webhooks_only"
+}
+
+export const DBT_PERMISSION_SET_MAP: Record<DbtPermissionsSet, string> = {
+ [DbtPermissionsSet.AccountAdmin]: "Account Admin",
+ [DbtPermissionsSet.AccountViewer]: "Account Viewer",
+ [DbtPermissionsSet.Admin]: "Admin",
+ [DbtPermissionsSet.Analyst]: "Analyst",
+ [DbtPermissionsSet.BillingAdmin]: "Billing Admin",
+ [DbtPermissionsSet.CostInsightsAdmin]: "Cost Insights Admin",
+ [DbtPermissionsSet.ConstInsightViewer]: "Cost Insights Viewer",
+ [DbtPermissionsSet.CostManagementAdmin]: "Cost Management Admin",
+ [DbtPermissionsSet.CostManagementViewer]: "Cost Management Viewer",
+ [DbtPermissionsSet.DatabaseAdmin]: "Database Admin",
+ [DbtPermissionsSet.Developer]: "Developer",
+ [DbtPermissionsSet.FusionAdmin]: "Fusion Admin",
+ [DbtPermissionsSet.GitAdmin]: "Git Admin",
+ [DbtPermissionsSet.JobAdmin]: "Job Admin",
+ [DbtPermissionsSet.JobRunner]: "Job Runner",
+ [DbtPermissionsSet.JobViewer]: "Job Viewer",
+ [DbtPermissionsSet.ManageMarketplaceApps]: "Manage Marketplace Apps",
+ [DbtPermissionsSet.Member]: "Member",
+ [DbtPermissionsSet.MetadataOnly]: "Metadata Only",
+ [DbtPermissionsSet.Owner]: "Owner",
+ [DbtPermissionsSet.ProjectCreator]: "Project Creator",
+ [DbtPermissionsSet.Readonly]: "Readonly",
+ [DbtPermissionsSet.ScimOnly]: "SCIM Only",
+ [DbtPermissionsSet.SecurityAdmin]: "Security Admin",
+ [DbtPermissionsSet.SemanticLayerOnly]: "Semantic Layer Only",
+ [DbtPermissionsSet.Stakeholder]: "Stakeholder",
+ [DbtPermissionsSet.TeamAdmin]: "Team Admin",
+ [DbtPermissionsSet.WebhooksOnly]: "Webhooks Only"
+};
+
+export const DbtTokenPermissionsSchema = z.object({
+ permissionSet: z.nativeEnum(DbtPermissionsSet),
+ projectId: z.number().optional()
+});
+
+export const DbtServiceTokenRotationSchema = z
+ .object({
+ type: z.literal(SecretRotation.DbtServiceToken),
+ parameters: z.object({
+ permissionGrants: DbtTokenPermissionsSchema.array()
+ }),
+ secretsMapping: z.object({
+ serviceToken: z.string().trim().min(1, "Service Token required")
+ })
+ })
+ .merge(BaseSecretRotationSchema);
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts
index d7edf85bb5..06ee64cb7b 100644
--- a/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts
@@ -17,6 +17,7 @@ import { OktaClientSecretRotationSchema } from "./okta-client-secret-rotation-sc
import { OracleDBCredentialsRotationSchema } from "./oracledb-credentials-rotation-schema";
import { RedisCredentialsRotationSchema } from "./redis-credentials-rotation-schema";
import { UnixLinuxLocalAccountRotationSchema } from "./unix-linux-local-account-rotation-schema";
+import { DbtServiceTokenRotationSchema } from "./dbt-service-token-rotation-schema";
export const SecretRotationV2FormSchema = (isUpdate: boolean) =>
z
@@ -34,7 +35,8 @@ export const SecretRotationV2FormSchema = (isUpdate: boolean) =>
RedisCredentialsRotationSchema,
MongoDBCredentialsRotationSchema,
DatabricksServicePrincipalSecretRotationSchema,
- UnixLinuxLocalAccountRotationSchema
+ UnixLinuxLocalAccountRotationSchema,
+ DbtServiceTokenRotationSchema
]),
z.object({ id: z.string().optional() })
)
diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.ts
index f2bac4054d..171d1befe7 100644
--- a/frontend/src/helpers/appConnections.ts
+++ b/frontend/src/helpers/appConnections.ts
@@ -23,6 +23,7 @@ import {
CamundaConnectionMethod,
CloudflareConnectionMethod,
DatabricksConnectionMethod,
+ DbtConnectionMethod,
FlyioConnectionMethod,
GcpConnectionMethod,
GitHubConnectionMethod,
@@ -140,7 +141,8 @@ export const APP_CONNECTION_MAP: Record<
},
[AppConnection.Chef]: { name: "Chef", image: "Chef.png", enterprise: true },
[AppConnection.OctopusDeploy]: { name: "Octopus Deploy", image: "Octopus Deploy.png" },
- [AppConnection.SSH]: { name: "SSH", image: "SSH.png" }
+ [AppConnection.SSH]: { name: "SSH", image: "SSH.png" },
+ [AppConnection.Dbt]: { name: "DBT", image: "DBT.png" }
};
export const getAppConnectionMethodDetails = (method: TAppConnection["method"]) => {
@@ -180,6 +182,7 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])
case NorthflankConnectionMethod.ApiToken:
case OktaConnectionMethod.ApiToken:
case LaravelForgeConnectionMethod.ApiToken:
+ case DbtConnectionMethod.ApiToken:
return { name: "API Token", icon: faKey };
case PostgresConnectionMethod.UsernameAndPassword:
case MsSqlConnectionMethod.UsernameAndPassword:
diff --git a/frontend/src/helpers/secretRotationsV2.ts b/frontend/src/helpers/secretRotationsV2.ts
index 5b298b7596..92efb4d20b 100644
--- a/frontend/src/helpers/secretRotationsV2.ts
+++ b/frontend/src/helpers/secretRotationsV2.ts
@@ -69,6 +69,11 @@ export const SECRET_ROTATION_MAP: Record<
name: "Unix/Linux Local Account",
image: "SSH.png",
size: 50
+ },
+ [SecretRotation.DbtServiceToken]: {
+ name: "DBT Service Token",
+ image: "DBT.png",
+ size: 50
}
};
@@ -85,7 +90,8 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio
[SecretRotation.RedisCredentials]: AppConnection.Redis,
[SecretRotation.MongoDBCredentials]: AppConnection.MongoDB,
[SecretRotation.DatabricksServicePrincipalSecret]: AppConnection.Databricks,
- [SecretRotation.UnixLinuxLocalAccount]: AppConnection.SSH
+ [SecretRotation.UnixLinuxLocalAccount]: AppConnection.SSH,
+ [SecretRotation.DbtServiceToken]: AppConnection.Dbt
};
// if a rotation can potentially have downtime due to rotating a single credential set this to false
@@ -102,7 +108,8 @@ export const IS_ROTATION_DUAL_CREDENTIALS: Record<SecretRotation, boolean> = {
[SecretRotation.RedisCredentials]: true,
[SecretRotation.MongoDBCredentials]: true,
[SecretRotation.DatabricksServicePrincipalSecret]: true,
- [SecretRotation.UnixLinuxLocalAccount]: false
+ [SecretRotation.UnixLinuxLocalAccount]: false,
+ [SecretRotation.DbtServiceToken]: true
};
export const getRotateAtLocal = ({ hours, minutes }: TSecretRotationV2["rotateAtUtc"]) => {
diff --git a/frontend/src/hooks/api/appConnections/dbt/index.ts b/frontend/src/hooks/api/appConnections/dbt/index.ts
new file mode 100644
index 0000000000..2c1906d369
--- /dev/null
+++ b/frontend/src/hooks/api/appConnections/dbt/index.ts
@@ -0,0 +1,2 @@
+export * from "./queries";
+export * from "./types";
diff --git a/frontend/src/hooks/api/appConnections/dbt/queries.tsx b/frontend/src/hooks/api/appConnections/dbt/queries.tsx
new file mode 100644
index 0000000000..3705d4d33a
--- /dev/null
+++ b/frontend/src/hooks/api/appConnections/dbt/queries.tsx
@@ -0,0 +1,37 @@
+import { useQuery, UseQueryOptions } from "@tanstack/react-query";
+
+import { apiRequest } from "@app/config/request";
+
+import { appConnectionKeys } from "../queries";
+import { TDbtProject } from "./types";
+
+const dbtConnectionKeys = {
+ all: [...appConnectionKeys.all, "dbt"] as const,
+ listProjects: (connectionId: string) =>
+ [...dbtConnectionKeys.all, "projects", connectionId] as const
+};
+
+export const useDbtConnectionListProjects = (
+ connectionId: string,
+ options?: Omit<
+ UseQueryOptions<
+ TDbtProject[],
+ unknown,
+ TDbtProject[],
+ ReturnType<typeof dbtConnectionKeys.listProjects>
+ >,
+ "queryKey" | "queryFn"
+ >
+) => {
+ return useQuery({
+ queryKey: dbtConnectionKeys.listProjects(connectionId),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ projects: TDbtProject[] }>(
+ `/api/v1/app-connections/dbt/${connectionId}/projects`
+ );
+
+ return data.projects;
+ },
+ ...options
+ });
+};
diff --git a/frontend/src/hooks/api/appConnections/dbt/types.ts b/frontend/src/hooks/api/appConnections/dbt/types.ts
new file mode 100644
index 0000000000..7f40abedfe
--- /dev/null
+++ b/frontend/src/hooks/api/appConnections/dbt/types.ts
@@ -0,0 +1,7 @@
+export type TDbtProject = {
+ id: number;
+ name: string;
+ description: string;
+ createdAt: string;
+ updatedAt: string;
+};
diff --git a/frontend/src/hooks/api/appConnections/enums.ts b/frontend/src/hooks/api/appConnections/enums.ts
index 634f8ba208..d793fdcb0d 100644
--- a/frontend/src/hooks/api/appConnections/enums.ts
+++ b/frontend/src/hooks/api/appConnections/enums.ts
@@ -44,5 +44,6 @@ export enum AppConnection {
LaravelForge = "laravel-forge",
Chef = "chef",
OctopusDeploy = "octopus-deploy",
- SSH = "ssh"
+ SSH = "ssh",
+ Dbt = "dbt"
}
diff --git a/frontend/src/hooks/api/appConnections/types/dbt-connection.ts b/frontend/src/hooks/api/appConnections/types/dbt-connection.ts
new file mode 100644
index 0000000000..fcf5ae8577
--- /dev/null
+++ b/frontend/src/hooks/api/appConnections/types/dbt-connection.ts
@@ -0,0 +1,16 @@
+import { AppConnection } from "@app/hooks/api/appConnections/enums";
+import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
+
+export enum DbtConnectionMethod {
+ ApiToken = "api-token"
+}
+
+export type TDbtConnection = TRootAppConnection & {
+ app: AppConnection.Dbt;
+ method: DbtConnectionMethod.ApiToken;
+ credentials: {
+ apiToken: string;
+ instanceUrl: string;
+ accountId: string;
+ };
+};
diff --git a/frontend/src/hooks/api/appConnections/types/index.ts b/frontend/src/hooks/api/appConnections/types/index.ts
index 4cf63d2182..5a4df3f021 100644
--- a/frontend/src/hooks/api/appConnections/types/index.ts
+++ b/frontend/src/hooks/api/appConnections/types/index.ts
@@ -14,6 +14,7 @@ import { TChecklyConnection } from "./checkly-connection";
import { TChefConnection } from "./chef-connection";
import { TCloudflareConnection } from "./cloudflare-connection";
import { TDatabricksConnection } from "./databricks-connection";
+import { TDbtConnection } from "./dbt-connection";
import { TDigitalOceanConnection } from "./digital-ocean";
import { TDNSMadeEasyConnection } from "./dns-made-easy-connection";
import { TFlyioConnection } from "./flyio-connection";
@@ -61,6 +62,7 @@ export * from "./checkly-connection";
export * from "./chef-connection";
export * from "./cloudflare-connection";
export * from "./databricks-connection";
+export * from "./dbt-connection";
export * from "./dns-made-easy-connection";
export * from "./flyio-connection";
export * from "./gcp-connection";
@@ -139,7 +141,8 @@ export type TAppConnection =
| TMongoDBConnection
| TChefConnection
| TDNSMadeEasyConnection
- | TSshConnection;
+ | TSshConnection
+ | TDbtConnection;
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id" | "projectId">;
diff --git a/frontend/src/hooks/api/secretRotationsV2/enums.ts b/frontend/src/hooks/api/secretRotationsV2/enums.ts
index df26b40992..f2374e987e 100644
--- a/frontend/src/hooks/api/secretRotationsV2/enums.ts
+++ b/frontend/src/hooks/api/secretRotationsV2/enums.ts
@@ -11,7 +11,8 @@ export enum SecretRotation {
RedisCredentials = "redis-credentials",
MongoDBCredentials = "mongodb-credentials",
DatabricksServicePrincipalSecret = "databricks-service-principal-secret",
- UnixLinuxLocalAccount = "unix-linux-local-account"
+ UnixLinuxLocalAccount = "unix-linux-local-account",
+ DbtServiceToken = "dbt-service-token"
}
export enum SecretRotationStatus {
diff --git a/frontend/src/hooks/api/secretRotationsV2/types/dbt-service-token-rotation.ts b/frontend/src/hooks/api/secretRotationsV2/types/dbt-service-token-rotation.ts
new file mode 100644
index 0000000000..37b8c3dcbc
--- /dev/null
+++ b/frontend/src/hooks/api/secretRotationsV2/types/dbt-service-token-rotation.ts
@@ -0,0 +1,42 @@
+import { z } from "zod";
+
+import { DbtTokenPermissionsSchema } from "@app/components/secret-rotations-v2/forms/schemas/dbt-service-token-rotation-schema";
+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 TDbtTokenPermissionGrant = z.infer<typeof DbtTokenPermissionsSchema>;
+
+export type TDbtServiceTokenRotation = TSecretRotationV2Base & {
+ type: SecretRotation.DbtServiceToken;
+ parameters: {
+ permissionGrants: TDbtTokenPermissionGrant[];
+ };
+ secretsMapping: {
+ serviceToken: string;
+ };
+};
+
+export type TDbtServiceTokenRotationGeneratedCredentials = {
+ serviceToken: string;
+ tokenId: number;
+ tokenName: string;
+};
+
+export type TDbtServiceTokenRotationGeneratedCredentialsResponse =
+ TSecretRotationV2GeneratedCredentialsResponseBase<
+ SecretRotation.DbtServiceToken,
+ TDbtServiceTokenRotationGeneratedCredentials
+ >;
+
+export type TDbtServiceTokenRotationOption = {
+ name: string;
+ type: SecretRotation.DbtServiceToken;
+ connection: AppConnection.Dbt;
+ template: {
+ secretsMapping: TDbtServiceTokenRotation["secretsMapping"];
+ };
+};
diff --git a/frontend/src/hooks/api/secretRotationsV2/types/index.ts b/frontend/src/hooks/api/secretRotationsV2/types/index.ts
index 4b91324551..9c7d08ca36 100644
--- a/frontend/src/hooks/api/secretRotationsV2/types/index.ts
+++ b/frontend/src/hooks/api/secretRotationsV2/types/index.ts
@@ -36,6 +36,10 @@ import { TSqlCredentialsRotationOption } from "@app/hooks/api/secretRotationsV2/
import { SecretV3RawSanitized } from "@app/hooks/api/secrets/types";
import { DiscriminativePick } from "@app/types";
+import {
+ TDbtServiceTokenRotationGeneratedCredentialsResponse,
+ TDbtServiceTokenRotationOption
+} from "./dbt-service-token-rotation";
import {
TMongoDBCredentialsRotation,
TMongoDBCredentialsRotationGeneratedCredentialsResponse,
@@ -93,7 +97,8 @@ export type TSecretRotationV2Option =
| TRedisCredentialsRotationOption
| TMongoDBCredentialsRotationOption
| TDatabricksServicePrincipalSecretRotationOption
- | TUnixLinuxLocalAccountRotationOption;
+ | TUnixLinuxLocalAccountRotationOption
+ | TDbtServiceTokenRotationOption;
export type TListSecretRotationV2Options = { secretRotationOptions: TSecretRotationV2Option[] };
@@ -112,7 +117,8 @@ export type TViewSecretRotationGeneratedCredentialsResponse =
| TRedisCredentialsRotationGeneratedCredentialsResponse
| TMongoDBCredentialsRotationGeneratedCredentialsResponse
| TDatabricksServicePrincipalSecretRotationGeneratedCredentialsResponse
- | TUnixLinuxLocalAccountRotationGeneratedCredentialsResponse;
+ | TUnixLinuxLocalAccountRotationGeneratedCredentialsResponse
+ | TDbtServiceTokenRotationGeneratedCredentialsResponse;
export type TCreateSecretRotationV2DTO = DiscriminativePick<
TSecretRotationV2,
@@ -169,6 +175,7 @@ export type TSecretRotationOptionMap = {
[SecretRotation.MongoDBCredentials]: TMongoDBCredentialsRotationOption;
[SecretRotation.DatabricksServicePrincipalSecret]: TDatabricksServicePrincipalSecretRotationOption;
[SecretRotation.UnixLinuxLocalAccount]: TUnixLinuxLocalAccountRotationOption;
+ [SecretRotation.DbtServiceToken]: TDbtServiceTokenRotationOption;
};
export type TSecretRotationGeneratedCredentialsResponseMap = {
@@ -185,6 +192,7 @@ export type TSecretRotationGeneratedCredentialsResponseMap = {
[SecretRotation.MongoDBCredentials]: TMongoDBCredentialsRotationGeneratedCredentialsResponse;
[SecretRotation.DatabricksServicePrincipalSecret]: TDatabricksServicePrincipalSecretRotationGeneratedCredentialsResponse;
[SecretRotation.UnixLinuxLocalAccount]: TUnixLinuxLocalAccountRotationGeneratedCredentialsResponse;
+ [SecretRotation.DbtServiceToken]: TDbtServiceTokenRotationGeneratedCredentialsResponse;
};
export type TReconcileUnixLinuxLocalAccountRotationDTO = {
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
index 199858f47b..a0d332d193 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
@@ -23,6 +23,7 @@ import { ChecklyConnectionForm } from "./ChecklyConnectionForm";
import { ChefConnectionForm } from "./ChefConnectionForm";
import { CloudflareConnectionForm } from "./CloudflareConnectionForm";
import { DatabricksConnectionForm } from "./DatabricksConnectionForm";
+import { DbtConnectionForm } from "./DbtConnectionForm";
import { DigitalOceanConnectionForm } from "./DigitalOceanConnectionForm";
import { DNSMadeEasyConnectionForm } from "./DNSMadeEasyConnectionForm";
import { FlyioConnectionForm } from "./FlyioConnectionForm";
@@ -182,6 +183,8 @@ const CreateForm = ({ app, onComplete, projectId }: CreateFormProps) => {
return <OctopusDeployConnectionForm onSubmit={onSubmit} />;
case AppConnection.SSH:
return <SshConnectionForm onSubmit={onSubmit} />;
+ case AppConnection.Dbt:
+ return <DbtConnectionForm onSubmit={onSubmit} />;
default:
throw new Error(`Unhandled App ${app}`);
}
@@ -346,6 +349,8 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {
return <OctopusDeployConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
case AppConnection.SSH:
return <SshConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
+ case AppConnection.Dbt:
+ return <DbtConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
default:
throw new Error(`Unhandled App ${(appConnection as TAppConnection).app}`);
}
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/DbtConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/DbtConnectionForm.tsx
new file mode 100644
index 0000000000..137f011b1c
--- /dev/null
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/DbtConnectionForm.tsx
@@ -0,0 +1,180 @@
+import { Controller, FormProvider, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+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 { AppConnection } from "@app/hooks/api/appConnections/enums";
+import { DbtConnectionMethod, TDbtConnection } from "@app/hooks/api/appConnections/types";
+
+import {
+ genericAppConnectionFieldsSchema,
+ GenericAppConnectionsFields
+} from "./GenericAppConnectionFields";
+
+type Props = {
+ appConnection?: TDbtConnection;
+ onSubmit: (formData: FormData) => void;
+};
+
+const rootSchema = genericAppConnectionFieldsSchema.extend({
+ app: z.literal(AppConnection.Dbt)
+});
+
+const formSchema = z.discriminatedUnion("method", [
+ rootSchema.extend({
+ method: z.literal(DbtConnectionMethod.ApiToken),
+ credentials: z.object({
+ apiToken: z.string().trim().min(1, "API Token required"),
+ instanceUrl: z.string().trim().min(1, "Instance URL required"),
+ accountId: z.string().trim().min(1, "Account ID required")
+ })
+ })
+]);
+
+type FormData = z.infer<typeof formSchema>;
+
+export const DbtConnectionForm = ({ appConnection, onSubmit }: Props) => {
+ const isUpdate = Boolean(appConnection);
+
+ const form = useForm<FormData>({
+ resolver: zodResolver(formSchema),
+ defaultValues: appConnection ?? {
+ app: AppConnection.Dbt,
+ method: DbtConnectionMethod.ApiToken,
+ credentials: {
+ apiToken: "",
+ instanceUrl: "",
+ accountId: ""
+ }
+ }
+ });
+
+ const {
+ handleSubmit,
+ control,
+ formState: { isSubmitting, isDirty }
+ } = form;
+
+ return (
+ <FormProvider {...form}>
+ <form onSubmit={handleSubmit(onSubmit)}>
+ {!isUpdate && <GenericAppConnectionsFields />}
+
+ <Controller
+ name="credentials.instanceUrl"
+ control={control}
+ shouldUnregister
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="Instance URL"
+ >
+ <Input
+ value={value}
+ onChange={(e) => onChange(e.target.value)}
+ placeholder="https://bw255.us1.dbt.com"
+ />
+ </FormControl>
+ )}
+ />
+
+ <Controller
+ name="credentials.accountId"
+ control={control}
+ shouldUnregister
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="Account ID"
+ >
+ <Input
+ value={value}
+ onChange={(e) => onChange(e.target.value)}
+ placeholder="70471823527642"
+ />
+ </FormControl>
+ )}
+ />
+
+ <Controller
+ name="method"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ tooltipText={`The type of token you would like to use to connect with ${
+ APP_CONNECTION_MAP[AppConnection.Dbt].name
+ }. This field cannot be changed after creation.`}
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="Token Type"
+ >
+ <Select
+ isDisabled={isUpdate}
+ value={value}
+ onValueChange={(val) => onChange(val)}
+ className="w-full border border-mineshaft-500"
+ position="popper"
+ dropdownContainerClassName="max-w-none"
+ >
+ {Object.values(DbtConnectionMethod).map((method) => {
+ return (
+ <SelectItem value={method} key={method}>
+ {getAppConnectionMethodDetails(method).name}{" "}
+ </SelectItem>
+ );
+ })}
+ </Select>
+ </FormControl>
+ )}
+ />
+ <Controller
+ name="credentials.apiToken"
+ control={control}
+ shouldUnregister
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="API Token"
+ >
+ <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 DBT"}
+ </Button>
+ <ModalClose asChild>
+ <Button colorSchema="secondary" variant="plain">
+ Cancel
+ </Button>
+ </ModalClose>
+ </div>
+ </form>
+ </FormProvider>
+ );
+};