<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
  <!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
  <title>Service Delegation</title>
  <abstract>This specification defines an approach for users to delegate certain services (e.g. pubsub) to alternative JIDs.</abstract>
  &LEGALNOTICE;
  <number>0291</number>
  <status>Deferred</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <dependencies>
    <spec>XMPP Core</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>NOT_YET_ASSIGNED</shortname>
  &infiniti;
  <revision>
    <version>0.1</version>
    <date>2011-01-26</date>
    <initials>psa</initials>
    <remark><p>Initial published version.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2010-01-05</date>
    <initials>jk</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>

<section1 topic='Introduction' anchor='intro'>
  <p>It is common to use XMPP user accounts for identity.  Many features for user accounts have been proposed (for example, &xep0084;, &xep0277;, etc), and this list only grows as XMPP heads into social networking territory.  However, not every XMPP server in the world supports every feature, nor can this ever be expected, and this limits the usefulness of the XMPP user account identity.  Also, even when servers do support a feature it may not be clear how to bind an identity to it (see the never-solved problem of learning where a user's generic &xep0060; service is, in the absence of &xep0163;).  Organizations such as Buddycloud and Livefyre have recognized the need to be able to offer features to existing standard XMPP accounts by offering proprietary service delegation mechanisms.  This specification proposes a Standards Track solution for discovering external services associated with XMPP user identities.</p>
</section1>

<section1 topic='How It Works' anchor='protocol'>
  <section2 topic='Discovering Delegate Services' anchor='discover'>
    <p>To learn of delegate services for a user, query the bare JID of the user:</p>
    <example caption="Query for delegate services"><![CDATA[
<iq type="get" from="alice@example.com/home" to="bob@example.com" id="d1">
  <query xmlns="urn:xmpp:tmp:delegate"/>
</iq>
]]></example>
    <example caption="Success response"><![CDATA[
<iq type="result" from="bob@example.com" to="alice@example.com/home" id="d1">
  <query xmlns="urn:xmpp:tmp:delegate">
    <service type="pubsub" jid="pubsub.example.net"/>
    <service type="chess" jid="bob@chess.example.net"/>
  </query>
</iq>
]]></example>
    <p>In the above example, we learn that "chess" related communication should go through the "bob@chess.example.net" JID rather than the user's own JID ("bob@example.com").</p>
  </section2>
  <section2 topic='Discovering Through a Third-Party Registry' anchor='registry-discover'>
    <p>As it is expected that most servers will not even support the ability to query user accounts for delegate services, it should be possible to contact a third-party or global registry holding the same information, to be queried in much the same way:</p>
    <example caption="Query registry for delegate services"><![CDATA[
<iq type="get" from="alice@example.com/home" to="registry.example.com" id="r1">
  <query xmlns="urn:xmpp:tmp:delegate" jid="bob@example.com"/>
</iq>
]]></example>
    <example caption="Success response"><![CDATA[
<iq type="result" from="registry.example.com" to="alice@example.com/home" id="r1">
  <query xmlns="urn:xmpp:tmp:delegate">
    <service type="pubsub" jid="pubsub.example.net"/>
    <service type="chess" jid="bob@chess.example.net"/>
  </query>
</iq>
]]></example>
  </section2>
  <section2 topic='Managing Third-Party Registry Information' anchor='registry-manage'>
    <p>Here's how a user adds a mapping to the registry:</p>
    <example caption="Adding an entry"><![CDATA[
<iq type="set" from="bob@example.com/home" to="registry.example.com" id="r2">
  <query xmlns="urn:xmpp:tmp:delegate">
    <service type="chess" jid="bob@chess.example.net"/>
  </query>
</iq>
]]></example>
    <example caption="Success response"><![CDATA[
<iq type="result" from="registry.example.com" to="bob@example.com/home" id="r2"/>
]]></example>
    <p>The registry will add the new service to the list of mapped services for the sender JID.</p>
    <p>To remove a service from the list, submit without a jid attribute:</p>
    <example caption="Removing an entry"><![CDATA[
<iq type="set" from="bob@example.com/home" to="registry.example.com" id="r3">
  <query xmlns="urn:xmpp:tmp:delegate">
    <service type="chess"/>
  </query>
</iq>
]]></example>
    <example caption="Success response"><![CDATA[
<iq type="result" from="registry.example.com" to="bob@example.com/home" id="r3"/>
]]></example>
  </section2>
  <section2 topic='Confirming With the Delegate' anchor='confirm'>
    <p>Whether a delegate JID is discovered directly or via registry, the mapping is an assertion made by the user only and not by the delegate.  This may have security implications.  For example, a third party should not allow the user to pose as the delegate, nor should the mapping be considered an endorsement by the delegate, since anyone can assert any delegate.  However, these types of things could be allowed if third parties confirm with the delegate that the association exists.</p>
    <p>Here's how to query a delegate JID to confirm if it is indeed associated with a specific user for a specific service type:</p>
    <example caption="Confirming a delegation"><![CDATA[
<iq type="get" from="alice@example.com/home" to="bob@chess.example.net" id="c1">
  <check xmlns="urn:xmpp:tmp:delegate" type="chess" jid="bob@example.com"/>
</iq>
]]></example>
    <p>Note that the user JID expected to be associated with the delegate must be provided in the request.  It is not possible to query a delegate to determine the user JID, since a single delegate may act for many users.</p>
    <p>Success response means the association exists:</p>
    <example caption="Success response"><![CDATA[
<iq type="result" from="bob@chess.example.net" to="alice@example.com/home" id="c1"/>
]]></example>
  </section2>
</section1>

<section1 topic='Implementation Notes' anchor='impl'>
  <section2 topic='Use of Both Direct and Third-Party Queries' anchor='impl-both'>
    <p>Applications that are configured to use a third-party registry SHOULD still be able to query user accounts directly.  For performance reasons, it is recommended to query both the user account and the registry simultaneously, and take whichever answer arrives first.  If one of the queries results in an error, then the application should wait for the other query to complete before assuming no such delegate records exists.</p>
    <p>If both queries return errors, or a success result does not contain an entry for some desired delegate service, it can be assumed that the desired service is provided by the user account itself (not delegated).</p>
  </section2>
  <section2 topic='Caching' anchor='impl-caching'>
    <p>It is RECOMMENDED that discovery or confirmation of delegate information be cached indefinitely and refreshed no more frequently than every 24 hours.  Data refreshing should not block access to existing information.  If over 24 hours pass since the last time delegate information was needed, the application should continue to use the old data while independently firing off a task to refresh the data.  This way, latency associated with a particular user delegation only occurs the first time a user is ever seen.</p>
  </section2>
</section1>

<section1 topic='Security Considerations' anchor='security'>
  <p>As discussed above, a delegate mapping is an assertion by the user only.  If the user should be allowed to act for the delegate, or if the user should be considered endorsed by the delegate, then the delegation needs to be confirmed first.</p>
</section1>

<section1 topic='IANA Considerations' anchor='iana'>
  <p>No interaction with &IANA; is required as a result of this document.</p>
</section1>

<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
    <p>This specification defines the following XML namespace:</p>
    <ul>
      <li>urn:xmpp:tmp:delegate</li>
    </ul>
    <p>Upon advancement of this specification from a status of Experimental to a status of Draft, the &REGISTRAR; shall add the foregoing namespace to the registry located at &NAMESPACES;, as described in Section 4 of &xep0053;.</p>
  </section2>
  <section2 topic='Namespace Versioning' anchor='registrar-versioning'>
    &NSVER;
  </section2>
</section1>

</xep>
