How to use the sasl.Sasl 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 apache / qpid-python / qpid / saslmech / external.py View on Github external
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

from sasl import Sasl


class EXTERNAL(Sasl):
  """Sasl mechanism used when SSL with client-auth is in use"""

  def prerequisitesOk(self):
    return True
github apache / qpid / python / qpid / saslmech / scram.py View on Github external
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

from hmac import HMAC
from binascii import b2a_hex
from sasl import Sasl
import os
import base64

class SCRAM_base(Sasl):

  def __init__(self, algorithm, user, password, name, sasl_options=None):
    Sasl.__init__(self, user, password, name, sasl_options)
    self.algorithm = algorithm
    self.client_nonce = b2a_hex(os.urandom(16))
    self.server_signature = None

  def initialResponse(self):
    name = self.user.replace("=","=3D").replace(",","=2C")
    self.client_first_message = "n=" + name + ",r=" + self.client_nonce
    return "n,," + self.client_first_message


  def response(self, challenge):
    if(self.server_signature):
      self.evaluateOutcome(challenge)
github apache / qpid / python / qpid / saslmech / amqplain.py View on Github external
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

from sasl import Sasl

class AMQPLAIN(Sasl):

  def initialResponse(self):
    return {"LOGIN": self.user, "PASSWORD": self.password}

  def priority(self):
    return 0
github apache / qpid / qpid / python / qpid / saslmech / amqplain.py View on Github external
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

from sasl import Sasl

class AMQPLAIN(Sasl):

  def initialResponse(self):
    return {"LOGIN": self.user, "PASSWORD": self.password}

  def priority(self):
    return 0
github apache / qpid-python / qpid / saslmech / amqplain.py View on Github external
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

from sasl import Sasl

class AMQPLAIN(Sasl):

  def initialResponse(self):
    return {"LOGIN": self.user, "PASSWORD": self.password}

  def priority(self):
    return 0
github apache / qpid-python / qpid / saslmech / cram_md5.py View on Github external
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

from sasl import Sasl
from hmac import HMAC

class CRAM_MD5(Sasl):

  def response(self, challenge):
    digest = HMAC( self.password, challenge).hexdigest()
    return "%s %s" % (self.user, digest)
github apache / qpid / python / qpid / saslmech / cram_md5_hex.py View on Github external
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

from sasl import Sasl
from hmac import HMAC
from hashlib import md5

class CRAM_MD5_HEX(Sasl):

  def response(self, challenge):
    m = md5()
    m.update(self.password)
    digest = HMAC( m.hexdigest(), challenge).hexdigest()
    return "%s %s" % (self.user, digest)
github apache / qpid / qpid / python / qpid / saslmech / cram_md5_hex.py View on Github external
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

from sasl import Sasl
from hmac import HMAC
from hashlib import md5

class CRAM_MD5_HEX(Sasl):

  def response(self, challenge):
    m = md5()
    m.update(self.password)
    digest = HMAC( m.hexdigest(), challenge).hexdigest()
    return "%s %s" % (self.user, digest)
github apache / qpid-python / qpid / saslmech / anonymous.py View on Github external
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

from sasl import Sasl

class ANONYMOUS(Sasl):

  def prerequisitesOk(self):
    return True