Skip to content

Commit 9f6a28a

Browse files
committed
Add new begin_auth callback in SSHClient
This commit adds a new begin_auth callback in the SSHClient class. When AsyncSSH is acting as a client, this is called when authentication begins, providing the username the client is attempting to authenticate as, after evaluating any supplied SSH config and connection options.
1 parent efd4b82 commit 9f6a28a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

asyncssh/client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ def auth_banner_received(self, msg: str, lang: str) -> None:
220220
221221
"""
222222

223+
def begin_auth(self, username: str) -> None:
224+
"""Begin client authentication
225+
226+
This method is called when client authentication is about to
227+
begin, Applications may store the username passed here to
228+
be used in future authentication callbacks.
229+
230+
"""
231+
223232
def auth_completed(self) -> None:
224233
"""Authentication was completed successfully
225234

asyncssh/connection.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,9 @@ def _process_service_accept(self, _pkttype: int, _pktid: int,
22922292

22932293
self._auth_in_progress = True
22942294

2295+
if self._owner: # pragma: no branch
2296+
self._owner.begin_auth(self._username)
2297+
22952298
# This method is only in SSHClientConnection
22962299
# pylint: disable=no-member
22972300
cast('SSHClientConnection', self).try_next_auth()

0 commit comments

Comments
 (0)