How to use the sasl.mechanism 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 / bbsauth.py View on Github external
__all__ = ('BBSAuth')

class BBSAuth(mech.Mechanism):
    """The bbsauth mechanism simply submits the optional authorization
    id, the authentication id, and token separated by null
    bytes."""

    NULL = u'\x00'

    def __init__(self, auth):
        self.auth = auth

    def verify(self, *args):
        return self.auth.verify_token(*args)

    state = mech.AuthState

    ## Server

    def challenge(self):
        return self.state(self.verify_challenge, None, '')

    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()
github HenryHu / pybbs / bbsauth.py View on Github external
"""bbsauth -- verifies session token



Copyright (c) 2009, Coptix, Inc.  All rights reserved.
See the LICENSE file for license terms and warranty disclaimer.
"""
from __future__ import absolute_import
from sasl import mechanism as mech, auth

__all__ = ('BBSAuth')

class BBSAuth(mech.Mechanism):
    """The bbsauth mechanism simply submits the optional authorization
    id, the authentication id, and token separated by null
    bytes."""

    NULL = u'\x00'

    def __init__(self, auth):
        self.auth = auth

    def verify(self, *args):
        return self.auth.verify_token(*args)

    state = mech.AuthState

    ## Server