<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Server Buddies</title>
  <abstract>This specification defines a convention for presence subscriptions between XMPP servers.</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0267</number>
  <status>Deferred</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>NOT_YET_ASSIGNED</shortname>
  <author>
    <firstname>Artur</firstname>
    <surname>Hefczyc</surname>
    <email>artur.hefczyc@gmail.com</email>
    <jid>artur.hefczyc@tigase.org</jid>
  </author>
  <author>
    <firstname>Florian</firstname>
    <surname>Jensen</surname>
    <email>admin@flosoft.biz</email>
    <jid>admin@im.flosoft.biz</jid>
  </author>
  <author>
    <firstname>Mickaël</firstname>
    <surname>Rémond</surname>
    <email>mickael.remond@process-one.net</email>
    <jid>mremond@process-one.net</jid>
  </author>
  
  <author>
    <firstname>Peter</firstname>
    <surname>Saint-Andre</surname>
    <email>stpeter@stpeter.im</email>
    <jid>stpeter@jabber.org</jid>
    <uri>https://stpeter.im/</uri>
  </author>

  
  <author>
    <firstname>Matthew</firstname>
    <surname>Wild</surname>
    <email>mwild1@gmail.com</email>
    <jid>me@matthewwild.co.uk</jid>
  </author>

  <revision>
    <version>0.5</version>
    <date>2012-05-29</date>
    <initials>psa</initials>
    <remark><p>Corrected several examples and points in the text.</p></remark>
  </revision>
  <revision>
    <version>0.4</version>
    <date>2011-12-12</date>
    <initials>psa</initials>
    <remark><p>Noted that sending server can be derived from 'to' address on IQ stanza, so removed serverjid field from FORM_TYPE; defined method for determining support; added further XMPP Registrar Considerations.</p></remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2011-12-12</date>
    <initials>psa</initials>
    <remark><p>Updated ad-hoc command with field for the sending server; added XMPP Registrar Considerations.</p></remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2011-12-09</date>
    <initials>psa</initials>
    <remark><p>Defined ad-hoc command for admin generation of outbound presence subscription; added security considerations.</p></remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2009-04-30</date>
    <initials>psa</initials>
    <remark><p>Initial published version.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2009-04-30</date>
    <initials>ah/fj/psa/mr/mw</initials>
    <remark><p>First draft, split from the incident reporting proposal.</p></remark>
  </revision>
</header>

