How to use the sasl.DigestMD5 function in sasl

To help you get started, we’ve selected a few sasl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thisismedium / message-db / mdb / db / tests.py View on Github external
def _login(self, user, pwd, mech=None):
        client = self._client(user, pwd)
        mech = mech or sasl.DigestMD5
        return self._negotiate(mech(authenticator()), mech(client))
github thisismedium / python-xmpp-server / xmpp / features.py View on Github external
## ---------- 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,