feat: add SFTP private key authentication support

This commit is contained in:
2026-06-09 14:27:23 +01:00
parent 9b25229073
commit a812d4ac35
3 changed files with 42 additions and 3 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ jobs:
uses: https://gitea.com/actions/gitea-release-action@v1
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
name: GoExplore ${{ steps.get_version.outputs.VERSION }}
name: ${{ steps.get_version.outputs.VERSION }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
+8 -1
View File
@@ -123,8 +123,15 @@
<input type="text" id="conn-username" placeholder="user">
</div>
<div class="form-group" style="flex: 1;">
<label>Password / Secret Key</label>
<div style="display: flex; justify-content: space-between; align-items: center;">
<label id="secret-label">Password / Secret Key</label>
<select id="conn-sftp-auth-type" style="display: none; width: auto; font-size: 0.75rem; padding: 0.1rem 0.3rem;" onchange="updateProtocolFields()">
<option value="password">Password</option>
<option value="key">Private Key</option>
</select>
</div>
<input type="password" id="conn-secret" placeholder="Stored in OS Keychain">
<textarea id="conn-secret-key" style="display: none; width: 100%; box-sizing: border-box; background: var(--bg-alt); color: var(--text-primary); border: 1px solid var(--border); border-radius: 4px; padding: 0.5rem; font-family: monospace;" rows="4" placeholder="-----BEGIN OPENSSH PRIVATE KEY-----..."></textarea>
</div>
</div>
+33 -1
View File
@@ -48,7 +48,10 @@ async function init() {
path_style: document.getElementById('conn-pathstyle').checked,
username: document.getElementById('conn-username').value
};
const secret = document.getElementById('conn-secret').value;
let secret = document.getElementById('conn-secret').value;
if (conn.protocol === 'sftp' && document.getElementById('conn-sftp-auth-type').value === 'key') {
secret = document.getElementById('conn-secret-key').value;
}
try {
await SaveConnection(conn, secret);
@@ -104,6 +107,8 @@ window.editConnection = (id) => {
document.getElementById('conn-pathstyle').checked = c.path_style || false;
document.getElementById('conn-username').value = c.username || '';
document.getElementById('conn-secret').value = '';
document.getElementById('conn-secret-key').value = '';
document.getElementById('conn-sftp-auth-type').value = 'password';
document.getElementById('conn-delete-btn').style.display = 'block';
updateProtocolFields();
@@ -114,6 +119,9 @@ window.openConnModal = () => {
document.getElementById('modal-title').innerText = "Add Connection";
document.getElementById('conn-form').reset();
document.getElementById('conn-id').value = uuidv4();
document.getElementById('conn-secret').value = '';
document.getElementById('conn-secret-key').value = '';
document.getElementById('conn-sftp-auth-type').value = 'password';
document.getElementById('conn-delete-btn').style.display = 'none';
updateProtocolFields();
document.getElementById('conn-modal').style.display = 'flex';
@@ -133,6 +141,30 @@ window.updateProtocolFields = () => {
const showS3Specific = protocol === 's3';
document.getElementById('region-group').style.display = showS3Specific ? 'flex' : 'none';
document.getElementById('pathstyle-group').style.display = showS3Specific ? 'flex' : 'none';
// SFTP Auth Type toggle
const authTypeSelect = document.getElementById('conn-sftp-auth-type');
const secretInput = document.getElementById('conn-secret');
const secretKeyArea = document.getElementById('conn-secret-key');
const secretLabel = document.getElementById('secret-label');
if (protocol === 'sftp') {
authTypeSelect.style.display = 'block';
if (authTypeSelect.value === 'key') {
secretInput.style.display = 'none';
secretKeyArea.style.display = 'block';
secretLabel.innerText = 'SSH Private Key';
} else {
secretInput.style.display = 'block';
secretKeyArea.style.display = 'none';
secretLabel.innerText = 'Password';
}
} else {
authTypeSelect.style.display = 'none';
secretInput.style.display = 'block';
secretKeyArea.style.display = 'none';
secretLabel.innerText = 'Password / Secret Key';
}
};
window.deleteConnection = async () => {