Simplify SASL mech registration.
Moved SASL registration completely to the feature plugin, instead of keeping a portion of it in ClientXMPP.
This commit is contained in:
@@ -51,7 +51,7 @@ class feature_mechanisms(base_plugin):
|
||||
restart=True,
|
||||
order=self.config.get('order', 100))
|
||||
|
||||
def register_mechanism(self, name, handler, priority=0):
|
||||
def register(self, name, handler, priority=0):
|
||||
"""
|
||||
Register a handler for a SASL authentication mechanism.
|
||||
|
||||
@@ -70,7 +70,7 @@ class feature_mechanisms(base_plugin):
|
||||
self._mechanism_priorities.append((priority, name))
|
||||
self._mechanism_priorities.sort(reverse=True)
|
||||
|
||||
def remove_mechanism(self, name):
|
||||
def remove(self, name):
|
||||
"""
|
||||
Remove support for a given SASL authentication mechanism.
|
||||
|
||||
|
||||
@@ -14,8 +14,9 @@ class sasl_anonymous(base_plugin):
|
||||
self.name = 'SASL ANONYMOUS'
|
||||
self.rfc = '6120'
|
||||
self.description = 'SASL ANONYMOUS Mechanism'
|
||||
self.stanza = self.xmpp['feature_mechanisms'].stanza
|
||||
|
||||
self.xmpp.register_sasl_mechanism('ANONYMOUS',
|
||||
self.xmpp['feature_mechanisms'].register('ANONYMOUS',
|
||||
self._handle_anonymous,
|
||||
priority=self.config.get('priority', 0))
|
||||
|
||||
@@ -23,7 +24,7 @@ class sasl_anonymous(base_plugin):
|
||||
if self.xmpp.boundjid.user:
|
||||
return False
|
||||
|
||||
resp = self.xmpp['feature_sasl'].stanza.Auth(self.xmpp)
|
||||
resp = self.stanza.Auth(self.xmpp)
|
||||
resp['mechanism'] = 'ANONYMOUS'
|
||||
resp.send(now=True)
|
||||
|
||||
|
||||
@@ -14,8 +14,9 @@ class sasl_plain(base_plugin):
|
||||
self.name = 'SASL PLAIN'
|
||||
self.rfc = '6120'
|
||||
self.description = 'SASL PLAIN Mechanism'
|
||||
self.stanza = self.xmpp['feature_mechanisms'].stanza
|
||||
|
||||
self.xmpp.register_sasl_mechanism('PLAIN',
|
||||
self.xmpp['feature_mechanisms'].register('PLAIN',
|
||||
self._handle_plain,
|
||||
priority=self.config.get('priority', 1))
|
||||
|
||||
@@ -33,7 +34,7 @@ class sasl_plain(base_plugin):
|
||||
auth = base64.b64encode(b'\x00' + user + \
|
||||
b'\x00' + password).decode('utf-8')
|
||||
|
||||
resp = self.xmpp['feature_mechanisms'].stanza.Auth(self.xmpp)
|
||||
resp = self.stanza.Auth(self.xmpp)
|
||||
resp['mechanism'] = 'PLAIN'
|
||||
resp['value'] = auth
|
||||
resp.send(now=True)
|
||||
|
||||
Reference in New Issue
Block a user