Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/two_factor' into two_factor
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Feb 2, 2024
2 parents 10de0f1 + 507bc62 commit b520a0e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pysqa/ext/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,18 @@ def _open_ssh_connection(self):
username=self._ssh_username,
password=self._ssh_password,
)
elif self._ssh_password is not None and self._ssh_authenticator_service is not None:
elif (
self._ssh_password is not None
and self._ssh_authenticator_service is not None
):

def authentication(title, instructions, prompt_list):
from pyauthenticator import get_two_factor_code

if len(prompt_list) > 0:
return [get_two_factor_code(service=self._ssh_authenticator_service)]
return [
get_two_factor_code(service=self._ssh_authenticator_service)
]
else:
return []

Expand All @@ -251,9 +258,7 @@ def authentication(title, instructions, prompt_list):
)

ssh._transport.auth_interactive(
username=self._ssh_username,
handler=authentication,
submethods=''
username=self._ssh_username, handler=authentication, submethods=""
)
else:
raise ValueError("Un-supported authentication method.")
Expand Down

0 comments on commit b520a0e

Please sign in to comment.