diff options
author | Florent Le Coz <louiz@louiz.org> | 2010-10-17 02:26:06 +0800 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2010-10-17 08:55:30 +0800 |
commit | 2d18d905a537587ee9685877ae2c108511e57d91 (patch) | |
tree | a8e987b04525d80f1325653ddc3898b440600adc /sleekxmpp/clientxmpp.py | |
parent | 4eb4d729eebd8049d68a944120360cb1f7e68895 (diff) | |
download | slixmpp-2d18d905a537587ee9685877ae2c108511e57d91.tar.gz slixmpp-2d18d905a537587ee9685877ae2c108511e57d91.tar.bz2 slixmpp-2d18d905a537587ee9685877ae2c108511e57d91.tar.xz slixmpp-2d18d905a537587ee9685877ae2c108511e57d91.zip |
Anonymous authentication
Implemented ANONYMOUS authentication on the ClientXMPP class.
To use it, you just need to provide a domain (e.g 'anon.example.com')
with an optional resource (e.g 'anon.example.com/resource') as the JID,
with no password. The JID class has been improved to accept
domains as fulljid.
You can test this with echo_client.py
python echo_client.py -j anon.louiz.org/ # anonymous with a resource
# defined by the server
python echo_client.py -j anon.louiz.org/resource # anonymous with given
# resource
The "normal" authentication method still works exactly like before.
Diffstat (limited to 'sleekxmpp/clientxmpp.py')
-rw-r--r-- | sleekxmpp/clientxmpp.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sleekxmpp/clientxmpp.py b/sleekxmpp/clientxmpp.py index 7d000bfa..9655ebab 100644 --- a/sleekxmpp/clientxmpp.py +++ b/sleekxmpp/clientxmpp.py @@ -304,7 +304,7 @@ class ClientXMPP(BaseXMPP): if sasl_mechs: for sasl_mech in sasl_mechs: self.features.append("sasl:%s" % sasl_mech.text) - if 'sasl:PLAIN' in self.features: + if 'sasl:PLAIN' in self.features and self.boundjid.user: if sys.version_info < (3, 0): user = bytes(self.username) password = bytes(self.password) @@ -318,6 +318,8 @@ class ClientXMPP(BaseXMPP): self.send("<auth xmlns='%s' mechanism='PLAIN'>%s</auth>" % ( sasl_ns, auth)) + elif 'sasl:ANONYMOUS' in self.features and not self.boundjid.user: + self.send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS' />") else: logging.error("No appropriate login method.") self.disconnect() |