Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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):
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)