From c433f051909ba82261a1b816d9ca76f001d2a51d Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 10 Sep 2018 22:48:49 +0200 Subject: [PATCH] Add a config var to require SASL auth when connecting. --- src/conf.py | 3 +++ src/irclib.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/conf.py b/src/conf.py index 112a2b0a4..100743d42 100644 --- a/src/conf.py +++ b/src/conf.py @@ -383,6 +383,9 @@ def registerNetwork(name, password='', ssl=True, sasl_username='', registerGlobalValue(sasl, 'mechanisms', SpaceSeparatedListOfSaslMechanisms( ['ecdsa-nist256p-challenge', 'external', 'plain'], _("""Determines what SASL mechanisms will be tried and in which order."""))) + registerGlobalValue(sasl, 'required', registry.Boolean(False, + _("""Determines whether the bot will abort the connection if the + none of the enabled SASL mechanism succeeded."""))) registerGlobalValue(network, 'socksproxy', registry.String('', _("""If not empty, determines the hostname of the socks proxy that will be used to connect to this network."""))) diff --git a/src/irclib.py b/src/irclib.py index a18990484..078176e14 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -1081,6 +1081,9 @@ class Irc(IrcCommandDispatcher, log.Firewalled): self.sasl_current_mechanism = self.sasl_next_mechanisms.pop(0) self.sendMsg(ircmsgs.IrcMsg(command='AUTHENTICATE', args=(self.sasl_current_mechanism.upper(),))) + elif conf.supybot.networks.get(self.network).sasl.required(): + log.error('None of the configured SASL mechanisms succeeded, ' + 'aborting connection.') else: self.sasl_current_mechanism = None self.endCapabilityNegociation()