summaryrefslogtreecommitdiff
path: root/sleekxmpp/features
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-11-27 19:57:48 -0500
committerLance Stout <lancestout@gmail.com>2012-11-27 19:57:48 -0500
commite25a49f80444ff36ba1ee91059b4c3d74644d6ff (patch)
tree46f2acdaef728c25bbe65eb220a35d11fdffa531 /sleekxmpp/features
parent2d066c34fd58882901fea0d82c34ad37e312cd27 (diff)
parentb820351f6468e6718dc75b69a0088b2433a658af (diff)
downloadslixmpp-e25a49f80444ff36ba1ee91059b4c3d74644d6ff.tar.gz
slixmpp-e25a49f80444ff36ba1ee91059b4c3d74644d6ff.tar.bz2
slixmpp-e25a49f80444ff36ba1ee91059b4c3d74644d6ff.tar.xz
slixmpp-e25a49f80444ff36ba1ee91059b4c3d74644d6ff.zip
Merge branch 'master' into develop
Diffstat (limited to 'sleekxmpp/features')
-rw-r--r--sleekxmpp/features/feature_mechanisms/mechanisms.py21
-rw-r--r--sleekxmpp/features/feature_mechanisms/stanza/auth.py2
2 files changed, 10 insertions, 13 deletions
diff --git a/sleekxmpp/features/feature_mechanisms/mechanisms.py b/sleekxmpp/features/feature_mechanisms/mechanisms.py
index b480d5be..9f3c47f6 100644
--- a/sleekxmpp/features/feature_mechanisms/mechanisms.py
+++ b/sleekxmpp/features/feature_mechanisms/mechanisms.py
@@ -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
diff --git a/sleekxmpp/features/feature_mechanisms/stanza/auth.py b/sleekxmpp/features/feature_mechanisms/stanza/auth.py
index 7b665345..6b6f85a3 100644
--- a/sleekxmpp/features/feature_mechanisms/stanza/auth.py
+++ b/sleekxmpp/features/feature_mechanisms/stanza/auth.py
@@ -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')