From 11f29f144b4883bb93e2f9fe34571a2ebb43935b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Mon, 29 Jan 2024 17:24:57 +0100 Subject: [PATCH] fixup! fs_storage: support SSH private keys authentication --- fs_storage/models/fs_storage.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fs_storage/models/fs_storage.py b/fs_storage/models/fs_storage.py index 77ea18c2d3..310ac57136 100644 --- a/fs_storage/models/fs_storage.py +++ b/fs_storage/models/fs_storage.py @@ -381,7 +381,9 @@ def _get_filesystem(self) -> fsspec.AbstractFileSystem: # paramiko.pkey.PKey object pkey_file = io.StringIO(options["pkey"]) pkey = self._get_ssh_private_key( - pkey_file, passphrase=options.get("passphrase") + pkey_file, + pkey_type=options.pop("pkey_type"), # Remove extra parameter + passphrase=options.get("passphrase"), ) options["pkey"] = pkey options = self._recursive_add_odoo_storage_path(options) @@ -411,12 +413,13 @@ def _detect_ssh_private_key_type(self, pkey_file): if keytype: return keytype - def _get_ssh_private_key(self, pkey_file, passphrase=None): + def _get_ssh_private_key(self, pkey_file, pkey_type=None, passphrase=None): """Build the expected `paramiko.pkey.PKey` object.""" - keytype = self._detect_ssh_private_key_type(pkey_file) - if not keytype: + if not pkey_type: + pkey_type = self._detect_ssh_private_key_type(pkey_file) + if not pkey_type: raise paramiko.SSHException("not a valid private key file") - return SSH_PKEYS[keytype].from_private_key(pkey_file, password=passphrase) + return SSH_PKEYS[pkey_type].from_private_key(pkey_file, password=passphrase) # Deprecated methods used to ease the migration from the storage_backend addons # to the fs_storage addons. These methods will be removed in the future (Odoo 18)