mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 23:25:24 +00:00
feat(ssh-terminal): add host setting to turn off password prompt auto-fill
This commit is contained in:
1 parent
f0d720cf05
commit
c5b2b880b6
8 files changed
+31
No files matched your search
@@ -1262,6 +1262,8 @@ const TerminalInner = forwardRef<TerminalHandle, SSHTerminalProps>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function maybeOfferPasswordFill(strippedData: string) {
|
function maybeOfferPasswordFill(strippedData: string) {
|
||||||
|
if (hostConfig.terminalConfig?.passwordPromptAutoFill === false) return;
|
||||||
|
|
||||||
// PTY output can split a short prompt like "[sudo] password for user: "
|
// PTY output can split a short prompt like "[sudo] password for user: "
|
||||||
// across multiple WebSocket chunks, so match against a rolling buffer
|
// across multiple WebSocket chunks, so match against a rolling buffer
|
||||||
// of recent output rather than each chunk in isolation.
|
// of recent output rather than each chunk in isolation.
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export interface TerminalConfig {
|
|||||||
startupSnippetId: number | null;
|
startupSnippetId: number | null;
|
||||||
autoMosh: boolean;
|
autoMosh: boolean;
|
||||||
moshCommand: string;
|
moshCommand: string;
|
||||||
|
passwordPromptAutoFill?: boolean;
|
||||||
sudoPasswordAutoFill: boolean;
|
sudoPasswordAutoFill: boolean;
|
||||||
sudoPassword?: string | null;
|
sudoPassword?: string | null;
|
||||||
keepaliveInterval?: number;
|
keepaliveInterval?: number;
|
||||||
|
|||||||
@@ -377,6 +377,7 @@ export interface TerminalConfig {
|
|||||||
startupSnippetId: number | null;
|
startupSnippetId: number | null;
|
||||||
autoMosh: boolean;
|
autoMosh: boolean;
|
||||||
moshCommand: string;
|
moshCommand: string;
|
||||||
|
passwordPromptAutoFill?: boolean;
|
||||||
sudoPasswordAutoFill: boolean;
|
sudoPasswordAutoFill: boolean;
|
||||||
sudoPassword?: string | null;
|
sudoPassword?: string | null;
|
||||||
keepaliveInterval?: number;
|
keepaliveInterval?: number;
|
||||||
|
|||||||
@@ -856,6 +856,7 @@ export const DEFAULT_TERMINAL_CONFIG = {
|
|||||||
startupSnippetId: null as number | null,
|
startupSnippetId: null as number | null,
|
||||||
autoMosh: false,
|
autoMosh: false,
|
||||||
moshCommand: "mosh-server new -s -l LANG=en_US.UTF-8",
|
moshCommand: "mosh-server new -s -l LANG=en_US.UTF-8",
|
||||||
|
passwordPromptAutoFill: true,
|
||||||
sudoPasswordAutoFill: false,
|
sudoPasswordAutoFill: false,
|
||||||
keepaliveInterval: undefined as number | undefined,
|
keepaliveInterval: undefined as number | undefined,
|
||||||
keepaliveCountMax: undefined as number | undefined,
|
keepaliveCountMax: undefined as number | undefined,
|
||||||
|
|||||||
@@ -567,6 +567,8 @@
|
|||||||
"linkClickBehaviorDefault": "Default (follow app setting)",
|
"linkClickBehaviorDefault": "Default (follow app setting)",
|
||||||
"linkClickBehaviorConfirm": "Show popup to open or copy",
|
"linkClickBehaviorConfirm": "Show popup to open or copy",
|
||||||
"linkClickBehaviorDirect": "Open directly",
|
"linkClickBehaviorDirect": "Open directly",
|
||||||
|
"passwordPromptAutoFillLabel": "Offer Password Auto-fill",
|
||||||
|
"passwordPromptAutoFillDesc": "Offer to fill in the saved password when the terminal asks for one. Turn off to never auto-fill any password on this host.",
|
||||||
"sudoPasswordAutoFillLabel": "Sudo Password Auto-fill",
|
"sudoPasswordAutoFillLabel": "Sudo Password Auto-fill",
|
||||||
"sudoPasswordAutoFillShortDesc": "Automatically provide sudo password when prompted",
|
"sudoPasswordAutoFillShortDesc": "Automatically provide sudo password when prompted",
|
||||||
"sudoPasswordAutoFillDesc": "Store a sudo password so host metrics, terminal prompts, and others can run privileged commands automatically.",
|
"sudoPasswordAutoFillDesc": "Store a sudo password so host metrics, terminal prompts, and others can run privileged commands automatically.",
|
||||||
|
|||||||
@@ -1005,6 +1005,15 @@ export function HostEditor({
|
|||||||
onChange={(v) => setField("allowLegacyAlgorithms", v)}
|
onChange={(v) => setField("allowLegacyAlgorithms", v)}
|
||||||
/>
|
/>
|
||||||
</SettingRow>
|
</SettingRow>
|
||||||
|
<SettingRow
|
||||||
|
label={t("hosts.passwordPromptAutoFillLabel")}
|
||||||
|
description={t("hosts.passwordPromptAutoFillDesc")}
|
||||||
|
>
|
||||||
|
<FakeSwitch
|
||||||
|
checked={form.passwordPromptAutoFill}
|
||||||
|
onChange={(v) => setField("passwordPromptAutoFill", v)}
|
||||||
|
/>
|
||||||
|
</SettingRow>
|
||||||
<SettingRow
|
<SettingRow
|
||||||
label={t("hosts.sudoPasswordAutoFillLabel")}
|
label={t("hosts.sudoPasswordAutoFillLabel")}
|
||||||
description={t("hosts.sudoPasswordAutoFillDesc")}
|
description={t("hosts.sudoPasswordAutoFillDesc")}
|
||||||
|
|||||||
@@ -200,6 +200,8 @@ export function createHostEditorForm(
|
|||||||
agentForwarding: host?.terminalConfig?.agentForwarding ?? false,
|
agentForwarding: host?.terminalConfig?.agentForwarding ?? false,
|
||||||
autoMosh: host?.terminalConfig?.autoMosh ?? false,
|
autoMosh: host?.terminalConfig?.autoMosh ?? false,
|
||||||
autoTmux: host?.terminalConfig?.autoTmux ?? d?.autoTmux ?? false,
|
autoTmux: host?.terminalConfig?.autoTmux ?? d?.autoTmux ?? false,
|
||||||
|
passwordPromptAutoFill:
|
||||||
|
host?.terminalConfig?.passwordPromptAutoFill ?? true,
|
||||||
sudoPasswordAutoFill: host?.terminalConfig?.sudoPasswordAutoFill ?? false,
|
sudoPasswordAutoFill: host?.terminalConfig?.sudoPasswordAutoFill ?? false,
|
||||||
sudoPassword: host?.hasSudoPassword
|
sudoPassword: host?.hasSudoPassword
|
||||||
? "existing_sudo_password"
|
? "existing_sudo_password"
|
||||||
@@ -344,6 +346,7 @@ export function buildHostEditorPayload(
|
|||||||
agentForwarding: form.agentForwarding,
|
agentForwarding: form.agentForwarding,
|
||||||
autoMosh: form.autoMosh,
|
autoMosh: form.autoMosh,
|
||||||
autoTmux: form.autoTmux,
|
autoTmux: form.autoTmux,
|
||||||
|
passwordPromptAutoFill: form.passwordPromptAutoFill,
|
||||||
sudoPasswordAutoFill: form.sudoPasswordAutoFill,
|
sudoPasswordAutoFill: form.sudoPasswordAutoFill,
|
||||||
sudoPassword:
|
sudoPassword:
|
||||||
form.sudoPassword === "existing_sudo_password"
|
form.sudoPassword === "existing_sudo_password"
|
||||||
|
|||||||
@@ -278,6 +278,18 @@ describe("buildHostEditorPayload auth field isolation", () => {
|
|||||||
expect(tc?.sudoPasswordAutoFill).toBe(true);
|
expect(tc?.sudoPasswordAutoFill).toBe(true);
|
||||||
expect(tc?.sudoPassword).toBe("sudo-secret");
|
expect(tc?.sudoPassword).toBe("sudo-secret");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("defaults password prompt autofill on and saves it when turned off", () => {
|
||||||
|
expect(createHostEditorForm(null).passwordPromptAutoFill).toBe(true);
|
||||||
|
|
||||||
|
const form = {
|
||||||
|
...createHostEditorForm(null),
|
||||||
|
passwordPromptAutoFill: false,
|
||||||
|
};
|
||||||
|
const payload = buildHostEditorPayload(form, sshOnly);
|
||||||
|
|
||||||
|
expect(payload.terminalConfig?.passwordPromptAutoFill).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("sudo password persistence indicator", () => {
|
describe("sudo password persistence indicator", () => {
|
||||||
|
|||||||
Reference in new issue
Block a user