summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0078/legacyauth.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-10-01 16:27:55 -0700
committerLance Stout <lancestout@gmail.com>2012-10-01 16:27:55 -0700
commit657102e938aeb385cd44daf3cc213a40d58c36fa (patch)
tree75691dd1ff76db43131d1d4b0b029ea054b3b964 /sleekxmpp/plugins/xep_0078/legacyauth.py
parent94488fa2ea4dac7ff6fce20621d2e80e700f6299 (diff)
downloadslixmpp-657102e938aeb385cd44daf3cc213a40d58c36fa.tar.gz
slixmpp-657102e938aeb385cd44daf3cc213a40d58c36fa.tar.bz2
slixmpp-657102e938aeb385cd44daf3cc213a40d58c36fa.tar.xz
slixmpp-657102e938aeb385cd44daf3cc213a40d58c36fa.zip
Update legacy auth to be used outside of stream features.
Also, add detection of legacy XMPP version.
Diffstat (limited to 'sleekxmpp/plugins/xep_0078/legacyauth.py')
-rw-r--r--sleekxmpp/plugins/xep_0078/legacyauth.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/sleekxmpp/plugins/xep_0078/legacyauth.py b/sleekxmpp/plugins/xep_0078/legacyauth.py
index 5c4045d8..89716e18 100644
--- a/sleekxmpp/plugins/xep_0078/legacyauth.py
+++ b/sleekxmpp/plugins/xep_0078/legacyauth.py
@@ -44,16 +44,27 @@ class XEP_0078(BasePlugin):
restart=False,
order=self.order)
+ self.xmpp.add_event_handler('legacy_protocol',
+ self._handle_legacy_protocol)
+
register_stanza_plugin(Iq, stanza.IqAuth)
register_stanza_plugin(StreamFeatures, stanza.AuthFeature)
def plugin_end(self):
+ self.xmpp.del_event_handler('legacy_protocol',
+ self._handle_legacy_protocol)
self.xmpp.unregister_feature('auth', self.order)
def _handle_auth(self, features):
# If we can or have already authenticated with SASL, do nothing.
if 'mechanisms' in features['features']:
return False
+ return self.authenticate()
+
+ def _handle_legacy_protocol(self, event):
+ self.authenticate()
+
+ def authenticate(self):
if self.xmpp.authenticated:
return False
@@ -62,8 +73,8 @@ class XEP_0078(BasePlugin):
# Step 1: Request the auth form
iq = self.xmpp.Iq()
iq['type'] = 'get'
- iq['to'] = self.xmpp.boundjid.host
- iq['auth']['username'] = self.xmpp.boundjid.user
+ iq['to'] = self.xmpp.requested_jid.host
+ iq['auth']['username'] = self.xmpp.requested_jid.user
try:
resp = iq.send(now=True)
@@ -81,11 +92,11 @@ class XEP_0078(BasePlugin):
# Step 2: Fill out auth form for either password or digest auth
iq = self.xmpp.Iq()
iq['type'] = 'set'
- iq['auth']['username'] = self.xmpp.boundjid.user
+ iq['auth']['username'] = self.xmpp.requested_jid.user
# A resource is required, so create a random one if necessary
- if self.xmpp.boundjid.resource:
- iq['auth']['resource'] = self.xmpp.boundjid.resource
+ if self.xmpp.requested_jid.resource:
+ iq['auth']['resource'] = self.xmpp.requested_jid.resource
else:
iq['auth']['resource'] = '%s' % random.random()