mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-24 03:00:15 +00:00
Add an extra config dict to store SASL credentials.
We'll need extra things beyond just a password, such as api_key.
This commit is contained in:
parent
02f4006153
commit
0d2125e737
2 changed files with 24 additions and 7 deletions
|
@ -74,12 +74,15 @@ class ClientXMPP(BaseXMPP):
|
||||||
BaseXMPP.__init__(self, jid, 'jabber:client')
|
BaseXMPP.__init__(self, jid, 'jabber:client')
|
||||||
|
|
||||||
self.set_jid(jid)
|
self.set_jid(jid)
|
||||||
self.password = password
|
|
||||||
self.escape_quotes = escape_quotes
|
self.escape_quotes = escape_quotes
|
||||||
self.plugin_config = plugin_config
|
self.plugin_config = plugin_config
|
||||||
self.plugin_whitelist = plugin_whitelist
|
self.plugin_whitelist = plugin_whitelist
|
||||||
self.default_port = 5222
|
self.default_port = 5222
|
||||||
|
|
||||||
|
self.credentials = {}
|
||||||
|
|
||||||
|
self.password = password
|
||||||
|
|
||||||
self.stream_header = "<stream:stream to='%s' %s %s version='1.0'>" % (
|
self.stream_header = "<stream:stream to='%s' %s %s version='1.0'>" % (
|
||||||
self.boundjid.host,
|
self.boundjid.host,
|
||||||
"xmlns:stream='%s'" % self.stream_ns,
|
"xmlns:stream='%s'" % self.stream_ns,
|
||||||
|
@ -119,6 +122,14 @@ class ClientXMPP(BaseXMPP):
|
||||||
self.register_plugin('feature_mechanisms',
|
self.register_plugin('feature_mechanisms',
|
||||||
pconfig={'use_mech': sasl_mech} if sasl_mech else None)
|
pconfig={'use_mech': sasl_mech} if sasl_mech else None)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def password(self):
|
||||||
|
return self.credentials.get('password', '')
|
||||||
|
|
||||||
|
@password.setter
|
||||||
|
def password(self, value):
|
||||||
|
self.credentials['password'] = value
|
||||||
|
|
||||||
def connect(self, address=tuple(), reattempt=True,
|
def connect(self, address=tuple(), reattempt=True,
|
||||||
use_tls=True, use_ssl=False):
|
use_tls=True, use_ssl=False):
|
||||||
"""Connect to the XMPP server.
|
"""Connect to the XMPP server.
|
||||||
|
|
|
@ -35,12 +35,18 @@ class feature_mechanisms(base_plugin):
|
||||||
return 'starttls' in self.xmpp.features
|
return 'starttls' in self.xmpp.features
|
||||||
|
|
||||||
def basic_callback(mech, values):
|
def basic_callback(mech, values):
|
||||||
if 'username' in values:
|
for value in values:
|
||||||
|
if value == 'username':
|
||||||
values['username'] = self.xmpp.boundjid.user
|
values['username'] = self.xmpp.boundjid.user
|
||||||
if 'password' in values:
|
elif value == 'password':
|
||||||
values['password'] = self.xmpp.password
|
values['password'] = self.xmpp.credentials['password']
|
||||||
if 'access_token' in values:
|
elif value == 'access_token':
|
||||||
values['access_token'] = self.xmpp.password
|
if 'access_token' in self.xmpp.credentials:
|
||||||
|
values['access_token'] = self.xmpp.credentials['access_token']
|
||||||
|
else:
|
||||||
|
values['access_token'] = self.xmpp.credentials['password']
|
||||||
|
elif value in self.xmpp.credentials:
|
||||||
|
values[value] = self.xmpp.credentials[value]
|
||||||
mech.fulfill(values)
|
mech.fulfill(values)
|
||||||
|
|
||||||
sasl_callback = self.config.get('sasl_callback', None)
|
sasl_callback = self.config.get('sasl_callback', None)
|
||||||
|
|
Loading…
Reference in a new issue