mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-20 17:53:03 +01:00
Merge pull request #826 from nyuszika7h/sasl-external
Add support for SASL EXTERNAL
This commit is contained in:
commit
06b865597f
@ -941,15 +941,21 @@ class Irc(IrcCommandDispatcher):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
sasl = self.sasl_username and self.sasl_password
|
self.sasl = None
|
||||||
|
|
||||||
if sasl:
|
if (conf.supybot.networks.get(self.network).certfile() or
|
||||||
|
conf.supybot.protocols.irc.certfile()):
|
||||||
|
self.sasl = 'external'
|
||||||
|
elif self.sasl_username and self.sasl_password:
|
||||||
|
self.sasl = 'plain'
|
||||||
|
|
||||||
|
if self.sasl:
|
||||||
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('REQ', 'sasl')))
|
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('REQ', 'sasl')))
|
||||||
|
|
||||||
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('REQ', 'account-notify')))
|
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('REQ', 'account-notify')))
|
||||||
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('REQ', 'extended-join')))
|
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('REQ', 'extended-join')))
|
||||||
|
|
||||||
if not sasl:
|
if not self.sasl:
|
||||||
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('END',)))
|
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('END',)))
|
||||||
|
|
||||||
if self.password:
|
if self.password:
|
||||||
@ -972,11 +978,14 @@ class Irc(IrcCommandDispatcher):
|
|||||||
if len(msg.args) == 1 and msg.args[0] == '+':
|
if len(msg.args) == 1 and msg.args[0] == '+':
|
||||||
log.info('%s: Authenticating using SASL.', self.network)
|
log.info('%s: Authenticating using SASL.', self.network)
|
||||||
|
|
||||||
authstring = base64.b64encode('\0'.join([
|
if self.sasl == 'external':
|
||||||
self.sasl_username,
|
authstring = '+'
|
||||||
self.sasl_username,
|
elif self.sasl == 'plain':
|
||||||
self.sasl_password
|
authstring = base64.b64encode('\0'.join([
|
||||||
]).encode('utf-8')).decode('utf-8')
|
self.sasl_username,
|
||||||
|
self.sasl_username,
|
||||||
|
self.sasl_password
|
||||||
|
]).encode('utf-8')).decode('utf-8')
|
||||||
|
|
||||||
self.queueMsg(ircmsgs.IrcMsg(command='AUTHENTICATE', args=(authstring,)))
|
self.queueMsg(ircmsgs.IrcMsg(command='AUTHENTICATE', args=(authstring,)))
|
||||||
|
|
||||||
@ -988,8 +997,9 @@ class Irc(IrcCommandDispatcher):
|
|||||||
self.network, cap)
|
self.network, cap)
|
||||||
|
|
||||||
if cap == 'sasl':
|
if cap == 'sasl':
|
||||||
self.queueMsg(ircmsgs.IrcMsg(command='AUTHENTICATE',
|
self.queueMsg(ircmsgs.IrcMsg(
|
||||||
args=('PLAIN',)))
|
command='AUTHENTICATE',
|
||||||
|
args=(self.sasl.upper(),)))
|
||||||
elif msg.args[1] == 'NAK':
|
elif msg.args[1] == 'NAK':
|
||||||
log.warning('%s: Server refused capability %r',
|
log.warning('%s: Server refused capability %r',
|
||||||
self.network, cap)
|
self.network, cap)
|
||||||
@ -999,8 +1009,18 @@ class Irc(IrcCommandDispatcher):
|
|||||||
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('END',)))
|
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('END',)))
|
||||||
|
|
||||||
def do904(self, msg):
|
def do904(self, msg):
|
||||||
log.warning('%s: SASL authentication failed', self.network)
|
if (self.sasl == 'external' and self.sasl_username and
|
||||||
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('END',)))
|
self.sasl_password):
|
||||||
|
self.log.info('%s: SASL EXTERNAL failed, trying PLAIN.',
|
||||||
|
self.network)
|
||||||
|
|
||||||
|
self.sasl = 'plain'
|
||||||
|
|
||||||
|
self.queueMsg(ircmsgs.IrcMsg(
|
||||||
|
command='AUTHENTICATE', args=(self.sasl.upper(),)))
|
||||||
|
else:
|
||||||
|
log.warning('%s: SASL authentication failed', self.network)
|
||||||
|
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('END',)))
|
||||||
|
|
||||||
def do905(self, msg):
|
def do905(self, msg):
|
||||||
log.warning('%s: SASL authentication failed because the username or '
|
log.warning('%s: SASL authentication failed because the username or '
|
||||||
|
Loading…
Reference in New Issue
Block a user