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.

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, use form_fields and form_instructions plugin config options.

Stanza elements#

class slixmpp.plugins.xep_0077.stanza.Register(xml=None, parent=None)[source]#
add_field(value)[source]#
del_fields()[source]#
form_fields = {'address', 'city', 'date', 'email', 'first', 'key', 'last', 'misc', 'name', 'nick', 'password', 'phone', 'state', 'text', 'url', 'username', 'zip'}#
get_fields()[source]#
get_registered()[source]#
get_remove()[source]#
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.

iterables: List[ElementBase]#

A list of child stanzas whose class is included in plugin_iterables.

loaded_plugins: Set[str]#
name: ClassVar[str] = 'query'#

The XML tag name of the element, not including any namespace prefixes. For example, an ElementBase object for <message /> would use name = 'message'.

namespace: str = 'jabber:iq:register'#

The XML namespace for the element. Given <foo xmlns="bar" />, then namespace = "bar" should be used. The default namespace is jabber:client since this is being used in an XMPP library.

parent: Optional[ReferenceType[ElementBase]]#

A weakref.weakref to the parent stanza, if there is one. If not, then parent is None.

plugin_attrib: ClassVar[str] = 'register'#

For ElementBase subclasses which are intended to be used as plugins, the plugin_attrib value defines the plugin name. Plugins may be accessed by using the plugin_attrib value as the interface. An example using plugin_attrib = 'foo':

register_stanza_plugin(Message, FooPlugin)
msg = Message()
msg['foo']['an_interface_from_the_foo_plugin']
plugins: Dict[Tuple[str, Optional[str]], ElementBase]#

An ordered dictionary of plugin stanzas, mapped by their plugin_attrib value.

set_fields(fields)[source]#
set_registered(value)[source]#
set_remove(value)[source]#
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.

tag: str#

The name of the tag for the stanza’s root element. It is the same as calling tag_name() and is formatted as '{namespace}elementname'.

xml: ET.Element#

The underlying XML object for the stanza. It is a standard xml.etree.ElementTree object.

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.

iterables: List[ElementBase]#

A list of child stanzas whose class is included in plugin_iterables.

loaded_plugins: Set[str]#
name: ClassVar[str] = 'register'#

The XML tag name of the element, not including any namespace prefixes. For example, an ElementBase object for <message /> would use name = 'message'.

namespace: str = 'http://jabber.org/features/iq-register'#

The XML namespace for the element. Given <foo xmlns="bar" />, then namespace = "bar" should be used. The default namespace is jabber:client since this is being used in an XMPP library.

parent: Optional[ReferenceType[ElementBase]]#

A weakref.weakref to the parent stanza, if there is one. If not, then parent is None.

plugin_attrib: ClassVar[str] = 'register'#

For ElementBase subclasses which are intended to be used as plugins, the plugin_attrib value defines the plugin name. Plugins may be accessed by using the plugin_attrib value as the interface. An example using plugin_attrib = 'foo':

register_stanza_plugin(Message, FooPlugin)
msg = Message()
msg['foo']['an_interface_from_the_foo_plugin']
plugins: Dict[Tuple[str, Optional[str]], ElementBase]#

An ordered dictionary of plugin stanzas, mapped by their plugin_attrib value.

tag: str#

The name of the tag for the stanza’s root element. It is the same as calling tag_name() and is formatted as '{namespace}elementname'.

xml: ET.Element#

The underlying XML object for the stanza. It is a standard xml.etree.ElementTree object.