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
feat: add SMB connection support for Windows local account rotation and update related schemas
Victor Santos6ed7a46c0075
diff --git a/Dockerfile.fips.standalone-infisical b/Dockerfile.fips.standalone-infisicalindex ba845e4767..7b43f9a640 100644--- a/Dockerfile.fips.standalone-infisical+++ b/Dockerfile.fips.standalone-infisical@@ -183,6 +183,9 @@ RUN wget https://www.openssl.org/source/openssl-3.1.2.tar.gz \&& apt-get clean \&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*+# Install smbclient for Windows SMB operations+RUN apt-get update && apt-get install -y smbclient && rm -rf /var/lib/apt/lists/*+# Install Infisical CLIRUN curl -1sLf 'https://artifacts-cli.infisical.com/setup.deb.sh' | bash \&& apt-get update && apt-get install -y infisical=0.43.47 \diff --git a/Dockerfile.standalone-infisical b/Dockerfile.standalone-infisicalindex d8ae16fcbe..c44086c1f6 100644--- a/Dockerfile.standalone-infisical+++ b/Dockerfile.standalone-infisical@@ -168,6 +168,9 @@ RUN ARCH=$(dpkg --print-architecture) && \ldconfig && \rm -rf /var/lib/apt/lists/*+# Install smbclient for Windows SMB operations+RUN apt-get update && apt-get install -y smbclient && rm -rf /var/lib/apt/lists/*+# Install Infisical CLIRUN curl -1sLf 'https://artifacts-cli.infisical.com/setup.deb.sh' | bash \&& apt-get update && apt-get install -y infisical=0.43.47 \diff --git a/backend/Dockerfile b/backend/Dockerfileindex 8fd55d4a9b..ba37d2540a 100644--- a/backend/Dockerfile+++ b/backend/Dockerfile@@ -79,6 +79,9 @@ RUN npm ci --only-production && npm cache clean --forceCOPY --from=build /app .+# Install smbclient for Windows SMB operations+RUN apt-get update && apt-get install -y smbclient+# Install Infisical CLIRUN apt-get update && apt-get install -y curl bash && \curl -1sLf 'https://artifacts-cli.infisical.com/setup.deb.sh' | bash && \diff --git a/backend/Dockerfile.dev b/backend/Dockerfile.devindex 15fba0924f..e9c22ede58 100644--- a/backend/Dockerfile.dev+++ b/backend/Dockerfile.dev@@ -78,6 +78,9 @@ RUN mkdir -p /opt/oracle && \# ? App setup+# Install smbclient for Windows SMB operations+RUN apt-get update && apt-get install -y smbclient+# Install Infisical CLIRUN curl -1sLf 'https://artifacts-cli.infisical.com/setup.deb.sh' | bash && \apt-get update && \diff --git a/backend/Dockerfile.dev.fips b/backend/Dockerfile.dev.fipsindex 88f2c2adab..b234587aa9 100644--- a/backend/Dockerfile.dev.fips+++ b/backend/Dockerfile.dev.fips@@ -90,6 +90,9 @@ RUN wget https://www.openssl.org/source/openssl-3.1.2.tar.gz \# ? App setup+# Install smbclient for Windows SMB operations+RUN apt-get update && apt-get install -y smbclient+# Install Infisical CLIRUN curl -1sLf 'https://artifacts-cli.infisical.com/setup.deb.sh' | bash && \apt-get update && \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.tsindex 526e8c1451..5a4aaf906b 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@@ -15,6 +15,7 @@ import { PostgresCredentialsRotationListItemSchema } from "@app/ee/services/secrimport { RedisCredentialsRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/redis-credentials";import { SecretRotationV2Schema } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema";import { UnixLinuxLocalAccountRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/unix-linux-local-account-rotation";+import { WindowsLocalAccountRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/windows-local-account-rotation";import { ApiDocsTags, SecretRotations } from "@app/lib/api-docs";import { readLimit } from "@app/server/config/rateLimiter";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";@@ -33,7 +34,8 @@ const SecretRotationV2OptionsSchema = z.discriminatedUnion("type", [RedisCredentialsRotationListItemSchema,MongoDBCredentialsRotationListItemSchema,DatabricksServicePrincipalSecretRotationListItemSchema,- UnixLinuxLocalAccountRotationListItemSchema+ UnixLinuxLocalAccountRotationListItemSchema,+ WindowsLocalAccountRotationListItemSchema]);export const registerSecretRotationV2Router = async (server: FastifyZodProvider) => {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.tsindex e19983e264..0fc2d3ea76 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@@ -32,5 +32,5 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio[SecretRotation.MongoDBCredentials]: AppConnection.MongoDB,[SecretRotation.DatabricksServicePrincipalSecret]: AppConnection.Databricks,[SecretRotation.UnixLinuxLocalAccount]: AppConnection.SSH,- [SecretRotation.WindowsLocalAccount]: AppConnection.SSH+ [SecretRotation.WindowsLocalAccount]: AppConnection.SMB};diff --git a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-constants.ts b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-constants.tsindex 89bc21753b..00990f9bb4 100644--- a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-constants.ts+++ b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-constants.ts@@ -6,7 +6,7 @@ import { TWindowsLocalAccountRotationListItem } from "./windows-local-account-roexport const WINDOWS_LOCAL_ACCOUNT_ROTATION_LIST_OPTION: TWindowsLocalAccountRotationListItem = {name: "Windows Local Account",type: SecretRotation.WindowsLocalAccount,- connection: AppConnection.SSH,+ connection: AppConnection.SMB,template: {secretsMapping: {username: "WINDOWS_USERNAME",diff --git a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-fns.tsindex bb48f6119d..ed0da87fc4 100644--- a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-fns.ts+++ b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-fns.ts@@ -1,5 +1,3 @@-import { Client } from "ssh2";-import {TRotationFactory,TRotationFactoryGetSecretsPayload,@@ -8,13 +6,12 @@ import {TRotationFactoryRotateCredentials} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-types";import { BadRequestError } from "@app/lib/errors";-import { logger } from "@app/lib/logger";+import { changeWindowsPassword, SmbRpcConfig, verifyWindowsCredentials } from "@app/lib/smb-rpc";import {- executeWithPotentialGateway,- getSshConnectionClient,- SshConnectionMethod,- TSshConnectionConfig-} from "@app/services/app-connection/ssh";+ executeSmbWithPotentialGateway,+ SmbConnectionMethod,+ TSmbConnectionConfig+} from "@app/services/app-connection/smb";import { generatePassword } from "../shared/utils";import { WindowsLocalAccountRotationMethod } from "./windows-local-account-rotation-schemas";@@ -24,159 +21,91 @@ import {TWindowsLocalAccountRotationWithConnection} from "./windows-local-account-rotation-types";-// Execute command over SSH and return stdout-const executeCommand = (client: Client, command: string): Promise<string> => {- return new Promise((resolve, reject) => {- client.exec(command, (err, stream) => {- if (err) {- reject(new Error(`SSH exec error: ${err.message}`));- return;- }-- let stdout = "";- let stderr = "";-- stream.on("close", (code: number) => {- if (code !== 0) {- reject(new Error(`Command failed with exit code ${code}: ${stderr || "Unknown error"}`));- } else {- resolve(stdout);- }- });-- stream.on("data", (data: Buffer) => {- stdout += data.toString();- });-- stream.stderr.on("data", (data: Buffer) => {- stderr += data.toString();- });- });- });-};--// Change password for managed rotation (admin changing another user's password)-const changeManagedPassword = async (client: Client, username: string, newPassword: string): Promise<void> => {- // Using base64 encoding to avoid any shell escaping issues- const encodedPassword = Buffer.from(newPassword).toString("base64");- const encodedUsername = Buffer.from(username).toString("base64");- const command = `powershell -Command "$u = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${encodedUsername}')); $p = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${encodedPassword}')); net user $u $p"`;-- try {- await executeCommand(client, command);- } catch (error) {- logger.error(error, "Windows Local Account Rotation: Failed to change password (managed)");- throw new Error(`Failed to change password: ${(error as Error).message}`);- }-};--// Change password for self rotation (user changing their own password)-// Windows net user command works the same for self-rotation on local accounts-const changeSelfPassword = async (client: Client, username: string, newPassword: string): Promise<void> => {- // Using base64 encoding to avoid any shell escaping issues- const encodedPassword = Buffer.from(newPassword).toString("base64");- const encodedUsername = Buffer.from(username).toString("base64");- const command = `powershell -Command "$u = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${encodedUsername}')); $p = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${encodedPassword}')); net user $u $p"`;-- try {- await executeCommand(client, command);- } catch (error) {- logger.error(error, "Windows Local Account Rotation: Failed to change password (self)");- throw new Error(`Failed to change password: ${(error as Error).message}`);- }-};-export const windowsLocalAccountRotationFactory: TRotationFactory<TWindowsLocalAccountRotationWithConnection,TWindowsLocalAccountRotationGeneratedCredentials,TWindowsLocalAccountRotationInput["temporaryParameters"]-> = (secretRotation, appConnectionDAL, kmsService, _gatewayService, gatewayV2Service) => {+> = (secretRotation, _appConnectionDAL, _kmsService, _gatewayService, gatewayV2Service) => {const { connection, parameters, secretsMapping, activeIndex } = secretRotation;const { username, passwordRequirements, rotationMethod = WindowsLocalAccountRotationMethod.LoginAsRoot } = parameters;- // Helper to verify SSH credentials work+ // Helper to verify Windows credentials work via SMBconst $verifyCredentials = async (targetUsername: string, targetPassword: string): Promise<void> => {- const verifyConfig: TSshConnectionConfig = {- method: SshConnectionMethod.Password,+ const { credentials } = connection;+ const credentialsDomain: string | undefined = credentials.domain;++ const verifyConfig: TSmbConnectionConfig = {+ method: SmbConnectionMethod.Credentials,app: connection.app,orgId: connection.orgId,gatewayId: connection.gatewayId,credentials: {- host: connection.credentials.host,- port: connection.credentials.port,+ host: credentials.host,+ port: credentials.port,+ domain: credentialsDomain,username: targetUsername,password: targetPassword}};- try {- await executeWithPotentialGateway(verifyConfig, gatewayV2Service, async (targetHost, targetPort) => {- const client = await getSshConnectionClient(verifyConfig, targetHost, targetPort);- client.destroy();- });- } catch (error) {- throw new Error(`Failed to verify credentials - ${(error as Error).message}`);- }+ await executeSmbWithPotentialGateway(verifyConfig, gatewayV2Service, async (targetHost, targetPort) => {+ await verifyWindowsCredentials(targetHost, targetPort, targetUsername, targetPassword, credentialsDomain);+ });};// Main password rotation logicconst $rotatePassword = async (currentPassword?: string): Promise<{ username: string; password: string }> => {const { credentials } = connection;+ const credentialsDomain: string | undefined = credentials.domain;+ const credentialsPassword: string = credentials.password;const newPassword = generatePassword(passwordRequirements);const isSelfRotation = rotationMethod === WindowsLocalAccountRotationMethod.LoginAsTarget;if (username === credentials.username)throw new BadRequestError({ message: "Provided username is used in Infisical app connections." });- const privilegedAccounts = ["administrator", "admin"];- if (privilegedAccounts.includes(username.toLowerCase()))- throw new BadRequestError({ message: "Cannot rotate passwords for privileged system accounts." });-- // Determine which credentials to use for the SSH connection- let connectConfig: TSshConnectionConfig;+ const smbConfig: SmbRpcConfig = {+ host: credentials.host,+ port: credentials.port,+ adminUser: credentials.username,+ adminPassword: credentialsPassword,+ domain: credentialsDomain+ };if (isSelfRotation && currentPassword) {- // For self-rotation with current password, connect as the target user- connectConfig = {- method: SshConnectionMethod.Password,- app: connection.app,- orgId: connection.orgId,- gatewayId: connection.gatewayId,- credentials: {- host: credentials.host,- port: credentials.port,- username,- password: currentPassword- }- };- } else {- // For managed rotation, connect with the app connection credentials (admin)- connectConfig = {- method: connection.method,- app: connection.app,- orgId: connection.orgId,- gatewayId: connection.gatewayId,- credentials: connection.credentials- } as TSshConnectionConfig;+ smbConfig.adminUser = username;+ smbConfig.adminPassword = currentPassword;}- await executeWithPotentialGateway(connectConfig, gatewayV2Service, async (targetHost, targetPort) => {- const client = await getSshConnectionClient(connectConfig, targetHost, targetPort);-- try {- if (isSelfRotation && currentPassword) {- // Self rotation: user changes their own password using net user command- await changeSelfPassword(client, username, newPassword);- } else {- // Managed rotation: admin changes user's password using net user command- await changeManagedPassword(client, username, newPassword);- }- } finally {- client.destroy();+ // Determine which credentials to use for the SMB connection+ const connectConfig: TSmbConnectionConfig = {+ method: connection.method,+ app: connection.app,+ orgId: connection.orgId,+ gatewayId: connection.gatewayId,+ credentials: {+ host: credentials.host,+ port: credentials.port,+ domain: credentialsDomain,+ username: credentials.username,+ password: credentialsPassword}+ };++ if (isSelfRotation && currentPassword) {+ connectConfig.credentials.username = username;+ connectConfig.credentials.password = currentPassword;+ }+ await executeSmbWithPotentialGateway(connectConfig, gatewayV2Service, async (targetHost, targetPort) => {+ const configWithProxiedHost: SmbRpcConfig = {+ ...smbConfig,+ host: targetHost,+ port: targetPort+ };++ await changeWindowsPassword(configWithProxiedHost, username, newPassword);});- // Verify the new credentials workawait $verifyCredentials(username, newPassword);return { username, password: newPassword };@@ -186,8 +115,8 @@ export const windowsLocalAccountRotationFactory: TRotationFactory<TWindowsLocalAccountRotationGeneratedCredentials,TWindowsLocalAccountRotationInput["temporaryParameters"]> = async (callback, temporaryParameters) => {- const credentials = await $rotatePassword(temporaryParameters?.password);- return callback(credentials);+ const newCredentials = await $rotatePassword(temporaryParameters?.password);+ return callback(newCredentials);};const revokeCredentials: TRotationFactoryRevokeCredentials<TWindowsLocalAccountRotationGeneratedCredentials> = async (@@ -210,8 +139,8 @@ export const windowsLocalAccountRotationFactory: TRotationFactory<// For both methods, pass the current password// Self rotation: needed to authenticate as the user// Managed rotation: admin doesn't need it but it's harmless to pass- const credentials = await $rotatePassword(activeCredentials.password);- return callback(credentials);+ const newCredentials = await $rotatePassword(activeCredentials.password);+ return callback(newCredentials);};const getSecretsPayload: TRotationFactoryGetSecretsPayload<TWindowsLocalAccountRotationGeneratedCredentials> = (diff --git a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-schemas.tsindex bac7d5b5cd..49875b710d 100644--- a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-schemas.ts+++ b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-schemas.ts@@ -95,7 +95,7 @@ export const UpdateWindowsLocalAccountRotationSchema = BaseUpdateSecretRotationSexport const WindowsLocalAccountRotationListItemSchema = z.object({name: z.literal("Windows Local Account"),- connection: z.literal(AppConnection.SSH),+ connection: z.literal(AppConnection.SMB),type: z.literal(SecretRotation.WindowsLocalAccount),template: WindowsLocalAccountRotationTemplateSchema});diff --git a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-types.ts b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-types.tsindex c1ff93e629..67278e8eb4 100644--- a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-types.ts+++ b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-types.ts@@ -1,6 +1,6 @@import { z } from "zod";-import { TSshConnection } from "@app/services/app-connection/ssh";+import { TSmbConnection } from "@app/services/app-connection/smb";import {CreateWindowsLocalAccountRotationSchema,@@ -16,7 +16,7 @@ export type TWindowsLocalAccountRotationInput = z.infer<typeof CreateWindowsLocaexport type TWindowsLocalAccountRotationListItem = z.infer<typeof WindowsLocalAccountRotationListItemSchema>;export type TWindowsLocalAccountRotationWithConnection = TWindowsLocalAccountRotation & {- connection: TSshConnection;+ connection: TSmbConnection;};export type TWindowsLocalAccountRotationGeneratedCredentials = z.infer<diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 9037474543..bb3563800b 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -2568,6 +2568,13 @@ 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)."+ },+ SMB: {+ host: "The hostname or IP address of the Windows server.",+ port: "The SMB port (defaults to 445).",+ domain: "The Windows domain name (optional).",+ username: "The username for SMB authentication.",+ password: "The password for SMB authentication."}}};diff --git a/backend/src/lib/smb-rpc/index.ts b/backend/src/lib/smb-rpc/index.tsnew file mode 100644index 0000000000..213ad81f71--- /dev/null+++ b/backend/src/lib/smb-rpc/index.ts@@ -0,0 +1 @@+export { changeWindowsPassword, SmbRpcConfig, verifyWindowsCredentials } from "./smb-rpc-client";diff --git a/backend/src/lib/smb-rpc/smb-rpc-client.ts b/backend/src/lib/smb-rpc/smb-rpc-client.tsnew file mode 100644index 0000000000..f2f41f50a3--- /dev/null+++ b/backend/src/lib/smb-rpc/smb-rpc-client.ts@@ -0,0 +1,172 @@+import { spawn } from "child_process";++export interface SmbRpcConfig {+ host: string;+ port: number;+ adminUser: string;+ adminPassword: string;+ domain?: string;+}++const SMB3_SECURITY_OPTIONS = ["--option=client min protocol=SMB3", "--option=client smb encrypt=required"];++/**+ * Build the target string (//host:port)+ */+const buildTarget = (config: SmbRpcConfig): string => {+ return `//${config.host}:${config.port}`;+};++/**+ * Helper to build common auth args for SMB commands+ */+const buildAuthArgs = (config: SmbRpcConfig): string[] => {+ const userCredential = config.domain+ ? `${config.domain}\\${config.adminUser}%${config.adminPassword}`+ : `${config.adminUser}%${config.adminPassword}`;++ return ["-U", userCredential, ...SMB3_SECURITY_OPTIONS];+};++/**+ * Execute a command and return stdout/stderr+ */+const executeCommand = (+ command: string,+ args: string[]+): Promise<{ stdout: string; stderr: string; exitCode: number }> => {+ return new Promise((resolve) => {+ const proc = spawn(command, args, {+ stdio: ["pipe", "pipe", "pipe"]+ });++ let stdout = "";+ let stderr = "";++ proc.stdout.on("data", (data: Buffer) => {+ stdout += data.toString();+ });++ proc.stderr.on("data", (data: Buffer) => {+ stderr += data.toString();+ });++ proc.on("close", (code) => {+ resolve({ stdout, stderr, exitCode: code ?? 0 });+ });++ proc.on("error", (err) => {+ stderr += err.message;+ resolve({ stdout, stderr, exitCode: 1 });+ });+ });+};++/**+ * Parse NT_STATUS errors from command output+ */+const parseNtStatusError = (output: string): string | null => {+ const match = output.match(/NT_STATUS_[A-Z_]+/);+ return match ? match[0] : null;+};++/**+ * Get human-readable error message for NT_STATUS codes+ */+const getNtStatusMessage = (ntStatus: string): string => {+ const messages: Record<string, string> = {+ NT_STATUS_LOGON_FAILURE: "Authentication failed - check username and password",+ NT_STATUS_ACCESS_DENIED: "Access denied - user lacks required permissions",+ NT_STATUS_ACCOUNT_LOCKED_OUT: "Account is locked out",+ NT_STATUS_ACCOUNT_DISABLED: "Account is disabled",+ NT_STATUS_PASSWORD_EXPIRED: "Password has expired",+ NT_STATUS_PASSWORD_MUST_CHANGE: "Password must be changed before login",+ NT_STATUS_NO_SUCH_USER: "User does not exist",+ NT_STATUS_INVALID_PARAMETER: "Invalid parameter provided",+ NT_STATUS_CONNECTION_REFUSED: "Connection refused - check if SMB is enabled on target",+ NT_STATUS_HOST_UNREACHABLE: "Host unreachable",+ NT_STATUS_IO_TIMEOUT: "Connection timed out",+ NT_STATUS_PASSWORD_RESTRICTION:+ "Password rejected by Windows policy - ensure Infisical password requirements meet or exceed Windows password policy",+ NT_STATUS_WRONG_PASSWORD: "Incorrect password"+ };++ return messages[ntStatus] || `SMB error: ${ntStatus}`;+};++/**+ * Test SMB connection to a Windows host+ * Uses smbclient to list shares and verify connectivity+ */+const testSmbConnection = async (config: SmbRpcConfig): Promise<void> => {+ const args = ["-L", buildTarget(config), ...buildAuthArgs(config)];++ const { stdout, stderr, exitCode } = await executeCommand("smbclient", args);+ const combinedOutput = stdout + stderr;++ const ntStatus = parseNtStatusError(combinedOutput);+ if (ntStatus) {+ throw new Error(getNtStatusMessage(ntStatus));+ }++ if (exitCode !== 0) {+ throw new Error(`SMB connection failed: ${combinedOutput || "Unknown error"}`);+ }+};++/**+ * Escape password for rpcclient's internal command parser+ * The password is wrapped in single quotes, with internal single quotes escaped+ */+const escapePasswordForRpc = (password: string): string => {+ return password.replace(/'/g, "'\\''");+};++/**+ * Change a Windows local account password using rpcclient+ * Uses setuserinfo2 command with level 23 (password reset)+ */+export const changeWindowsPassword = async (+ config: SmbRpcConfig,+ targetUser: string,+ newPassword: string+): Promise<void> => {+ const escapedPassword = escapePasswordForRpc(newPassword);+ const rpcCommand = `setuserinfo2 ${targetUser} 23 '${escapedPassword}'`;++ const args = [buildTarget(config), ...buildAuthArgs(config), "-c", rpcCommand];++ const { stdout, stderr, exitCode } = await executeCommand("rpcclient", args);+ const combinedOutput = stdout + stderr;++ const ntStatus = parseNtStatusError(combinedOutput);+ if (ntStatus) {+ throw new Error(getNtStatusMessage(ntStatus));+ }++ if (exitCode !== 0) {+ throw new Error(`Password change failed: ${combinedOutput || "Unknown error"}`);+ }+};++/**+ * Verify Windows credentials by attempting to list shares+ * This is used to verify that a password change was successful+ */+export const verifyWindowsCredentials = async (+ host: string,+ port: number,+ username: string,+ password: string,+ domain?: string+): Promise<void> => {+ const config: SmbRpcConfig = {+ host,+ port,+ adminUser: username,+ adminPassword: password,+ domain+ };++ await testSmbConnection(config);+};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.tsindex e65dc88946..64abaf4ab7 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@@ -119,6 +119,7 @@ import {RenderConnectionListItemSchema,SanitizedRenderConnectionSchema} from "@app/services/app-connection/render/render-connection-schema";+import { SanitizedSmbConnectionSchema, SmbConnectionListItemSchema } from "@app/services/app-connection/smb";import { SanitizedSshConnectionSchema, SshConnectionListItemSchema } from "@app/services/app-connection/ssh";import {SanitizedSupabaseConnectionSchema,@@ -187,6 +188,7 @@ const SanitizedAppConnectionSchema = z.union([...SanitizedChefConnectionSchema.options,...SanitizedDNSMadeEasyConnectionSchema.options,...SanitizedOctopusDeployConnectionSchema.options,+ ...SanitizedSmbConnectionSchema.options,...SanitizedSshConnectionSchema.options]);@@ -236,6 +238,7 @@ const AppConnectionOptionsSchema = z.discriminatedUnion("app", [ChefConnectionListItemSchema,DNSMadeEasyConnectionListItemSchema,OctopusDeployConnectionListItemSchema,+ SmbConnectionListItemSchema,SshConnectionListItemSchema]);diff --git a/backend/src/server/routes/v1/app-connection-routers/index.ts b/backend/src/server/routes/v1/app-connection-routers/index.tsindex 6a1ad4ad97..4fd46b2777 100644--- a/backend/src/server/routes/v1/app-connection-routers/index.ts+++ b/backend/src/server/routes/v1/app-connection-routers/index.ts@@ -39,6 +39,7 @@ import { registerPostgresConnectionRouter } from "./postgres-connection-router";import { registerRailwayConnectionRouter } from "./railway-connection-router";import { registerRedisConnectionRouter } from "./redis-connection-router";import { registerRenderConnectionRouter } from "./render-connection-router";+import { registerSmbConnectionRouter } from "./smb-connection-router";import { registerSshConnectionRouter } from "./ssh-connection-router";import { registerSupabaseConnectionRouter } from "./supabase-connection-router";import { registerTeamCityConnectionRouter } from "./teamcity-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.SMB]: registerSmbConnectionRouter};diff --git a/backend/src/server/routes/v1/app-connection-routers/smb-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/smb-connection-router.tsnew file mode 100644index 0000000000..fa657a8def--- /dev/null+++ b/backend/src/server/routes/v1/app-connection-routers/smb-connection-router.ts@@ -0,0 +1,18 @@+import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import {+ CreateSmbConnectionSchema,+ SanitizedSmbConnectionSchema,+ UpdateSmbConnectionSchema+} from "@app/services/app-connection/smb";++import { registerAppConnectionEndpoints } from "./app-connection-endpoints";++export const registerSmbConnectionRouter = async (server: FastifyZodProvider) => {+ registerAppConnectionEndpoints({+ app: AppConnection.SMB,+ server,+ sanitizedResponseSchema: SanitizedSmbConnectionSchema,+ createSchema: CreateSmbConnectionSchema,+ updateSchema: UpdateSmbConnectionSchema+ });+};diff --git a/backend/src/services/app-connection/app-connection-enums.ts b/backend/src/services/app-connection/app-connection-enums.tsindex 3474914220..ab4e6b01a7 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",+ SMB = "smb"}export enum AWSRegion {diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.tsindex 2b9ce06e75..cf2d9a9dff 100644--- a/backend/src/services/app-connection/app-connection-fns.ts+++ b/backend/src/services/app-connection/app-connection-fns.ts@@ -140,6 +140,7 @@ import { getRailwayConnectionListItem, validateRailwayConnectionCredentials } frimport { getRedisConnectionListItem, RedisConnectionMethod, validateRedisConnectionCredentials } from "./redis";import { RenderConnectionMethod } from "./render/render-connection-enums";import { getRenderConnectionListItem, validateRenderConnectionCredentials } from "./render/render-connection-fns";+import { getSmbConnectionListItem, SmbConnectionMethod, validateSmbConnectionCredentials } from "./smb";import { getSshConnectionListItem, SshConnectionMethod, validateSshConnectionCredentials } from "./ssh";import {getSupabaseConnectionListItem,@@ -234,7 +235,8 @@ export const listAppConnectionOptions = (projectType?: ProjectType) => {getRedisConnectionListItem(),getMongoDBConnectionListItem(),getChefConnectionListItem(),- getSshConnectionListItem()+ getSshConnectionListItem(),+ getSmbConnectionListItem()].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.SMB]: validateSmbConnectionCredentials as TAppConnectionCredentialsValidator};return VALIDATE_APP_CONNECTION_CREDENTIALS_MAP[appConnection.app](appConnection, gatewayService, gatewayV2Service);@@ -442,6 +445,8 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>return "Password";case SshConnectionMethod.SshKey:return "SSH Key";+ case SmbConnectionMethod.Credentials:+ return "Credentials";case RenderConnectionMethod.ApiKey:case ChecklyConnectionMethod.ApiKey:case OctopusDeployConnectionMethod.ApiKey:@@ -527,7 +532,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.SMB]: platformManagedCredentialsNotSupported};export const enterpriseAppCheck = async (diff --git a/backend/src/services/app-connection/app-connection-maps.ts b/backend/src/services/app-connection/app-connection-maps.tsindex 3e8f006f66..9c0db67e75 100644--- a/backend/src/services/app-connection/app-connection-maps.ts+++ b/backend/src/services/app-connection/app-connection-maps.ts@@ -46,7 +46,8 @@ export const APP_CONNECTION_NAME_MAP: Record<AppConnection, string> = {[AppConnection.Chef]: "Chef",[AppConnection.Northflank]: "Northflank",[AppConnection.OctopusDeploy]: "Octopus Deploy",- [AppConnection.SSH]: "SSH"+ [AppConnection.SSH]: "SSH",+ [AppConnection.SMB]: "SMB"};export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanType> = {@@ -95,5 +96,6 @@ export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanTyp[AppConnection.Chef]: AppConnectionPlanType.Enterprise,[AppConnection.Northflank]: AppConnectionPlanType.Regular,[AppConnection.OctopusDeploy]: AppConnectionPlanType.Regular,- [AppConnection.SSH]: AppConnectionPlanType.Regular+ [AppConnection.SSH]: AppConnectionPlanType.Regular,+ [AppConnection.SMB]: AppConnectionPlanType.Regular};diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.tsindex 99b0bef3ae..f2a9eca55a 100644--- a/backend/src/services/app-connection/app-connection-service.ts+++ b/backend/src/services/app-connection/app-connection-service.ts@@ -113,6 +113,7 @@ import { railwayConnectionService } from "./railway/railway-connection-service";import { ValidateRedisConnectionCredentialsSchema } from "./redis";import { ValidateRenderConnectionCredentialsSchema } from "./render/render-connection-schema";import { renderConnectionService } from "./render/render-connection-service";+import { ValidateSmbConnectionCredentialsSchema } from "./smb";import { ValidateSshConnectionCredentialsSchema } from "./ssh";import { ValidateSupabaseConnectionCredentialsSchema } from "./supabase";import { supabaseConnectionService } from "./supabase/supabase-connection-service";@@ -187,7 +188,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.SMB]: ValidateSmbConnectionCredentialsSchema};export const appConnectionServiceFactory = ({diff --git a/backend/src/services/app-connection/app-connection-types.ts b/backend/src/services/app-connection/app-connection-types.tsindex d40975d36b..fc58284a34 100644--- a/backend/src/services/app-connection/app-connection-types.ts+++ b/backend/src/services/app-connection/app-connection-types.ts@@ -227,6 +227,12 @@ import {TRenderConnectionInput,TValidateRenderConnectionCredentialsSchema} from "./render/render-connection-types";+import {+ TSmbConnection,+ TSmbConnectionConfig,+ TSmbConnectionInput,+ TValidateSmbConnectionCredentialsSchema+} from "./smb";import {TSshConnection,TSshConnectionConfig,@@ -317,6 +323,7 @@ export type TAppConnection = { id: string } & (| TChefConnection| TOctopusDeployConnection| TSshConnection+ | TSmbConnection);export type TAppConnectionRaw = NonNullable<Awaited<ReturnType<TAppConnectionDALFactory["findById"]>>>;@@ -370,6 +377,7 @@ export type TAppConnectionInput = { id: string } & (| TChefConnectionInput| TOctopusDeployConnectionInput| TSshConnectionInput+ | TSmbConnectionInput);export type TSqlConnectionInput =@@ -440,7 +448,8 @@ export type TAppConnectionConfig =| TMongoDBConnectionConfig| TChefConnectionConfig| TOctopusDeployConnectionConfig- | TSshConnectionConfig;+ | TSshConnectionConfig+ | TSmbConnectionConfig;export type TValidateAppConnectionCredentialsSchema =| TValidateAwsConnectionCredentialsSchema@@ -488,7 +497,8 @@ export type TValidateAppConnectionCredentialsSchema =| TValidateMongoDBConnectionCredentialsSchema| TValidateChefConnectionCredentialsSchema| TValidateOctopusDeployConnectionCredentialsSchema- | TValidateSshConnectionCredentialsSchema;+ | TValidateSshConnectionCredentialsSchema+ | TValidateSmbConnectionCredentialsSchema;export type TListAwsConnectionKmsKeys = {connectionId: string;diff --git a/backend/src/services/app-connection/smb/index.ts b/backend/src/services/app-connection/smb/index.tsnew file mode 100644index 0000000000..dcb341a984--- /dev/null+++ b/backend/src/services/app-connection/smb/index.ts@@ -0,0 +1,4 @@+export * from "./smb-connection-enums";+export * from "./smb-connection-fns";+export * from "./smb-connection-schemas";+export * from "./smb-connection-types";diff --git a/backend/src/services/app-connection/smb/smb-connection-enums.ts b/backend/src/services/app-connection/smb/smb-connection-enums.tsnew file mode 100644index 0000000000..b31f3eface--- /dev/null+++ b/backend/src/services/app-connection/smb/smb-connection-enums.ts@@ -0,0 +1,3 @@+export enum SmbConnectionMethod {+ Credentials = "credentials"+}diff --git a/backend/src/services/app-connection/smb/smb-connection-fns.ts b/backend/src/services/app-connection/smb/smb-connection-fns.tsnew file mode 100644index 0000000000..d89ae8e8c2--- /dev/null+++ b/backend/src/services/app-connection/smb/smb-connection-fns.ts@@ -0,0 +1,81 @@+import { TGatewayServiceFactory } from "@app/ee/services/gateway/gateway-service";+import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";+import { BadRequestError } from "@app/lib/errors";+import { GatewayProxyProtocol } from "@app/lib/gateway";+import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";+import { verifyWindowsCredentials } from "@app/lib/smb-rpc";+import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";++import { SmbConnectionMethod } from "./smb-connection-enums";+import { TSmbConnectionConfig } from "./smb-connection-types";++export const getSmbConnectionListItem = () => {+ return {+ name: "SMB" as const,+ app: AppConnection.SMB as const,+ methods: Object.values(SmbConnectionMethod) as [SmbConnectionMethod.Credentials]+ };+};++export const executeSmbWithPotentialGateway = async <T>(+ config: TSmbConnectionConfig,+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,+ operation: (targetHost: string, targetPort: number) => Promise<T>+): Promise<T> => {+ const { gatewayId, credentials } = config;++ if (gatewayId) {+ await blockLocalAndPrivateIpAddresses(`smb://${credentials.host}:${credentials.port}`, true);++ const platformConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({+ gatewayId,+ targetHost: credentials.host,+ targetPort: credentials.port+ });++ if (!platformConnectionDetails) {+ throw new BadRequestError({ message: "Unable to connect to gateway, no platform connection details found" });+ }++ return withGatewayV2Proxy(+ async (proxyPort) => {+ return operation("localhost", proxyPort);+ },+ {+ protocol: GatewayProxyProtocol.Tcp,+ relayHost: platformConnectionDetails.relayHost,+ gateway: platformConnectionDetails.gateway,+ relay: platformConnectionDetails.relay+ }+ );+ }++ // Non-gateway path - direct connection+ await blockLocalAndPrivateIpAddresses(`smb://${credentials.host}:${credentials.port}`, false);+ return operation(credentials.host, credentials.port);+};++export const validateSmbConnectionCredentials = async (+ config: TSmbConnectionConfig,+ _gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">+) => {+ try {+ await executeSmbWithPotentialGateway(config, gatewayV2Service, async (targetHost, targetPort) => {+ await verifyWindowsCredentials(+ targetHost,+ targetPort,+ config.credentials.username,+ config.credentials.password,+ config.credentials.domain+ );+ });++ return config.credentials;+ } catch (error) {+ throw new BadRequestError({+ message: `Unable to validate connection: ${(error as Error)?.message ?? "verify credentials"}`+ });+ }+};diff --git a/backend/src/services/app-connection/smb/smb-connection-schemas.ts b/backend/src/services/app-connection/smb/smb-connection-schemas.tsnew file mode 100644index 0000000000..4f49164f96--- /dev/null+++ b/backend/src/services/app-connection/smb/smb-connection-schemas.ts@@ -0,0 +1,82 @@+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 { SmbConnectionMethod } from "./smb-connection-enums";++export const SmbConnectionCredentialsSchema = z.object({+ host: z.string().trim().min(1, "Host required").describe(AppConnections.CREDENTIALS.SMB.host),+ port: z.coerce.number().int().min(1).max(65535).describe(AppConnections.CREDENTIALS.SMB.port),+ domain: z.string().trim().optional().describe(AppConnections.CREDENTIALS.SMB.domain),+ username: z.string().trim().min(1, "Username required").describe(AppConnections.CREDENTIALS.SMB.username),+ password: z.string().trim().min(1, "Password required").describe(AppConnections.CREDENTIALS.SMB.password)+});++// Validation schema for credentials+export const ValidateSmbConnectionCredentialsSchema = z.object({+ method: z.literal(SmbConnectionMethod.Credentials).describe(AppConnections.CREATE(AppConnection.SMB).method),+ credentials: SmbConnectionCredentialsSchema.describe(AppConnections.CREATE(AppConnection.SMB).credentials)+});++// Create connection schema+export const CreateSmbConnectionSchema = ValidateSmbConnectionCredentialsSchema.and(+ GenericCreateAppConnectionFieldsSchema(AppConnection.SMB, {+ supportsGateways: true+ })+);++// Update connection schema+export const UpdateSmbConnectionSchema = z+ .object({+ credentials: SmbConnectionCredentialsSchema.optional().describe(+ AppConnections.UPDATE(AppConnection.SMB).credentials+ )+ })+ .and(+ GenericUpdateAppConnectionFieldsSchema(AppConnection.SMB, {+ supportsGateways: true+ })+ );++// Base connection schema+const BaseSmbConnectionSchema = BaseAppConnectionSchema.extend({+ app: z.literal(AppConnection.SMB)+});++// Full connection schema+export const SmbConnectionSchema = BaseSmbConnectionSchema.extend({+ method: z.literal(SmbConnectionMethod.Credentials),+ credentials: SmbConnectionCredentialsSchema+});++// Sanitized credentials schema (excludes sensitive fields)+const SanitizedSmbConnectionCredentialsSchema = z.object({+ host: z.string(),+ port: z.number(),+ domain: z.string().optional(),+ username: z.string()+});++// Sanitized schema (excludes sensitive fields)+export const SanitizedSmbConnectionSchema = z.discriminatedUnion("method", [+ BaseSmbConnectionSchema.extend({+ method: z.literal(SmbConnectionMethod.Credentials),+ credentials: SanitizedSmbConnectionCredentialsSchema+ }).describe(JSON.stringify({ title: APP_CONNECTION_NAME_MAP[AppConnection.SMB] }))+]);++// List item schema+export const SmbConnectionListItemSchema = z+ .object({+ name: z.literal("SMB"),+ app: z.literal(AppConnection.SMB),+ methods: z.nativeEnum(SmbConnectionMethod).array()+ })+ .describe(JSON.stringify({ title: APP_CONNECTION_NAME_MAP[AppConnection.SMB] }));diff --git a/backend/src/services/app-connection/smb/smb-connection-types.ts b/backend/src/services/app-connection/smb/smb-connection-types.tsnew file mode 100644index 0000000000..3e44c5632f--- /dev/null+++ b/backend/src/services/app-connection/smb/smb-connection-types.ts@@ -0,0 +1,25 @@+import { z } from "zod";++import { DiscriminativePick } from "@app/lib/types";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";++import {+ CreateSmbConnectionSchema,+ SmbConnectionSchema,+ ValidateSmbConnectionCredentialsSchema+} from "./smb-connection-schemas";++export type TSmbConnection = z.infer<typeof SmbConnectionSchema>;++export type TSmbConnectionInput = z.infer<typeof CreateSmbConnectionSchema> & {+ app: AppConnection.SMB;+};++export type TValidateSmbConnectionCredentialsSchema = typeof ValidateSmbConnectionCredentialsSchema;++export type TSmbConnectionConfig = DiscriminativePick<+ TSmbConnectionInput,+ "method" | "app" | "credentials" | "gatewayId"+> & {+ orgId: string;+};diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/WindowsLocalAccountRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/WindowsLocalAccountRotationParametersFields.tsxindex 26b26b1b06..882e349be4 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/WindowsLocalAccountRotationParametersFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/WindowsLocalAccountRotationParametersFields.tsx@@ -33,7 +33,7 @@ export const WindowsLocalAccountRotationParametersFields = () => {<span>Determines how the rotation will be performed:</span><ul className="mt-2 ml-4 flex list-disc flex-col gap-2"><li>- <span className="font-medium">Login as Root</span> - The SSH connection+ <span className="font-medium">Login as Root</span> - The SMB connectioncredentials of the app connection linked will be used to change the targetuser's password.</li>@@ -53,7 +53,7 @@ export const WindowsLocalAccountRotationParametersFields = () => {isUpdate? "Cannot be updated.": value === WindowsLocalAccountRotationMethod.LoginAsRoot- ? "The SSH connection credentials will change the target user's password"+ ? "The SMB connection credentials will change the target user's password": "The target user will change their own password"}>diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.tsindex f2bac4054d..aa34d324d1 100644--- a/frontend/src/helpers/appConnections.ts+++ b/frontend/src/helpers/appConnections.ts@@ -59,6 +59,7 @@ import { NorthflankConnectionMethod } from "@app/hooks/api/appConnections/types/import { OCIConnectionMethod } from "@app/hooks/api/appConnections/types/oci-connection";import { RailwayConnectionMethod } from "@app/hooks/api/appConnections/types/railway-connection";import { RenderConnectionMethod } from "@app/hooks/api/appConnections/types/render-connection";+import { SmbConnectionMethod } from "@app/hooks/api/appConnections/types/smb-connection";import { SshConnectionMethod } from "@app/hooks/api/appConnections/types/ssh-connection";import { SupabaseConnectionMethod } from "@app/hooks/api/appConnections/types/supabase-connection";@@ -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.SMB]: { name: "SMB", image: "Windows.png", size: 50 }};export const getAppConnectionMethodDetails = (method: TAppConnection["method"]) => {@@ -231,6 +233,8 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])return { name: "Password", icon: faLock };case SshConnectionMethod.SshKey:return { name: "SSH Key", icon: faKey };+ case SmbConnectionMethod.Credentials:+ return { name: "Credentials", icon: faLock };default:throw new Error(`Unhandled App Connection Method: ${method}`);}diff --git a/frontend/src/helpers/secretRotationsV2.ts b/frontend/src/helpers/secretRotationsV2.tsindex e3def5c3e4..416b15ce6e 100644--- a/frontend/src/helpers/secretRotationsV2.ts+++ b/frontend/src/helpers/secretRotationsV2.ts@@ -91,7 +91,7 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio[SecretRotation.MongoDBCredentials]: AppConnection.MongoDB,[SecretRotation.DatabricksServicePrincipalSecret]: AppConnection.Databricks,[SecretRotation.UnixLinuxLocalAccount]: AppConnection.SSH,- [SecretRotation.WindowsLocalAccount]: AppConnection.SSH+ [SecretRotation.WindowsLocalAccount]: AppConnection.SMB};// if a rotation can potentially have downtime due to rotating a single credential set this to falsediff --git a/frontend/src/hooks/api/appConnections/enums.ts b/frontend/src/hooks/api/appConnections/enums.tsindex 634f8ba208..07a7ff5c43 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",+ SMB = "smb"}diff --git a/frontend/src/hooks/api/appConnections/types/index.ts b/frontend/src/hooks/api/appConnections/types/index.tsindex 4cf63d2182..80ea71d316 100644--- a/frontend/src/hooks/api/appConnections/types/index.ts+++ b/frontend/src/hooks/api/appConnections/types/index.ts@@ -39,6 +39,7 @@ import { TPostgresConnection } from "./postgres-connection";import { TRailwayConnection } from "./railway-connection";import { TRedisConnection } from "./redis-connection";import { TRenderConnection } from "./render-connection";+import { TSmbConnection } from "./smb-connection";import { TSshConnection } from "./ssh-connection";import { TSupabaseConnection } from "./supabase-connection";import { TTeamCityConnection } from "./teamcity-connection";@@ -85,6 +86,7 @@ export * from "./postgres-connection";export * from "./railway-connection";export * from "./redis-connection";export * from "./render-connection";+export * from "./smb-connection";export * from "./ssh-connection";export * from "./supabase-connection";export * from "./teamcity-connection";@@ -139,7 +141,8 @@ export type TAppConnection =| TMongoDBConnection| TChefConnection| TDNSMadeEasyConnection- | TSshConnection;+ | TSshConnection+ | TSmbConnection;export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id" | "projectId">;diff --git a/frontend/src/hooks/api/appConnections/types/smb-connection.ts b/frontend/src/hooks/api/appConnections/types/smb-connection.tsnew file mode 100644index 0000000000..9368dc4b0d--- /dev/null+++ b/frontend/src/hooks/api/appConnections/types/smb-connection.ts@@ -0,0 +1,17 @@+import { AppConnection } from "@app/hooks/api/appConnections/enums";+import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";++export enum SmbConnectionMethod {+ Credentials = "credentials"+}++export type TSmbConnection = TRootAppConnection & {+ app: AppConnection.SMB;+ method: SmbConnectionMethod.Credentials;+ credentials: {+ host: string;+ port: number;+ domain?: string;+ username: string;+ };+};diff --git a/frontend/src/hooks/api/secretRotationsV2/types/windows-local-account-rotation.ts b/frontend/src/hooks/api/secretRotationsV2/types/windows-local-account-rotation.tsindex dabf2d8143..28dbcf1ccf 100644--- a/frontend/src/hooks/api/secretRotationsV2/types/windows-local-account-rotation.ts+++ b/frontend/src/hooks/api/secretRotationsV2/types/windows-local-account-rotation.ts@@ -38,7 +38,7 @@ export type TWindowsLocalAccountRotationGeneratedCredentialsResponse =export type TWindowsLocalAccountRotationOption = {name: string;type: SecretRotation.WindowsLocalAccount;- connection: AppConnection.SSH;+ connection: AppConnection.SMB;template: {secretsMapping: TWindowsLocalAccountRotation["secretsMapping"];};diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsxindex 199858f47b..de7dd23645 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx@@ -48,6 +48,7 @@ import { PostgresConnectionForm } from "./PostgresConnectionForm";import { RailwayConnectionForm } from "./RailwayConnectionForm";import { RedisConnectionForm } from "./RedisConnectionForm";import { RenderConnectionForm } from "./RenderConnectionForm";+import { SmbConnectionForm } from "./SmbConnectionForm";import { SshConnectionForm } from "./SshConnectionForm";import { SupabaseConnectionForm } from "./SupabaseConnectionForm";import { TeamCityConnectionForm } from "./TeamCityConnectionForm";@@ -182,6 +183,8 @@ const CreateForm = ({ app, onComplete, projectId }: CreateFormProps) => {return <OctopusDeployConnectionForm onSubmit={onSubmit} />;case AppConnection.SSH:return <SshConnectionForm onSubmit={onSubmit} />;+ case AppConnection.SMB:+ return <SmbConnectionForm 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.SMB:+ return <SmbConnectionForm 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/SmbConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsxnew file mode 100644index 0000000000..cb3eb09fd1--- /dev/null+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsx@@ -0,0 +1,242 @@+import { Controller, FormProvider, useForm } from "react-hook-form";+import { zodResolver } from "@hookform/resolvers/zod";+import { useQuery } from "@tanstack/react-query";+import { z } from "zod";++import { OrgPermissionCan } from "@app/components/permissions";+import {+ Button,+ FormControl,+ Input,+ ModalClose,+ SecretInput,+ Select,+ SelectItem,+ Tooltip+} from "@app/components/v2";+import { OrgPermissionSubjects, useSubscription } from "@app/context";+import { OrgGatewayPermissionActions } from "@app/context/OrgPermissionContext/types";+import { APP_CONNECTION_MAP } from "@app/helpers/appConnections";+import { gatewaysQueryKeys } from "@app/hooks/api";+import { SmbConnectionMethod, TSmbConnection } from "@app/hooks/api/appConnections";+import { AppConnection } from "@app/hooks/api/appConnections/enums";++import {+ genericAppConnectionFieldsSchema,+ GenericAppConnectionsFields+} from "./GenericAppConnectionFields";++type Props = {+ appConnection?: TSmbConnection;+ onSubmit: (formData: FormData) => Promise<void>;+};++const formSchema = genericAppConnectionFieldsSchema.extend({+ app: z.literal(AppConnection.SMB),+ method: z.literal(SmbConnectionMethod.Credentials),+ credentials: z.object({+ host: z.string().trim().min(1, "Host required"),+ port: z.coerce.number().int().min(1).max(65535, "Port must be between 1 and 65535"),+ domain: z.string().trim().optional(),+ username: z.string().trim().min(1, "Username required"),+ password: z.string().trim().min(1, "Password required")+ })+});++type FormData = z.infer<typeof formSchema>;++export const SmbConnectionForm = ({ appConnection, onSubmit }: Props) => {+ const isUpdate = Boolean(appConnection);++ const form = useForm<FormData>({+ resolver: zodResolver(formSchema),+ defaultValues: appConnection+ ? {+ ...appConnection,+ credentials: {+ ...appConnection.credentials,+ password: ""+ }+ }+ : {+ app: AppConnection.SMB,+ method: SmbConnectionMethod.Credentials,+ gatewayId: null,+ credentials: {+ host: "",+ port: 445,+ domain: "",+ username: "",+ password: ""+ }+ }+ });++ const {+ handleSubmit,+ control,+ formState: { isSubmitting, isDirty }+ } = form;++ const { subscription } = useSubscription();+ const { data: gateways, isPending: isGatewaysLoading } = useQuery(gatewaysQueryKeys.list());++ return (+ <FormProvider {...form}>+ <form onSubmit={handleSubmit(onSubmit)}>+ {!isUpdate && <GenericAppConnectionsFields />}+ {subscription.gateway && (+ <OrgPermissionCan+ I={OrgGatewayPermissionActions.AttachGateways}+ a={OrgPermissionSubjects.Gateway}+ >+ {(isAllowed) => (+ <Controller+ control={control}+ name="gatewayId"+ defaultValue=""+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error?.message)}+ errorText={error?.message}+ label="Gateway"+ >+ <Tooltip+ isDisabled={isAllowed}+ content="Restricted access. You don't have permission to attach gateways to resources."+ >+ <div>+ <Select+ isDisabled={!isAllowed}+ value={value as string}+ onValueChange={onChange}+ className="w-full border border-mineshaft-500"+ dropdownContainerClassName="max-w-none"+ isLoading={isGatewaysLoading}+ placeholder="Default: Internet Gateway"+ position="popper"+ >+ <SelectItem+ value={null as unknown as string}+ onClick={() => onChange(undefined)}+ >+ Internet Gateway+ </SelectItem>+ {gateways?.map((el) => (+ <SelectItem value={el.id} key={el.id}>+ {el.name}+ </SelectItem>+ ))}+ </Select>+ </div>+ </Tooltip>+ </FormControl>+ )}+ />+ )}+ </OrgPermissionCan>+ )}+ <div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3 pb-0">+ <p className="mb-3 text-xs text-mineshaft-300">+ SMB connection uses SMB3 encryption for secure Windows remote management.+ </p>+ <Controller+ name="credentials.host"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Host"+ >+ <Input {...field} placeholder="Hostname or IP address of Windows server" />+ </FormControl>+ )}+ />+ <Controller+ name="credentials.port"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Port"+ isOptional+ >+ <Input+ type="number"+ value={value}+ onChange={(e) => onChange(e.target.value ? Number(e.target.value) : 445)}+ placeholder="445"+ />+ </FormControl>+ )}+ />+ <Controller+ name="credentials.domain"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Domain"+ isOptional+ >+ <Input {...field} placeholder="e.g., MYDOMAIN (for domain-joined servers)" />+ </FormControl>+ )}+ />+ <Controller+ name="credentials.username"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Username"+ >+ <Input {...field} placeholder="Administrator" />+ </FormControl>+ )}+ />+ <Controller+ name="credentials.password"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Password"+ >+ <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>+ <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 ${APP_CONNECTION_MAP[AppConnection.SMB].name}`}+ </Button>+ <ModalClose asChild>+ <Button colorSchema="secondary" variant="plain">+ Cancel+ </Button>+ </ModalClose>+ </div>+ </form>+ </FormProvider>+ );+};