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