Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
requested changes
Daniel Hougaardd5f099b614ae
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.tsindex eabd49c2bb..3d81a6868f 100644--- 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@@ -11,8 +11,7 @@ import {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 { createDbtError, getDbtUrl } from "@app/services/app-connection/dbt";+import { createDbtError, getDbtUrl, retrieveDbtAccount } from "@app/services/app-connection/dbt";import {TCreateDbtServiceTokenResponse,@@ -27,7 +26,7 @@ export const dbtServiceTokenRotationFactory: TRotationFactory<> = (secretRotation) => {const {connection,- parameters: { permissionGrants },+ parameters: { permissionGrants, tokenName },secretsMapping} = secretRotation;@@ -41,7 +40,7 @@ export const dbtServiceTokenRotationFactory: TRotationFactory<const { data } = await request.post<TCreateDbtServiceTokenResponse>(`${instanceUrl}/api/v3/accounts/${connection.credentials.accountId}/service-tokens/`,{- name: `infisical-service-token-${alphaNumericNanoId(12)}`,+ name: tokenName,permission_grants: permissionGrants.map((grant) => ({permission_set: grant.permissionSet,project_id: grant.projectId@@ -55,13 +54,6 @@ export const dbtServiceTokenRotationFactory: TRotationFactory<});- 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,@@ -110,10 +102,6 @@ export const dbtServiceTokenRotationFactory: TRotationFactory<});- if (!data.status.is_success) {- throw new Error();- }-return data.data.id === tokenId;} catch (_) {return false;@@ -125,6 +113,13 @@ export const dbtServiceTokenRotationFactory: TRotationFactory<* First checks if the service token exists before attempting revocation.*/const revokeCredential = async (tokenId: number) => {+ await retrieveDbtAccount(connection).catch(() => {+ throw new BadRequestError({+ message:+ "Failed to validate connection credentials. Are you sure your configured DBT app connection credentials are valid?"+ });+ });+// Check if credential exists before attempting revocationconst exists = await tokenExists(tokenId);if (!exists) {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.tsindex 0ca3907e6c..f1e3f3c5aa 100644--- 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@@ -57,6 +57,7 @@ export const DbtServiceTokenRotationGeneratedCredentialsSchema = z.max(2);const DbtServiceTokenRotationParametersSchema = z.object({+ tokenName: z.string().trim().min(1).describe(SecretRotations.PARAMETERS.DBT_SERVICE_TOKEN.tokenName),permissionGrants: DbtTokenPermissionsSchema.array().min(1).describe(SecretRotations.PARAMETERS.DBT_SERVICE_TOKEN.permissionGrants)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.tsindex bf5666ebbc..69eafd118f 100644--- 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@@ -28,6 +28,7 @@ export type TDbtServiceTokenRotationGeneratedCredentials = z.infer<export interface TDbtServiceTokenRotationParameters {permissionGrants: DbtTokenPermissions[];+ tokenName: string;}export interface TDbtServiceTokenRotationSecretsMapping {diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 38c49e96e2..aa9b643c05 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -3026,7 +3026,8 @@ export const SecretRotations = {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."+ permissionGrants: "The permission grants to apply to the service token.",+ tokenName: "The name of the service token to create."},OPEN_ROUTER_API_KEY: {name: "The name for the generated OpenRouter API key.",diff --git a/backend/src/services/app-connection/dbt/dbt-connection-fns.ts b/backend/src/services/app-connection/dbt/dbt-connection-fns.tsindex 1eb296fac4..4ce9d3cbb0 100644--- a/backend/src/services/app-connection/dbt/dbt-connection-fns.ts+++ b/backend/src/services/app-connection/dbt/dbt-connection-fns.ts@@ -48,7 +48,7 @@ export const createDbtError = (error: AxiosError) => {}};-const retrieveDbtAccount = async (config: TDbtConnectionConfig) => {+export const retrieveDbtAccount = async (config: TDbtConnectionConfig) => {const { credentials } = config;const dbtUrl = await getDbtUrl(config);diff --git a/docs/documentation/platform/secret-rotation/dbt-service-token.mdx b/docs/documentation/platform/secret-rotation/dbt-service-token.mdxindex c4a0a57c32..2332ab482c 100644--- a/docs/documentation/platform/secret-rotation/dbt-service-token.mdx+++ b/docs/documentation/platform/secret-rotation/dbt-service-token.mdx@@ -32,7 +32,12 @@ description: "Learn how to automatically rotate DBT Service Tokens."Note that it's important that the DBT connection being used has permissions to create service tokens. Groups such as `Owner` or `Security Admin` are sufficient.</Note>- 4. Select the permission grants for the service token. Then click **Next**.+ 4. Select the parameters for the DBT service token rotation. Then click **Next**.+ - **Service Token Name**: The name of the service token to be created.+ - **Permission Grants**: The permission grants to apply to the service token.+ - **Permission Set**: The permission set to apply to the service token.+ - **Projects**: The projects to apply the permission set to. Select "All Projects" for the permission set to be applied to all projects.+@@ -80,10 +85,11 @@ description: "Learn how to automatically rotate DBT Service Tokens.""minutes": 0},"parameters": {+ "tokenName": "my-service-token","permissionGrants": [{"permissionSet": "account_admin",- "projectId": "<project-id>, <leave empty for all projects>"+ "projectId": "<project-id>" // leave empty for all projects}]},@@ -138,10 +144,11 @@ description: "Learn how to automatically rotate DBT Service Tokens.""lastRotationMessage": null,"type": "dbt-service-token","parameters": {+ "tokenName": "my-service-token","permissionGrants": [{"permissionSet": "account_admin",-projectId": "<project-id>" // empty for all projects+ "projectId": "<project-id>" // leave empty for all projects}]}diff --git a/docs/images/secret-rotations-v2/dbt-service-token/parameters.png b/docs/images/secret-rotations-v2/dbt-service-token/parameters.pngindex 4ea7a3fdcf..b950109dc0 100644Binary files a/docs/images/secret-rotations-v2/dbt-service-token/parameters.png and b/docs/images/secret-rotations-v2/dbt-service-token/parameters.png differdiff --git a/docs/snippets/RotationsBrowser.jsx b/docs/snippets/RotationsBrowser.jsxindex 1d1acd2446..5292f6c9d9 100644--- a/docs/snippets/RotationsBrowser.jsx+++ b/docs/snippets/RotationsBrowser.jsx@@ -4,7 +4,7 @@ export const RotationsBrowser = () => {const [searchTerm, setSearchTerm] = useState("");const [selectedCategory, setSelectedCategory] = useState("All");- const categories = ["All", "Databases", "Identity & Auth", "Cloud Providers", "Networking & DNS"];+ const categories = ["All", "Databases", "Identity & Auth", "Cloud Providers", "Networking & DNS", "Data Analytics"];const rotations = [{@@ -35,7 +35,7 @@ export const RotationsBrowser = () => {slug: "dbt-service-token",path: "/documentation/platform/secret-rotation/dbt-service-token",description: "Learn how to automatically rotate DBT service tokens.",- category: "Cloud Providers",+ category: "Data Analytics",},{name: "Auth0 Client Secret",diff --git a/frontend/src/components/secret-rotations-v2/SecretRotationV2Select.tsx b/frontend/src/components/secret-rotations-v2/SecretRotationV2Select.tsxindex 5679940fd1..50fc0dd51b 100644--- a/frontend/src/components/secret-rotations-v2/SecretRotationV2Select.tsx+++ b/frontend/src/components/secret-rotations-v2/SecretRotationV2Select.tsx@@ -1,7 +1,4 @@-import { faWrench } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";--import { Spinner, Tooltip } from "@app/components/v2";+import { Spinner } from "@app/components/v2";import { SECRET_ROTATION_MAP } from "@app/helpers/secretRotationsV2";import { SecretRotation, useSecretRotationV2Options } from "@app/hooks/api/secretRotationsV2";@@ -45,44 +42,6 @@ export const SecretRotationV2Select = ({ onSelect }: Props) => {</button>);})}- <Tooltip- side="bottom"- className="max-w-sm py-4"- content={- <>- <p className="mb-2">Infisical is constantly adding support for more services.</p>- <p>- {`If you don't see the third-party- service you're looking for,`}{" "}- <a- target="_blank"- className="underline hover:text-mineshaft-300"- href="https://infisical.com/slack"- rel="noopener noreferrer"- >- let us know on Slack- </a>{" "}- or{" "}- <a- target="_blank"- className="underline hover:text-mineshaft-300"- href="https://github.com/Infisical/infisical/discussions"- rel="noopener noreferrer"- >- make a request on GitHub- </a>- .- </p>- </>- }- >- <div className="group relative flex h-28 flex-col items-center justify-center rounded-md border border-dashed border-mineshaft-600 bg-mineshaft-800 p-4 hover:bg-mineshaft-900/50">- <FontAwesomeIcon className="mt-auto text-3xl" icon={faWrench} />- <div className="mt-auto max-w-xs text-center text-xs font-medium text-gray-300 duration-200 group-hover:text-gray-200">- Coming Soon- </div>- </div>- </Tooltip></div>);};diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/DbtServiceTokenRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/DbtServiceTokenRotationParametersFields.tsxindex 809551edbb..8896a400ca 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/DbtServiceTokenRotationParametersFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/DbtServiceTokenRotationParametersFields.tsx@@ -3,6 +3,7 @@ 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 { twMerge } from "tailwind-merge";import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";import {@@ -11,6 +12,7 @@ import {FormControl,FormLabel,IconButton,+ Input,Select,SelectItem} from "@app/components/v2";@@ -65,11 +67,30 @@ export const DbtServiceTokenRotationParametersFields = () => {return (<>+ <Controller+ control={control}+ name="parameters.tokenName"+ render={({ field, fieldState: { error } }) => (+ <FormControl+ tooltipText="Enter a name for the service token to be created. Note that each secret will have a suffix of '-1' or '-2' to differentiate between rotation cycles."+ isError={Boolean(error?.message)}+ errorText={error?.message}+ label="Service Token Name"+ >+ <Input {...field} placeholder="infisical-service-token" />+ </FormControl>+ )}+ /><FormLabel label="Permission Grants" />- <div className="mb-3 flex w-full flex-col space-y-2">+ <div+ className={twMerge(+ "mb-3 flex w-full flex-col space-y-2",+ permissionGrantsFields?.fields?.length >= 5 ? "max-h-72 overflow-y-auto" : ""+ )}+ >{permissionGrantsFields.fields.map(({ id: roleFieldId }, i) => (<div key={roleFieldId} className="flex items-end space-x-2">- <div className="w-72">+ <div className="w-80">{i === 0 && <span className="text-xs text-mineshaft-400">Permission set</span>}<Controllercontrol={control}@@ -80,7 +101,13 @@ export const DbtServiceTokenRotationParametersFields = () => {errorText={error?.message}className="mb-0">- <Select className="w-72" value={field.value} onValueChange={field.onChange}>+ <Select+ className="w-80"+ position="popper"+ dropdownContainerClassName="max-h-72"+ value={field.value}+ onValueChange={field.onChange}+ >{Object.entries(DBT_PERMISSION_SET_MAP).map(([permissionSet, { label, isEnterpriseOnly }]) => (<SelectItem key={permissionSet} value={permissionSet}>@@ -125,6 +152,7 @@ export const DbtServiceTokenRotationParametersFields = () => {)}/></div>+<IconButtonariaLabel="delete key"className="bottom-0.5 h-9"diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/DbtServiceTokenRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/DbtServiceTokenRotationReviewFields.tsxindex 2c03490b12..0d3bbcd7bb 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/DbtServiceTokenRotationReviewFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/DbtServiceTokenRotationReviewFields.tsx@@ -20,16 +20,18 @@ export const DbtServiceTokenRotationReviewFields = () => {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].label}</span>- <Badge variant={grant.projectId ? "neutral" : "info"}>- {grant.projectId ? `Project: ${grant.projectId}` : "All Projects"}- </Badge>- </div>- </GenericFieldLabel>- ))}+ <div className="grid grid-cols-2 gap-2">+ {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].label}</span>+ <Badge variant={grant.projectId ? "neutral" : "info"}>+ {grant.projectId ? `Project: ${grant.projectId}` : "All Projects"}+ </Badge>+ </div>+ </GenericFieldLabel>+ ))}+ </div></SecretRotationReviewSection><SecretRotationReviewSection label="Secrets Mapping"><GenericFieldLabel label="Service Token">{serviceToken}</GenericFieldLabel>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.tsindex 7c8ce74798..91130c2ca8 100644--- 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@@ -172,7 +172,8 @@ export const DbtServiceTokenRotationSchema = z.object({type: z.literal(SecretRotation.DbtServiceToken),parameters: z.object({- permissionGrants: DbtTokenPermissionsSchema.array()+ permissionGrants: DbtTokenPermissionsSchema.array(),+ tokenName: z.string().trim().min(1, "Token name required")}),secretsMapping: z.object({serviceToken: z.string().trim().min(1, "Service Token required")