<section1 topic="Description" anchor="description">
  <p>In XMPP, rosters and presence subscriptions have been used to date only among IM users (see <span class="ref"><link url="http://tools.ietf.org/html/rfc6121">XMPP IM</link></span> <note>RFC 6121: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence &lt;<link url="http://tools.ietf.org/html/rfc6121">http://tools.ietf.org/html/rfc6121</link>&gt;.</note>). However, nothing prevents the application of these concepts to other XMPP entities, such as components and servers. Given that a presence subscription typically indicates some level of trust in a peer, server deployments can use the sharing of XMPP presence information as a way to indicate that a given server has a trust relationship with a peer server (informally, we can say that the two servers consider each other "buddies"). The server might then share certain kinds of additional information only with its trusted peers, for example <span class="ref"><link url="https://xmpp.org/extensions/xep-0268.html">Incident Reporting (XEP-0268)</link></span> <note>XEP-0268: Incident Reporting &lt;<link url="https://xmpp.org/extensions/xep-0268.html">https://xmpp.org/extensions/xep-0268.html</link>&gt;.</note> and <span class="ref"><link url="https://xmpp.org/extensions/xep-0275.html">Entity Reputation (XEP-0275)</link></span> <note>XEP-0275: Entity Reputation &lt;<link url="https://xmpp.org/extensions/xep-0275.html">https://xmpp.org/extensions/xep-0275.html</link>&gt;.</note>. The server buddy relationship can also be leveraged for additional functionality, such as <span class="ref"><link url="https://xmpp.org/extensions/xep-0309.html">Service Directories (XEP-0309)</link></span> <note>XEP-0309: Service Directories &lt;<link url="https://xmpp.org/extensions/xep-0309.html">https://xmpp.org/extensions/xep-0309.html</link>&gt;.</note></p>
  <p>To establish such a trust relationship with a peer, a server sends a presence subscription request to the peer, just as is done between XMPP users.</p>
  <example caption="Service sends subscription request to peer"><![CDATA[
<presence from='montague.lit'
          to='capulet.lit'
          type='subscribe'/>
]]></example>
  <p>A server MUST NOT send such a presence subscription request unless explicitly requested to do so by a server administrator (see below).</p>
  <p>Upon receiving such a presence subscription request, the XMPP server software running at the peer shall either prompt the server administrator to approve the request or (if explicitly configured to accept subscriptions requests) automatically approve it. (A future version of this specification might define an approval method based on <span class="ref"><link url="https://xmpp.org/extensions/xep-0004.html">Data Forms (XEP-0004)</link></span> <note>XEP-0004: Data Forms &lt;<link url="https://xmpp.org/extensions/xep-0004.html">https://xmpp.org/extensions/xep-0004.html</link>&gt;.</note>.)</p>
  <p>If the request is approved, the peer server then informs the originating server that the request has been approved.</p>
  <example caption="Peer sends approval to server"><![CDATA[
<presence from='capulet.lit'
          to='montague.lit'
          type='subscribed'/>
]]></example>
  <p>The peer SHOULD also send a subscription request to the originating server.</p>
  <example caption="Peer sends subscription request to server"><![CDATA[
<presence from='capulet.lit'
          to='montague.lit'
          type='subscribe'/>
]]></example>
  <p>The originating server would then approve that subscription request.</p>
  <example caption="Service sends approval to peer"><![CDATA[
<presence from='montague.lit'
          to='capulet.lit'
          type='subscribed'/>
]]></example>
  <p>If an XMPP server implementation supports this usage of presence subscriptions, it MUST keep a list of approved entities, which we denote a "server roster". The implementation MAY use that roster for access control purposes defined in other specifications.</p>
</section1>

<section1 topic="Ad-Hoc Command" anchor="command">
  <p>This section defines an <span class="ref"><link url="https://xmpp.org/extensions/xep-0050.html">Ad-Hoc Commands (XEP-0050)</link></span> <note>XEP-0050: Ad-Hoc Commands &lt;<link url="https://xmpp.org/extensions/xep-0050.html">https://xmpp.org/extensions/xep-0050.html</link>&gt;.</note> node scoped by the <span class="ref"><link url="https://xmpp.org/extensions/xep-0068.html">Field Standardization for Data Forms (XEP-0068)</link></span> <note>XEP-0068: Field Data Standardization for Data Forms &lt;<link url="https://xmpp.org/extensions/xep-0068.html">https://xmpp.org/extensions/xep-0068.html</link>&gt;.</note> FORM_TYPE specified in <span class="ref"><link url="https://xmpp.org/extensions/xep-0133.html">Service Administration (XEP-0133)</link></span> <note>XEP-0133: Service Administration &lt;<link url="https://xmpp.org/extensions/xep-0133.html">https://xmpp.org/extensions/xep-0133.html</link>&gt;.</note>. Upon advancement of this specification to Draft, this section ought to be moved to XEP-0133.</p>
  <p>The command node for this use case SHOULD be "http://jabber.org/protocol/admin#server-buddy".</p>
  <p>A sample protocol flow for this use case is shown below.</p>
    <example caption="Admin Subscribes Service to Peer Server"><![CDATA[
<iq from='bard@shakespeare.lit/globe'
    id='nrw51vs8'
    to='shakespeare.lit'
    type='set'
    xml:lang='en'>
  <command xmlns='http://jabber.org/protocol/commands'
           action='execute'
           node='http://jabber.org/protocol/admin#server-buddy'/>
</iq>
]]></example>
    <p>Unless an error occurs (see the "Error Handling" section of XEP-0133), the service SHOULD return the appropriate form.</p>
    <example caption="Service Returns Server Buddy Form to Admin"><![CDATA[
<iq from='shakespeare.lit'
    id='nrw51vs8'
    to='bard@shakespeare.lit/globe'
    type='result'
    xml:lang='en'>
  <command xmlns='http://jabber.org/protocol/commands'
           node='http://jabber.org/protocol/admin#server-buddy'
           sessionid='server-buddy:20040408T0337Z'
           status='executing'>
    <x xmlns='jabber:x:data' type='form'>
      <title>Subscribing to a Peer Server</title>
      <instructions>Fill out this form to subscribe your server to a peer server.</instructions>
      <field type='hidden' var='FORM_TYPE'>
        <value>http://jabber.org/protocol/admin</value>
      </field>
      <field label='The domain name of the peer server'
             type='jid-single'
             var='peerjid'>
        <required/>
      </field>
    </x>
  </command>
</iq>
]]></example>
    <p>Note: In virtual hosting environments, the server can determine the domain name from which to send the presence subscription based on the 'to' address of the &lt;iq/&gt; stanza.</p>
    <example caption="Admin Submits Server Buddy Form to Service"><![CDATA[
<iq from='bard@shakespeare.lit/globe'
    id='lk2vs82g'
    to='shakespeare.lit'
    type='set'
    xml:lang='en'>
  <command xmlns='http://jabber.org/protocol/commands'
           node='http://jabber.org/protocol/admin#server-buddy'
           sessionid='server-buddy:20040408T0337Z'>
    <x xmlns='jabber:x:data' type='submit'>
      <field type='hidden' var='FORM_TYPE'>
        <value>http://jabber.org/protocol/admin</value>
      </field>
      <field var='peerjid'>
        <value>marlowe.lit</value>
      </field>
    </x>
  </command>
</iq>
]]></example>
    <example caption="Service Informs Admin of Completion"><![CDATA[
<iq from='shakespeare.lit'
    id='lk2vs82g'
    to='bard@shakespeare.lit/globe'
    type='result'
    xml:lang='en'>
  <command xmlns='http://jabber.org/protocol/commands'
           node='http://jabber.org/protocol/admin#server-buddy'
           sessionid='server-buddy:20040408T0337Z'
           status='completed'/>
</iq>
]]></example>
  <p>Notification of completion MAY include the processed data in a data form of type "result".</p>
</section1>

<section1 topic="Determining Support" anchor="support">
  <p>To advertise its support for the server buddy feature, when replying to service discovery information ("disco#info") requests a server MUST return a URN of "urn:xmpp:server-presence".</p>
  <example caption="Service discovery information request"><![CDATA[
<iq from='jabber.org'
    id='uw72g176'
    to='xmpp.net'
    type='get'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
]]></example>
  <example caption="Service discovery information response"><![CDATA[
<iq from='xmpp.net'
    id='uw72g176'
    to='jabber.org'
    type='result'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    <feature var='urn:xmpp:server-presence'/>
  </query>
</iq>
]]></example>
</section1>

<section1 topic="Security Considerations" anchor="security">
  <p>Because server "buddies" might be granted greater privileges than unknown peers, care should be taken in sending or approving presence subscription requests. In particular, a server MUST NOT send a presence subscription request unless explicitly requested to do so by a server administrator.</p>
</section1>

<section1 topic="IANA Considerations" anchor="iana">
  <p>This document requires no interaction with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>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 &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note>.</p>
</section1>

<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <section2 topic="Service Discovery Features" anchor="registrar-features">
    <code caption="Registry Submission"><![CDATA[
<var>
  <name>urn:xmpp:server-presence</name>
  <desc>Support for subscriptions to server presence</desc>
  <doc>XEP-0267</doc>
</var>
]]></code>
  </section2>
  <section2 topic="Field Standardization" anchor="registrar-formtype">
    <p><span class="ref"><link url="https://xmpp.org/extensions/xep-0068.html">Field Standardization for Data Forms (XEP-0068)</link></span> <note>XEP-0068: Field Data Standardization for Data Forms &lt;<link url="https://xmpp.org/extensions/xep-0068.html">https://xmpp.org/extensions/xep-0068.html</link>&gt;.</note> defines a process for standardizing the fields used within Data Forms scoped by a particular namespace. This registration adds two more reserved fields to the 'http://jabber.org/protocol/admin' namespace defined in XEP-0133.</p>
    <code caption="Registry Submission"><![CDATA[
<form_type>
  <name>http://jabber.org/protocol/admin</name>
  <field var='peerjid'
         type='jid-single'
         label='The Jabber ID of a peer server'/>
</form_type>
]]></code>
  </section2>
</section1>

<section1 topic="Acknowledgements" anchor="ack">
  <p>Thanks to Kim Alvefur, Waqas Hussain, and Tobias Markmann for their feedback.</p>
</section1>

</xep>
