diff --git a/httpd/api_folder.go b/httpd/api_folder.go index 273b876b..f2f25fa7 100644 --- a/httpd/api_folder.go +++ b/httpd/api_folder.go @@ -67,6 +67,7 @@ func updateFolder(w http.ResponseWriter, r *http.Request) { currentCryptoPassphrase := folder.FsConfig.CryptConfig.Passphrase currentSFTPPassword := folder.FsConfig.SFTPConfig.Password currentSFTPKey := folder.FsConfig.SFTPConfig.PrivateKey + currentSFTPKeyPassphrase := folder.FsConfig.SFTPConfig.Passphrase folder.FsConfig.S3Config = vfs.S3FsConfig{} folder.FsConfig.AzBlobConfig = vfs.AzBlobFsConfig{} @@ -82,7 +83,7 @@ func updateFolder(w http.ResponseWriter, r *http.Request) { folder.Name = name folder.FsConfig.SetEmptySecretsIfNil() updateEncryptedSecrets(&folder.FsConfig, currentS3AccessSecret, currentAzAccountKey, currentAzSASUrl, currentGCSCredentials, - currentCryptoPassphrase, currentSFTPPassword, currentSFTPKey) + currentCryptoPassphrase, currentSFTPPassword, currentSFTPKey, currentSFTPKeyPassphrase) err = dataprovider.UpdateFolder(&folder, users, groups, claims.Username, util.GetIPFromRemoteAddress(r.RemoteAddr)) if err != nil { sendAPIResponse(w, r, err, "", getRespStatus(err)) diff --git a/httpd/api_group.go b/httpd/api_group.go index ead160e6..c619f9b4 100644 --- a/httpd/api_group.go +++ b/httpd/api_group.go @@ -72,6 +72,7 @@ func updateGroup(w http.ResponseWriter, r *http.Request) { currentCryptoPassphrase := group.UserSettings.FsConfig.CryptConfig.Passphrase currentSFTPPassword := group.UserSettings.FsConfig.SFTPConfig.Password currentSFTPKey := group.UserSettings.FsConfig.SFTPConfig.PrivateKey + currentSFTPKeyPassphrase := group.UserSettings.FsConfig.SFTPConfig.Passphrase group.UserSettings.FsConfig.S3Config = vfs.S3FsConfig{} group.UserSettings.FsConfig.AzBlobConfig = vfs.AzBlobFsConfig{} @@ -87,7 +88,7 @@ func updateGroup(w http.ResponseWriter, r *http.Request) { group.Name = name group.UserSettings.FsConfig.SetEmptySecretsIfNil() updateEncryptedSecrets(&group.UserSettings.FsConfig, currentS3AccessSecret, currentAzAccountKey, currentAzSASUrl, - currentGCSCredentials, currentCryptoPassphrase, currentSFTPPassword, currentSFTPKey) + currentGCSCredentials, currentCryptoPassphrase, currentSFTPPassword, currentSFTPKey, currentSFTPKeyPassphrase) err = dataprovider.UpdateGroup(&group, users, claims.Username, util.GetIPFromRemoteAddress(r.RemoteAddr)) if err != nil { sendAPIResponse(w, r, err, "", getRespStatus(err)) diff --git a/httpd/api_user.go b/httpd/api_user.go index 8d9eee85..b278d7f1 100644 --- a/httpd/api_user.go +++ b/httpd/api_user.go @@ -134,6 +134,7 @@ func updateUser(w http.ResponseWriter, r *http.Request) { currentCryptoPassphrase := user.FsConfig.CryptConfig.Passphrase currentSFTPPassword := user.FsConfig.SFTPConfig.Password currentSFTPKey := user.FsConfig.SFTPConfig.PrivateKey + currentSFTPKeyPassphrase := user.FsConfig.SFTPConfig.Passphrase user.Permissions = make(map[string][]string) user.FsConfig.S3Config = vfs.S3FsConfig{} @@ -159,7 +160,7 @@ func updateUser(w http.ResponseWriter, r *http.Request) { user.Permissions = currentPermissions } updateEncryptedSecrets(&user.FsConfig, currentS3AccessSecret, currentAzAccountKey, currentAzSASUrl, - currentGCSCredentials, currentCryptoPassphrase, currentSFTPPassword, currentSFTPKey) + currentGCSCredentials, currentCryptoPassphrase, currentSFTPPassword, currentSFTPKey, currentSFTPKeyPassphrase) err = dataprovider.UpdateUser(&user, claims.Username, util.GetIPFromRemoteAddress(r.RemoteAddr)) if err != nil { sendAPIResponse(w, r, err, "", getRespStatus(err)) @@ -231,7 +232,7 @@ func disconnectUser(username string) { } func updateEncryptedSecrets(fsConfig *vfs.Filesystem, currentS3AccessSecret, currentAzAccountKey, currentAzSASUrl, - currentGCSCredentials, currentCryptoPassphrase, currentSFTPPassword, currentSFTPKey *kms.Secret) { + currentGCSCredentials, currentCryptoPassphrase, currentSFTPPassword, currentSFTPKey *kms.Secret, currentSFTPKeyPassphrase *kms.Secret) { // we use the new access secret if plain or empty, otherwise the old value switch fsConfig.Provider { case sdk.S3FilesystemProvider: @@ -262,5 +263,8 @@ func updateEncryptedSecrets(fsConfig *vfs.Filesystem, currentS3AccessSecret, cur if fsConfig.SFTPConfig.PrivateKey.IsNotPlainAndNotEmpty() { fsConfig.SFTPConfig.PrivateKey = currentSFTPKey } + if fsConfig.SFTPConfig.Passphrase.IsNotPlainAndNotEmpty() { + fsConfig.SFTPConfig.Passphrase = currentSFTPKeyPassphrase + } } } diff --git a/httpd/webadmin.go b/httpd/webadmin.go index f5172e98..6639ca71 100644 --- a/httpd/webadmin.go +++ b/httpd/webadmin.go @@ -1219,6 +1219,7 @@ func getSFTPConfig(r *http.Request) (vfs.SFTPFsConfig, error) { config.Username = r.Form.Get("sftp_username") config.Password = getSecretFromFormField(r, "sftp_password") config.PrivateKey = getSecretFromFormField(r, "sftp_private_key") + config.Passphrase = getSecretFromFormField(r, "sftp_passphrase") fingerprintsFormValue := r.Form.Get("sftp_fingerprints") config.Fingerprints = getSliceFromDelimitedValues(fingerprintsFormValue, "\n") config.Prefix = r.Form.Get("sftp_prefix") @@ -2202,7 +2203,7 @@ func (s *httpdServer) handleWebUpdateUserPost(w http.ResponseWriter, r *http.Req } updateEncryptedSecrets(&updatedUser.FsConfig, user.FsConfig.S3Config.AccessSecret, user.FsConfig.AzBlobConfig.AccountKey, user.FsConfig.AzBlobConfig.SASURL, user.FsConfig.GCSConfig.Credentials, user.FsConfig.CryptConfig.Passphrase, - user.FsConfig.SFTPConfig.Password, user.FsConfig.SFTPConfig.PrivateKey) + user.FsConfig.SFTPConfig.Password, user.FsConfig.SFTPConfig.PrivateKey, user.FsConfig.SFTPConfig.Passphrase) updatedUser = getUserFromTemplate(updatedUser, userTemplateFields{ Username: updatedUser.Username, @@ -2336,7 +2337,7 @@ func (s *httpdServer) handleWebUpdateFolderPost(w http.ResponseWriter, r *http.R updatedFolder.FsConfig.SetEmptySecretsIfNil() updateEncryptedSecrets(&updatedFolder.FsConfig, folder.FsConfig.S3Config.AccessSecret, folder.FsConfig.AzBlobConfig.AccountKey, folder.FsConfig.AzBlobConfig.SASURL, folder.FsConfig.GCSConfig.Credentials, folder.FsConfig.CryptConfig.Passphrase, - folder.FsConfig.SFTPConfig.Password, folder.FsConfig.SFTPConfig.PrivateKey) + folder.FsConfig.SFTPConfig.Password, folder.FsConfig.SFTPConfig.PrivateKey, folder.FsConfig.SFTPConfig.Passphrase) updatedFolder = getFolderFromTemplate(updatedFolder, updatedFolder.Name) @@ -2500,7 +2501,7 @@ func (s *httpdServer) handleWebUpdateGroupPost(w http.ResponseWriter, r *http.Re updateEncryptedSecrets(&updatedGroup.UserSettings.FsConfig, group.UserSettings.FsConfig.S3Config.AccessSecret, group.UserSettings.FsConfig.AzBlobConfig.AccountKey, group.UserSettings.FsConfig.AzBlobConfig.SASURL, group.UserSettings.FsConfig.GCSConfig.Credentials, group.UserSettings.FsConfig.CryptConfig.Passphrase, - group.UserSettings.FsConfig.SFTPConfig.Password, group.UserSettings.FsConfig.SFTPConfig.PrivateKey) + group.UserSettings.FsConfig.SFTPConfig.Password, group.UserSettings.FsConfig.SFTPConfig.PrivateKey, group.UserSettings.FsConfig.SFTPConfig.Passphrase) err = dataprovider.UpdateGroup(&updatedGroup, group.Users, claims.Username, ipAddr) if err != nil { diff --git a/templates/webadmin/fsconfig.html b/templates/webadmin/fsconfig.html index 67ab37df..879b4123 100644 --- a/templates/webadmin/fsconfig.html +++ b/templates/webadmin/fsconfig.html @@ -424,6 +424,17 @@ +