Add debug logging when skipping SASL mechanisms

It is useful to figure out what you forgot to configure
This commit is contained in:
Valentin Lorentz 2022-07-29 10:03:39 +02:00
parent f549ec12c6
commit ee60431396
1 changed files with 35 additions and 14 deletions

View File

@ -1731,20 +1731,41 @@ class Irc(IrcCommandDispatcher, log.Firewalled):
self.sasl_current_mechanism = None self.sasl_current_mechanism = None
for mechanism in network_config.sasl.mechanisms(): for mechanism in network_config.sasl.mechanisms():
if mechanism == 'ecdsa-nist256p-challenge' and \ if mechanism == 'ecdsa-nist256p-challenge':
crypto and self.sasl_username and \ if not crypto:
self.sasl_ecdsa_key: log.debug('Skipping SASL %s, crypto module '
self.sasl_next_mechanisms.append(mechanism) 'is not available',
elif mechanism == 'external' and ( mechanism)
network_config.certfile() or elif not self.sasl_username or not self.sasl_ecdsa_key:
conf.supybot.protocols.irc.certfile()): log.debug('Skipping SASL %s, missing username and/or key',
self.sasl_next_mechanisms.append(mechanism) mechanism)
elif mechanism.startswith('scram-') and scram and \ else:
self.sasl_username and self.sasl_password: self.sasl_next_mechanisms.append(mechanism)
self.sasl_next_mechanisms.append(mechanism) elif mechanism == 'external':
elif mechanism == 'plain' and \ if not network_config.certfile() and \
self.sasl_username and self.sasl_password: not conf.supybot.protocols.irc.certfile():
self.sasl_next_mechanisms.append(mechanism) log.debug('Skipping SASL %s, missing cert file',
mechanism)
else:
self.sasl_next_mechanisms.append(mechanism)
elif mechanism.startswith('scram-'):
if not scram:
log.debug('Skipping SASL %s, scram module '
'is not available',
mechanism)
elif not self.sasl_username or not self.sasl_password:
log.debug('Skipping SASL %s, missing username and/or '
'password',
mechanism)
else:
self.sasl_next_mechanisms.append(mechanism)
elif mechanism == 'plain':
if not self.sasl_username or not self.sasl_password:
log.debug('Skipping SASL %s, missing username and/or '
'password',
mechanism)
else:
self.sasl_next_mechanisms.append(mechanism)
if self.sasl_next_mechanisms: if self.sasl_next_mechanisms:
self.REQUEST_CAPABILITIES.add('sasl') self.REQUEST_CAPABILITIES.add('sasl')