XEP-0077: In-Band Registration¶
- class slixmpp.plugins.xep_0077.XEP_0077(xmpp, config=None)[source]¶
XEP-0077: In-Band Registration
Events:
user_register -- After succesful validation and add to the user store in api["user_validate"] user_unregister -- After succesful user removal in api["user_remove"]
Config:
form_fields are only form_instructions are only used for component registration in case api["make_registration_form"] is not overriden.
API:
user_get(jid, node, ifrom, iq) Returns a dict-like object containing `form_fields` for this user or None user_remove(jid, node, ifrom, iq) Removes a user or raise KeyError in case the user is not found in the user store make_registration_form(self, jid, node, ifrom, iq) Returns an iq reply to a registration form request, pre-filled and with <registered/> in case the requesting entity is already registered to us user_validate((self, jid, node, ifrom, registration) Add the user to the user store or raise ValueError(msg) if any problem is encountered msg is sent back to the XMPP client as an error message.
- default_config: ClassVar[Dict[str, Any]] = {'create_account': True, 'force_registration': False, 'form_fields': {'password', 'username'}, 'form_instructions': 'Enter your credentials', 'order': 50}¶
The basic, standard configuration for the plugin, which may be overridden when initializing the plugin. The configuration fields included here may be accessed directly as attributes of the plugin. For example, including the configuration field ‘foo’ would mean accessing plugin.foo returns the current value of plugin.config[‘foo’].
- dependencies: ClassVar[Set[str]] = {'xep_0004', 'xep_0066'}¶
Some plugins may depend on others in order to function properly. Any plugin names included in
dependencies
will be initialized as needed if this plugin is enabled.
- description: str = 'XEP-0077: In-Band Registration'¶
A longer name for the plugin, describing its purpose. For example, a plugin for XEP-0030 would use ‘Service Discovery’ as its description value.
- name: str = 'xep_0077'¶
A short name for the plugin based on the implemented specification. For example, a plugin for XEP-0030 would use ‘xep_0030’.
Internal APi methods¶
The API here is made to allow components to manage registered users. The default handlers make use of the plugin options and store users in memory.
- user_get¶
jid: unused
node: unused
ifrom: who the request is coming from
args:
Iq
registration request.returns:
dict
containing user data or None.
Get user data for a user.
- user_validate¶
jid: unused
node: unused
ifrom: who the request is coming from
args:
Iq
registration request, ‘register’ payload.raises: ValueError if some fields are invalid
Validate form fields and save user data.
- user_remove¶
jid: unused
node: unused
ifrom: who the request is coming from
args:
Iq
registration removal request.raises: KeyError if the user is not found.
Remove a user from the store.
- make_registration_form¶
jid: unused
node: unused
ifrom: who the request is coming from
args:
Iq
registration request.raises: KeyError if the user is not found.
Return an
Iq
reply for the request, with a form and options set. By default, useform_fields
andform_instructions
plugin config options.
Stanza elements¶
- class slixmpp.plugins.xep_0077.stanza.Register(xml=None, parent=None)[source]¶
-
- form_fields = {'address', 'city', 'date', 'email', 'first', 'key', 'last', 'misc', 'name', 'nick', 'password', 'phone', 'state', 'text', 'url', 'username', 'zip'}¶
- interfaces: ClassVar[Set[str]] = {'address', 'city', 'date', 'email', 'fields', 'first', 'instructions', 'key', 'last', 'misc', 'name', 'nick', 'password', 'phone', 'registered', 'remove', 'state', 'text', 'url', 'username', 'zip'}¶
The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the
plugin_attrib
value of any registered stanza plugins.
- name: ClassVar[str] = 'query'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBase
object for<message />
would usename = 'message'
.
- namespace: str = 'jabber:iq:register'¶
The XML namespace for the element. Given
<foo xmlns="bar" />
, thennamespace = "bar"
should be used. The default namespace isjabber:client
since this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'register'¶
For
ElementBase
subclasses which are intended to be used as plugins, theplugin_attrib
value defines the plugin name. Plugins may be accessed by using theplugin_attrib
value as the interface. An example usingplugin_attrib = 'foo'
:register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- sub_interfaces: ClassVar[Set[str]] = {'address', 'city', 'date', 'email', 'fields', 'first', 'instructions', 'key', 'last', 'misc', 'name', 'nick', 'password', 'phone', 'registered', 'remove', 'state', 'text', 'url', 'username', 'zip'}¶
A subset of
interfaces
which maps interfaces to direct subelements of the underlying XML object. Using this set, the text of these subelements may be set, retrieved, or removed without needing to define custom methods.
- class slixmpp.plugins.xep_0077.stanza.RegisterFeature(xml=None, parent=None)[source]¶
- interfaces: ClassVar[Set[str]] = {}¶
The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the
plugin_attrib
value of any registered stanza plugins.
- name: ClassVar[str] = 'register'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBase
object for<message />
would usename = 'message'
.
- namespace: str = 'http://jabber.org/features/iq-register'¶
The XML namespace for the element. Given
<foo xmlns="bar" />
, thennamespace = "bar"
should be used. The default namespace isjabber:client
since this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'register'¶
For
ElementBase
subclasses which are intended to be used as plugins, theplugin_attrib
value defines the plugin name. Plugins may be accessed by using theplugin_attrib
value as the interface. An example usingplugin_attrib = 'foo'
:register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']