mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-19 00:22:50 +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,6 +978,9 @@ 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)
|
||||||
|
|
||||||
|
if self.sasl == 'external':
|
||||||
|
authstring = '+'
|
||||||
|
elif self.sasl == 'plain':
|
||||||
authstring = base64.b64encode('\0'.join([
|
authstring = base64.b64encode('\0'.join([
|
||||||
self.sasl_username,
|
self.sasl_username,
|
||||||
self.sasl_username,
|
self.sasl_username,
|
||||||
@ -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,6 +1009,16 @@ 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):
|
||||||
|
if (self.sasl == 'external' and self.sasl_username and
|
||||||
|
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)
|
log.warning('%s: SASL authentication failed', self.network)
|
||||||
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('END',)))
|
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('END',)))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user