Skip to content

feat(ftp): add SSH key authentication for SFTP#968

Merged
heloise-gllm merged 7 commits intodevelopfrom
feat/ftp-ssh-key-auth
Feb 23, 2026
Merged

feat(ftp): add SSH key authentication for SFTP#968
heloise-gllm merged 7 commits intodevelopfrom
feat/ftp-ssh-key-auth

Conversation

@jloriaux
Copy link
Contributor

Summary

  • Add SSH key authentication support for SFTP image pre-hosting (alternative to password)
  • Support PEM and OpenSSH key formats
  • Reorganize group settings form with clear sections
  • Extract FTP logic to dedicated service with unit tests

Changes

Features

  • SSH Key Auth: Groups can now use SSH private keys for SFTP authentication
  • Auth Type Selection: UI dropdown to choose between password or SSH key
  • Key Format Validation: Validates PEM (RSA/DSA/EC) and OpenSSH formats

Code Quality

  • Extract group-ftp.service.js from controller (209 lines)
  • Extract ftp-settings.vue component (285 lines)
  • Add 29 unit tests (100% coverage on FTP service)
  • Add ERROR_CODES for standardized FTP/SSH error handling

UI Improvements

  • Reorganize group form into 4 sections: General Info, Image Hosting, Authentication, Permissions

Test Plan

  • Test SFTP with password authentication
  • Test SFTP with SSH key authentication
  • Unit tests pass (29/29)
  • Linting passes (0 errors)

Jonathan Loriaux and others added 5 commits February 20, 2026 15:09
Add support for SSH key authentication in addition to password
authentication for SFTP image hosting.

## Changes

### Dependencies
- Upgrade ssh2-sftp-client from 5.1.2 to 7.2.3 (fixed version)
- Required for rsa-sha2-256/512 support (OpenSSH 8.8+)

### Backend
- group.schema.js: Add ftpAuthType (password/ssh_key) and ftpSshKey fields
- ftp-client.service.js: Support privateKey in connection settings
- mailing.service.js: Pass auth type and SSH key to FTP client
- group.controller.js:
  - Validate SSH key format (PEM/OpenSSH)
  - Mask ftpPassword and ftpSshKey in API responses
  - Handle credential updates (preserve masked, delete with __DELETE__)
  - Add testFtpConnection endpoint
- group.routes.js: Add POST /:groupId/test-ftp-connection route

### Frontend
- form.vue: Auth method selector, SSH key textarea, test connection button
- api-routes.js: Add groupTestFtpConnection route
- Translations FR/EN for new fields

## Supported key types (Node 14)
- RSA 2048+ ✓
- ECDSA ✓
- Ed25519 ✗ (requires Node 16+)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Fix undefined groupId error for admin users without a group
- Fix maskFtpCredentials using toJSON() to include Mongoose virtuals (id)
- Pass ftpAuthType and ftpSshKey through ftpServerParams to FTP client

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Add 4 clear sections: General Info, Image Hosting, Authentication, Permissions
- Group FTP fields logically: connection, authentication, paths, display
- Add visual encapsulation for FTP and CDN subsections
- Move permissions checkbox to its own section (was buried in SAML)
- Add section titles with FR/EN translations
- Fix typo: "Compagny" → "Company" in English locale

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
## Code Quality Improvements
- Extract FTP logic from group.controller.js to group-ftp.service.js
- Extract FTP form fields from form.vue to ftp-settings.vue component
- Add ERROR_CODES for FTP/SSH errors (standardized error handling)
- Fix console.error to use development-only logging in user.js store

## Tests
- Add 29 unit tests for group-ftp.service.js (100% coverage)
- Tests cover: validateSshKeyFormat, maskFtpCredentials,
  processCredentialsForUpdate, mapFtpError

## File Size Reduction
- group.controller.js: 587 → 463 lines (-124)
- form.vue: 695 → 477 lines (-218)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 23, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
4 Security Hotspots
7.0% Duplication on New Code (required ≤ 3%)
B Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@heloise-gllm heloise-gllm merged commit e369276 into develop Feb 23, 2026
4 of 5 checks passed
@heloise-gllm heloise-gllm deleted the feat/ftp-ssh-key-auth branch February 23, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants