-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/1730 extend filesystem sftp (#1769)
* chore: add paramiko dev dependency * test: add container for sftp localhost * chore: add tmp bash scripts * exp: sftp client with fsspec * chore: sftp timestamp metadata discovered * fix: docs lint * feat: add fsspec protocol sftp * fix: lint errors from devel * test: sftp server localhost * fix: filesystem SFTP docker-compose tests * fix: json import * chore: clean tests and dockerfile * refactor: ci test exec for sftp server * feat: sftp file url parser * test: sftp reading using file samples * chore: extended SFTP credentials class * docs: filesystem SFTP credentials and authentication * chore: add bobby password protected key-based authentication * docs: sftp correction for ssh-agent * chore: add docker volume * chore: revert ci changes * test: refactor sftp with auth methods * test: sftp skip test when agent not configured * fix: poetry lock * fix: github workflow * fix: run only sftp tests * fix: merge conflict regression * fix: ssh-agent for tests * fix: pytest executions excluding sftp * fix: CI test execution * test: sftp login with signed certificate * fix: poetry lock regenerated * refactor: filesystem sftp tests * fix: filesystem tests for sftp * refactor: reduce redundancy * fix: lint and remove duplicated test * chore: change ubuntu version * fix: enforce test marker * fix: ignore sftp tests * fix: exclude sftp from filesystem tests * adds sftp extra dep --------- Co-authored-by: Marcin Rudolf <[email protected]>
- Loading branch information
Showing
29 changed files
with
883 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from typing import Any, Dict, Optional | ||
|
||
from dlt.common.typing import TSecretStrValue, DictStrAny | ||
from dlt.common.configuration.specs.base_configuration import CredentialsConfiguration, configspec | ||
|
||
|
||
@configspec | ||
class SFTPCredentials(CredentialsConfiguration): | ||
"""Credentials for SFTP filesystem, compatible with fsspec SFTP protocol. | ||
Authentication is attempted in the following order of priority: | ||
- `key_filename` may contain OpenSSH public certificate paths | ||
as well as regular private-key paths; when files ending in `-cert.pub` are found, they are assumed to match | ||
a private key, and both components will be loaded. | ||
- Any key found through an SSH agent: any “id_rsa”, “id_dsa”, or “id_ecdsa” key discoverable in ~/.ssh/. | ||
- Plain username/password authentication, if a password was provided. | ||
- If a private key requires a password to unlock it, and a password is provided, that password will be used to | ||
attempt to unlock the key. | ||
For more information about parameters: | ||
https://docs.paramiko.org/en/3.3/api/client.html#paramiko.client.SSHClient.connect | ||
""" | ||
|
||
sftp_port: Optional[int] = 22 | ||
sftp_username: Optional[str] = None | ||
sftp_password: Optional[TSecretStrValue] = None | ||
sftp_key_filename: Optional[str] = None | ||
sftp_key_passphrase: Optional[TSecretStrValue] = None | ||
sftp_timeout: Optional[float] = None | ||
sftp_banner_timeout: Optional[float] = None | ||
sftp_auth_timeout: Optional[float] = None | ||
sftp_channel_timeout: Optional[float] = None | ||
sftp_allow_agent: Optional[bool] = True | ||
sftp_look_for_keys: Optional[bool] = True | ||
sftp_compress: Optional[bool] = False | ||
sftp_gss_auth: Optional[bool] = False | ||
sftp_gss_kex: Optional[bool] = False | ||
sftp_gss_deleg_creds: Optional[bool] = True | ||
sftp_gss_host: Optional[str] = None | ||
sftp_gss_trust_dns: Optional[bool] = True | ||
|
||
def to_fsspec_credentials(self) -> Dict[str, Any]: | ||
"""Return a dict that can be passed to fsspec SFTP/SSHClient.connect method.""" | ||
|
||
credentials: Dict[str, Any] = { | ||
"port": self.sftp_port, | ||
"username": self.sftp_username, | ||
"password": self.sftp_password, | ||
"key_filename": self.sftp_key_filename, | ||
"passphrase": self.sftp_key_passphrase, | ||
"timeout": self.sftp_timeout, | ||
"banner_timeout": self.sftp_banner_timeout, | ||
"auth_timeout": self.sftp_auth_timeout, | ||
"channel_timeout": self.sftp_channel_timeout, | ||
"allow_agent": self.sftp_allow_agent, | ||
"look_for_keys": self.sftp_look_for_keys, | ||
"compress": self.sftp_compress, | ||
"gss_auth": self.sftp_gss_auth, | ||
"gss_kex": self.sftp_gss_kex, | ||
"gss_deleg_creds": self.sftp_gss_deleg_creds, | ||
"gss_host": self.sftp_gss_host, | ||
"gss_trust_dns": self.sftp_gss_trust_dns, | ||
} | ||
|
||
return credentials |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.