Merge branch 'master' into develop
This commit is contained in:
commit
e25a49f804
3 changed files with 13 additions and 15 deletions
|
@ -44,15 +44,16 @@ class FeatureMechanisms(BasePlugin):
|
|||
}
|
||||
|
||||
def plugin_init(self):
|
||||
if not self.use_mech and not self.xmpp.requested_jid.user:
|
||||
self.use_mech = 'ANONYMOUS'
|
||||
|
||||
if self.sasl_callback is None:
|
||||
self.sasl_callback = self._default_credentials
|
||||
|
||||
if self.security_callback is None:
|
||||
self.security_callback = self._default_security
|
||||
|
||||
creds = self.sasl_callback(set(['username']), set())
|
||||
if not self.use_mech and not creds['username']:
|
||||
self.use_mech = 'ANONYMOUS'
|
||||
|
||||
self.mech = None
|
||||
self.mech_list = set()
|
||||
self.attempted_mechs = set()
|
||||
|
@ -92,11 +93,7 @@ class FeatureMechanisms(BasePlugin):
|
|||
values = required_values.union(optional_values)
|
||||
for value in values:
|
||||
if value == 'username':
|
||||
result[value] = self.xmpp.requested_jid.user
|
||||
elif value == 'password':
|
||||
result[value] = creds['password']
|
||||
elif value == 'authzid':
|
||||
result[value] = creds.get('authzid', '')
|
||||
result[value] = creds.get('username', self.xmpp.requested_jid.user)
|
||||
elif value == 'email':
|
||||
jid = self.xmpp.requested_jid.bare
|
||||
result[value] = creds.get('email', jid)
|
||||
|
@ -106,13 +103,13 @@ class FeatureMechanisms(BasePlugin):
|
|||
else:
|
||||
result[value] = None
|
||||
elif value == 'host':
|
||||
result[value] = self.xmpp.requested_jid.domain
|
||||
result[value] = creds.get('host', self.xmpp.requested_jid.domain)
|
||||
elif value == 'realm':
|
||||
result[value] = self.xmpp.requested_jid.domain
|
||||
result[value] = creds.get('realm', self.xmpp.requested_jid.domain)
|
||||
elif value == 'service-name':
|
||||
result[value] = self.xmpp._service_name
|
||||
result[value] = creds.get('service-name', self.xmpp._service_name)
|
||||
elif value == 'service':
|
||||
result[value] = 'xmpp'
|
||||
result[value] = creds.get('service', 'xmpp')
|
||||
elif value in creds:
|
||||
result[value] = creds[value]
|
||||
return result
|
||||
|
|
|
@ -40,7 +40,7 @@ class Auth(StanzaBase):
|
|||
if not self['mechanism'] in self.plain_mechs:
|
||||
if values:
|
||||
self.xml.text = bytes(base64.b64encode(values)).decode('utf-8')
|
||||
else:
|
||||
elif values == b'':
|
||||
self.xml.text = '='
|
||||
else:
|
||||
self.xml.text = bytes(values).decode('utf-8')
|
||||
|
|
|
@ -467,7 +467,8 @@ class DIGEST(Mech):
|
|||
'qop': self.qop,
|
||||
'digest-uri': quote(self.digest_uri()),
|
||||
'response': self.response(b'AUTHENTICATE'),
|
||||
'maxbuf': self.maxbuf
|
||||
'maxbuf': self.maxbuf,
|
||||
'charset': 'utf-8'
|
||||
}
|
||||
resp = b''
|
||||
for key, value in data.items():
|
||||
|
@ -480,7 +481,7 @@ class DIGEST(Mech):
|
|||
if self.cnonce and self.nonce and self.nonce_count and self.qop:
|
||||
self.nonce_count += 1
|
||||
return self.respond()
|
||||
return b''
|
||||
return None
|
||||
|
||||
data = self.parse(challenge)
|
||||
if 'rspauth' in data:
|
||||
|
|
Loading…
Reference in a new issue