Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _login(self, user, pwd, mech=None):
client = self._client(user, pwd)
mech = mech or sasl.DigestMD5
return self._negotiate(mech(authenticator()), mech(client))
## ---------- Common ----------
def negotiate(self):
self.starttls(self.done, **self.options)
def done(self):
self._active = False
self.trigger(StreamSecured).reset_stream()
### SASL
class Mechanisms(plugin.Feature):
__xmlns__ = 'urn:ietf:params:xml:ns:xmpp-sasl'
DEFAULT_MECHANISMS = (sasl.Plain, sasl.DigestMD5)
def __init__(self, auth, mechanisms=None):
self.auth = auth
self.mechanisms = mechanisms or self.DEFAULT_MECHANISMS
self.jid = None
def active(self):
return not self.jid
## ---------- Server ----------
def include(self):
self.bind(
auth=self.begin,
abort=self.terminate,
success=self.terminate,