How to use the sasl.DigestMD5Password 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 _client(self, user, pwd):
        return sasl.SimpleAuth(
            sasl.DigestMD5Password,
            {},
            lambda: user,
            lambda: pwd,
            lambda: authenticator().service_type(),
            lambda: authenticator().host()
        )
github thisismedium / python-xmpp-server / xmpp / application.py View on Github external
def ClientAuth(serv_type, host, username, password):

    return sasl.SimpleAuth(
        sasl.DigestMD5Password,
        {},
        lambda: username,
        lambda: password,
        lambda: serv_type,
        lambda: host
    )
github thisismedium / message-db / mdb / db / auth.py View on Github external
return user

def save_user(user, *args, **kw):
    if not user:
        raise NameError('User does not exist: %r.' % user)
    return api.update(user.update(*args, **kw))

def remove_user(user):
    if not (user and get_user(user.name)):
        raise NameError('User does not exist: %r.' % user)
    api.delete(user)


### Authentication

PASSWORD_TYPE = sasl.DigestMD5Password

def make_password(name, passwd):
    auth = authenticator()
    if not auth:
        raise ValueError('No active authenticator.')
    return password(PASSWORD_TYPE.make(auth, name, passwd))

class LocalAuth(sasl.Authenticator):
    def __init__(self, service=None, host=None):
        self._service = service or 'xmpp'
        self._host = host or get_host()

    def service_type(self):
        return self._service

    def host(self):
github thisismedium / python-xmpp-server / xmpp / application.py View on Github external
def ServerAuth(serv_type, host, users):

    def user():
        raise NotImplementedError

    def password():
        raise NotImplementedError

    def get_host():
        return host

    return sasl.SimpleAuth(
        sasl.DigestMD5Password,
        users,
        user,
        password,
        lambda: serv_type,
        get_host,
        realm=get_host
    )