Skip to content
Back to top
View this page

# XEP-0077: In-Band Registration

class slixmpp.plugins.xep_0077.XEP_0077(xmpp, config=None)

  XEP-0077: In-Band Registration

  Events:

      user_register           -- After successful validation and add to the user store
                                 in api["user_validate"]
      user_unregister         -- After successful 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 overridden.

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

## Stanza elements

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

  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']

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

  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']