How to use the sasl.auth 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 HenryHu / pybbs / xmppauth.py View on Github external
from UserManager import UserManager
import Session
from Log import Log
import sasl

class XMPPAuth(sasl.auth.Authenticator):
    """To authenticate XMPP users.
    Plan to support 2 methods:
        PLAIN: just username & password
        X-BBS-OAUTH: use OAuth token
    """

    def __init__(self, service_type, host, service_name):
        self._service_type = service_type
        self._host = host
        self._service_name = service_name
        self._username = None

    def service_type(self):
        return self._service_type

    def host(self):
github HenryHu / pybbs / bbsauth.py View on Github external
def verify_challenge(self, entity, response):
        try:
            token = response.decode('utf-8')
        except ValueError as exc:
            return self.state(False, entity, None)

        try:
            result = self.verify(token)
            if result:
                entity = entity or self.auth.username()
            return self.state(result, entity, None)
        except auth.PasswordError as exc:
            return self.state(False, entity, None)