XEP-0193: Proposed Resource Binding Improvements

This document proposes improvements to the definition of resource binding for inclusion in the specification that supersedes RFC 3920.


NOTICE: This document is currently within Last Call or under consideration by the XMPP Council for advancement to the next stage in the JSF standards process.


Document Information

Status: Proposed
Type: Standards Track
Number: 0193
Version: 0.2
Last Updated: 2007-01-02
Publishing Organization: Jabber Software Foundation
Approving Body: XMPP Council
Dependencies: XMPP Core
Supersedes: None
Superseded By: None
Short Name: N/A
Wiki Page: <http://wiki.jabber.org/index.php/Proposed Resource Binding Improvements (XEP-0193)>

Author Information

Peter Saint-Andre

Email: stpeter@jabber.org
JID: stpeter@jabber.org

Legal Notice

This XMPP Extension Protocol is copyright 1999 - 2006 by the Jabber Software Foundation (JSF) and is in full conformance with the JSF's Intellectual Property Rights Policy <http://www.xmpp.org/extensions/ipr-policy.shtml>. This material may be distributed only subject to the terms and conditions set forth in the Creative Commons Attribution License (<http://creativecommons.org/licenses/by/2.5/>).

Discussion Venue

The preferred venue for discussion of this document is the Standards-JIG discussion list: <http://mail.jabber.org/mailman/listinfo/standards-jig>.

Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the Jabber Software Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.

Conformance Terms

The following keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".


Table of Contents

1. Introduction
2. Unbinding a Resource
3. Business Rules
3.1. From Addresses
3.2. Server Sessions
4. Examples
5. Security Considerations
6. IANA Considerations
7. XMPP Registrar Considerations
8. XML Schema
Notes
Revision History


1. Introduction

Note: This document describes a protocol or best practice that is intended for incorporation into the specification that will supersede RFC 3920 [1] within the Internet Standards Process, i.e., rfc3920bis [2]. This document is provided only for the purpose of open community discussion of the potential modification and will be obsoleted as soon as the relevant RFC is published.

RFC 3920 introduced the concept of binding a resource to an XML stream (this concept superseded part of the older jabber:iq:auth protocol described in Non-SASL Authentication [3]). As defined in RFC 3920, resource binding enables a client to bind one resource to a stream but does not enable a client to unbind a resource and leaves underspecified what a server and client should do if a client binds more than one resource to a stream. Because the ability to bind multiple resources to a stream is desirable in certain environments (e.g., for devices that are unable to open more than one TCP connection or when a machine runs a daemon process that is used by multiple applications), this document proposes improvements to resource binding in order to address these shortcomings.

Note: The recommendations described herein have been incorporated into rfc3920bis.

2. Unbinding a Resource

In order to properly manage the resources associated with an XML stream, a client must be able to unbind resources. This shall be completed by sending an IQ-set with a child element of <unbind/> qualified by the 'urn:ietf:params:xml:ns:xmpp-bind' namespace, which in turn has a child element of <resource/> whose XML character data specifies the resource to be unbound:

Example 1. Unbind

<iq type='set' id='bind_2'>
  <unbind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <resource>someresource</resource>
  </unbind>
</iq>
  

If the server does not understand the <unbind/> element, it MUST return an error of <bad-request/>. Otherwise, if there is no such resource, the server MUST return an error of <item-not-found/>. When the client unbinds the only resource associated with the stream, the server SHOULD close the stream and terminate the TCP connection.

A server SHOULD advertise its support for the 'urn:ietf:params:xml:ns:xmpp-bind' namespace and the unbind functionality by returning an appropriate stream feature as shown below:

Example 2. Unbind Stream Feature

<stream:features>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <required/>
  </bind>
  <unbind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
</stream:features>
  

3. Business Rules

3.1 From Addresses

