Allow more replies to end SASL auth

This commit is contained in:
Dpeta 2023-02-25 21:22:36 +01:00
parent 2a65361c92
commit 5f817867eb
No known key found for this signature in database
GPG key ID: 51227517CEA0030C
2 changed files with 13 additions and 5 deletions

15
irc.py
View file

@ -115,8 +115,10 @@ class PesterIRC(QtCore.QThread):
"768": self._keynotset, "768": self._keynotset,
"769": self._keynopermission, "769": self._keynopermission,
"770": self._metadatasubok, "770": self._metadatasubok,
"902": self._sasl_skill_issue, # ERR_NICKLOCKED, account is not available...
"903": self._saslsuccess, # We did a SASL!! woo yeah!! (RPL_SASLSUCCESS) "903": self._saslsuccess, # We did a SASL!! woo yeah!! (RPL_SASLSUCCESS)
"904": self._saslfail, # oh no,,, cringe,,, (ERR_SASLFAIL) "904": self._sasl_skill_issue, # oh no,,, cringe,,, (ERR_SASLFAIL)
"905": self._sasl_skill_issue, # ERR_SASLTOOLONG, we don't split so end.
"error": self._error, "error": self._error,
"join": self._join, "join": self._join,
"kick": self._kick, "kick": self._kick,
@ -1046,13 +1048,18 @@ class PesterIRC(QtCore.QThread):
password=self.mainwindow.userprofile.getNickServPass(), password=self.mainwindow.userprofile.getNickServPass(),
) )
def _saslfail(self, *_msg): def _sasl_skill_issue(self, *_msg):
"""Handle 'RPL_SASLSUCCESS' reply from server, SASL authentication succeeded! woo yeah!!""" """Handles all responses from server that indicate SASL authentication failed.
Replies that indicate we can't authenticate include: 902, 904, 905."""
if not self.registered_irc: if not self.registered_irc:
self._send_irc.authenticate(
"*"
) # Abort SASL, optional since we send cap END anyway.
self._send_irc.cap("END") self._send_irc.cap("END")
def _saslsuccess(self, *_msg): def _saslsuccess(self, *_msg):
"""Handle 'ERR_SASLFAIL' reply from server, SASL failed somehow.""" """Handle 'RPL_SASLSUCCESS' reply from server, SASL authentication succeeded! woo yeah!!"""
if not self.registered_irc: if not self.registered_irc:
self._send_irc.cap("END") self._send_irc.cap("END")

View file

@ -176,7 +176,8 @@ class SendIRC:
sasl_string_base64 = base64.b64encode(sasl_string_bytes).decode( sasl_string_base64 = base64.b64encode(sasl_string_bytes).decode(
encoding="utf-8" encoding="utf-8"
) )
# Woo yeah woo yeah # SASL string needs to be under 400 bytes,
# splitting over multiple messages is in the protocol but not implemented here.
self._send("AUTHENTICATE", text=sasl_string_base64) self._send("AUTHENTICATE", text=sasl_string_base64)