Add support for passwordless host authentication

Allow adding SSH hosts without authentication credentials by introducing
a new "none" auth type. This enables users to configure hosts for later
use with SSH agent or manual credential addition.

Changes:
- Add authType "none" to type definitions
- Update frontend form to support "None" authentication option
- Skip credential validation for "none" auth type
- Update backend to accept hosts without credentials
- Add i18n support for English and Chinese

Fixes #278
This commit is contained in:
ZacharyZcR
2025-10-04 04:17:07 +08:00
parent 937e04fa5c
commit 522fe3e571
5 changed files with 57 additions and 12 deletions
+20 -2
View File
@@ -281,7 +281,14 @@ router.post(
sshDataObj.keyPassword = keyPassword || null;
sshDataObj.keyType = keyType;
sshDataObj.password = null;
} else if (effectiveAuthType === "none") {
// No authentication credentials - set all to null
sshDataObj.password = null;
sshDataObj.key = null;
sshDataObj.keyPassword = null;
sshDataObj.keyType = null;
} else {
// credential type or fallback - set all to null except credentialId
sshDataObj.password = null;
sshDataObj.key = null;
sshDataObj.keyPassword = null;
@@ -471,7 +478,14 @@ router.put(
sshDataObj.keyType = keyType;
}
sshDataObj.password = null;
} else if (effectiveAuthType === "none") {
// No authentication credentials - set all to null
sshDataObj.password = null;
sshDataObj.key = null;
sshDataObj.keyPassword = null;
sshDataObj.keyType = null;
} else {
// credential type or fallback - set all to null except credentialId
sshDataObj.password = null;
sshDataObj.key = null;
sshDataObj.keyPassword = null;
@@ -1356,10 +1370,12 @@ router.post(
continue;
}
if (!["password", "key", "credential"].includes(hostData.authType)) {
if (
!["password", "key", "credential", "none"].includes(hostData.authType)
) {
results.failed++;
results.errors.push(
`Host ${i + 1}: Invalid authType. Must be 'password', 'key', or 'credential'`,
`Host ${i + 1}: Invalid authType. Must be 'password', 'key', 'credential', or 'none'`,
);
continue;
}
@@ -1391,6 +1407,8 @@ router.post(
continue;
}
// "none" authType requires no validation - no credentials needed
const sshDataObj: any = {
userId: userId,
name: hostData.name || `${hostData.username}@${hostData.ip}`,