When a client binds multiple resources to the same stream, proper management of 'from' addresses is imperative. In particular, a client MUST specify a 'from' address on every stanza it sends over a stream to which it has bound multiple resources. If a client does not specify a 'from' address on a stanza it sends over a stream to which it has bound multiple resources (or if it specifies as the 'from' address a full JID other than one of the bound resources), the server MUST do one of the following:

  1. Stamp the stanza with the resource that the server considers to be the "default resource" for the stream. [4]
  2. Return the stanza to the client with an <unknown-sender/> stanza error. [5]

Which of these a server does is up to the implementation or deployment.

Naturally, the existing rules from RFC 3920 regarding validation of asserted 'from' addresses still apply.

3.2 Server Sessions

In instant messaging and presence applications, an XMPP server manages a session on behalf of a connected client. A server MUST create and manage a separate session for each distinct resource, even if there are multiple resources associated with a given XML stream. In particular:

  1. A server MUST consider each resource to be a distinct source of presence information, both with regard to presence notifications and with regard to presence probes.
  2. A server MUST manage rosters (see RFC 3920) and Server-Based Privacy Rules [6] separately for each resource.

4. Examples

The following examples show a possible flow of resource binding and unbinding.

First, the client binds an initial resource to the stream.

Example 3. Binding an Initial Resource

<iq type='set' id='bind-1'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <resource>core</resource>
  </bind>
</iq>

<iq type='result' id='bind-1'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <jid>juliet@capulet.com/core</jid>
  </bind>
</iq>
  

Now the client sends some stanzas, making sure to set its 'from' address:

Example 4. Sending Some Stanzas

<iq from='juliet@capulet.com/core' type='get' id='roster-1'>
  <query xmlns='jabber:iq:roster'/>
</iq>

<iq to='juliet@capulet.com/core' type='result' id='roster-1'>
  <query xmlns='jabber:iq:roster'>
    <item jid='romeo@montague.net'/>
  </query>
</iq>

<presence from='juliet@capulet.com/core'/>
  

Now the client binds a second resource to the stream.

Example 5. Binding a Second Resource

<iq type='set' id='bind-2'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <resource>balcony</resource>
  </bind>
</iq>

<iq type='result' id='bind-2'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <jid>juliet@capulet.com/balcony</jid>
  </bind>
</iq>
  

If the server does not allow entities to bind multiple resources to the stream, it MUST return a <not-allowed/> error as described in RFC 3920.

Now the client sends more stanzas.

Example 6. Sending More Stanzas

<iq from='juliet@capulet.com/balcony' type='get' id='roster-2'>
  <query xmlns='jabber:iq:roster'/>
</iq>

<iq to='juliet@capulet.com/balcony' type='result' id='roster-2'>
  <query xmlns='jabber:iq:roster'>
    <item jid='romeo@montague.net'/>
  </query>
</iq>

<presence from='juliet@capulet.com/balcony'/>

<message to='romeo@montague.net'>
  <body>Wherefore art thou?</body>
</message>
  

