How to use the sasl.Authenticator 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 / View on Github external
if not (user and get_user(
        raise NameError('User does not exist: %r.' % 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):
        return self._host

    def realm(self):
        return self._host

    def username(self):
        raise NotImplemented