In handling the last stanza shown above, the server will either return a <unknown-sender/> error or stamped the 'from' address <juliet@capulet.com/core> (but in no case will the server stamp the 'from' address as <juliet@capulet.com/balcony>. Here we assume that the server stamps the 'from' address.

Now the client binds a third resource to the stream.

Example 7. Binding a Third Resource

<iq type='set' id='bind-3'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <resource>softphone</resource>
  </bind>
</iq>

<iq type='result' id='bind-3'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <jid>juliet@capulet.com/softphone</jid>
  </bind>
</iq>
  

Now the client unbinds its initial resource.

Example 8. Unbinding a Resource

<iq type='set' id='unbind-1'>
  <unbind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <resource>core</resource>
  </unbind>
</iq>

<iq type='result' id='unbind-1'/>
  

Now the client sends another stanza without a 'from' address, which we assume the server stamps as from the new default resource (note that this is no longer the initial resource):

Example 9. Client Generates Another Stanza

<message to='romeo@montague.net'>
  <body>Art thou not Romeo, and a Montague?</body>
</message>
  

Example 10. Server Stamps Stanza As From (New) Default Resource

<message from='juliet@capulet.com/balcony' to='romeo@montague.net'>
  <body>Art thou not Romeo, and a Montague?</body>
</message>
  

Now the client unbinds another resource.

Example 11. Unbinding a Resource

<iq type='set' id='unbind-2'>
  <unbind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <resource>softphone</resource>
  </unbind>
</iq>

<iq type='result' id='unbind-2'/>
  

Now the client unbinds its last remaining resource.

Example 12. Unbinding the Final Resource

<iq type='set' id='unbind-3'>
  <unbind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <resource>balcony</resource>
  </unbind>
</iq>

<iq type='result' id='unbind-3'/>
  

The server now SHOULD close the stream and terminate the underlying TCP connection.

Example 13. Server Closes the Stream

</stream:stream>
  

5. Security Considerations

If properly implemented, the modifications described herein do not introduce any new security concerns above and beyond those defined in RFC 3920. However, care must be taken to properly manage 'from' addresses in order to avoid the delivery of stanzas from an unintended resource (which may, for example, leak presence information).

6. IANA Considerations

No interaction with the Internet Assigned Numbers Authority (IANA) [7] is required as a result of this document.

7. XMPP Registrar Considerations

No interaction with the XMPP Registrar [8] is required as a result of this document.

8. XML Schema

Note: The following provisional schema is intended to replace the existing schema for the Resource Binding stream feature.

<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:ietf:params:xml:ns:xmpp-bind'
    xmlns='urn:ietf:params:xml:ns:xmpp-bind'
    elementFormDefault='qualified'>

  <xs:element name='bind'>
    <xs:complexType>
      <xs:sequence>
        <xs:choice minOccurs='0' maxOccurs='1'>
          <xs:element name='resource' type='resourceType'/>
          <xs:element name='jid' type='fullJIDType'/>
        </xs:choice>
        <xs:element name='required'
                    minOccurs='0'
                    maxOccurs='1'
                    type='empty'/>
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name='unbind'>
    <xs:complexType>
      <xs:sequence minOccurs='0'>
        <xs:element name='resource' type='resourceType'/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:simpleType name='resourceType'>
    <xs:restriction base='xs:string'>
      <xs:minLength value='1'/>
      <xs:maxLength value='1023'/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name='fullJIDType'>
    <xs:restriction base='xs:string'>
      <xs:minLength value='8'/>
      <xs:maxLength value='3071'/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>
  


Notes

1. RFC 3920: Extensible Messaging and Presence Protocol (XMPP): Core <http://www.ietf.org/rfc/rfc3920.txt>.

2. rfc3921bis: proposed revisions to Extensible Messaging and Presence Protocol (XMPP): Core <http://www.ietf.org/internet-drafts/draft-saintandre-rfc3920bis-00.txt>. (work in progress)

3. XEP-0078: Non-SASL Authentication <http://www.xmpp.org/extensions/xep-0078.html>.

4. The default resource SHOULD be the oldest resource bound to the stream, which typically will be the initial resource but which might be a resource bound later if subsequently the initial resource has been unbound.

5. Currently there is no <unknown-sender/> stanza defined in RFC 3920; the author will work to add such an error condition to rfc3920bis.

6. XEP-0016: Server-Based Privacy Rules <http://www.xmpp.org/extensions/xep-0016.html>.

7. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.

8. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the Jabber Software Foundation. For further information, see <http://www.xmpp.org/registrar/>.


Revision History

Version 0.2 (2007-01-02)

Required client to include from address on every stanza it sends over a stream to which it has bound multiple resources; specified server handling of sessions.

(psa)

Version 0.1 (2006-08-16)

Initial version.

(psa)

Version 0.0.2 (2006-08-15)

Added stream feature for unbind.

(psa)

Version 0.0.1 (2006-08-15)

First draft.

(psa)


END