<p>Several updates according to feedbacks + review:</p>
<ul>
<li>added links to PEP and namespace delegation XEPs</li>
<li>removed MUST for default values in configuration</li>
<li><forwarded/> element is now a child of a <privilege/> element</li>
<li><perm/> "namespace" attribute has been renamed to "access"</li>
<li>"headline" type restriction for "message" privilege has been removed</li>
<li>"message" permission violation now result in a "forbidden" message error</li>
<li>for "presence" permission, only &PRESENCE; stanza with no type or with a "unavailable" type are sent to privileged entity</li>
<li>added specifitation for "presence" if a managed entity is unavailable and if a privileged entity is available after first &PRESENCE; stanzas have been received</li>
<li>added Business Rules section</li>
<li>Updated namespace to reflect incompatible changes</li>
<remark><p>Initial published version approved by the XMPP Council.</p></remark>
</revision>
<revision>
<version>0.0.4</version>
<date>2014-12-18</date>
<initials>jp</initials>
<remark><ul>
<li>Big simplification and restriction following council's veto and standard@ discussions</li>
<li>Configuration is now done only on server own configuration</li>
<li>No more client mode</li>
<li>Permissions are adverised using &MESSAGE;</li>
<li>The only &IQ; privilege still available is jabber:iq:roster</li>
</ul>
</remark>
</revision>
<revision>
<version>0.0.3</version>
<date>2014-11-13</date>
<initials>jp</initials>
<remark><ul>
<li>giving permission to manage this XEP namespace is forbidden</li>
<li>Added configuration section; with well-defined command node</li>
<li>better specification of persistent permissions</li>
<li>fixed erroneous example (server returns bookmarks)</li>
<li>added special permissions</li>
<li>better specification of &QUERY; element</li>
</ul>
</remark>
</revision>
<revision>
<version>0.0.2</version>
<date>2014-09-17</date>
<initials>jp</initials>
<remark><ul>
<li>changed for privileged entity</li>
<li>fixes after feedbacks on standard mailing list</li>
<li>completed missing required parts</li>
</ul>
</remark>
</revision>
<revision>
<version>0.0.1</version>
<date>2014-05-09</date>
<initials>jp</initials>
<remark><p>First draft.</p></remark>
</revision>
</header>
<section1topic='Introduction'anchor='intro'>
<p>XMPP components are used for long through &xep0114;, but are quite limited: they have a restricted access to other entities data, similar to what a client can do. This is sufficient for components like gateways, but very limiting for more complex components like a PubSub service. The goal of this XEP is to allow a component or any entity to have a "privileged" status, and access some other entity data with the same privileges than the entity itself, that means manage an entity roster on its behalf, send &MESSAGE; or receive &PRESENCE; stanzas in the name of the server.</p>
<p>Privileged entities have numerous advantages, including:</p>
<ul>
<li>a step forward in decentralization: it is possible for an entity to do tasks which were before reserved to server itself. For example, a privileged pubsub component can offer access model based on publisher's roster</li>
<li>better integration of components: a gateway can add items to an entity roster itself</li>
<p>Privileged entity has been created with the main goal to create an external, server agnostic, PEP service. It is restricted to only a couple of features, see <linkurl='#acks'>Acknowledgements section</link> for more details.</p>
<p>This XEP is complementary to &xep0355; (and works in a similar way), although they can be used together or separately. To build something like an external PEP service, it is necessary to use both XEPs.</p>
<li><strong>get</strong> — the entity is allowed to send &IQ; stanzas of type <em>'get'</em> for the namespace 'jabber:iq:roster'.</li>
<li><strong>set</strong> — the entity is allowed to send &IQ; stanzas of type <em>'set'</em> for namespace 'jabber:iq:roster'.</li>
<li><strong>both</strong> — the entity is allowed to send &IQ; stanzas of type <em>'get'</em> and <em>'set'</em> for namespace 'jabber:iq:roster'.</li>
<section2topic='Server Advertises Entity Of Allowed Permission'anchor='advertise_roster'>
<p>Once a privileged entity is authenticated and stream is started, the server send it a &MESSAGE; stanza with a <privilege/> elements which MUST have the namespace 'urn:xmpp:privilege:1'. This element contains <perm/> elements which MUST contain a 'access' attribute of the value "roster" and a 'type' attribute which must correspond to the type configured as specified in <linkurl='#server_roster'>"Server Allows Roster Access" section</link></p>
<p>Doing a <em>get</em> or <em>set</em> operation on the roster of a managed entity is done in the usual way (as described in &rfc6121; section 2), except that the 'to' attribute is set to the attribute of the managed entity. The server MUST check that the privileged entity has right to <em>get</em> or <em>set</em> the roster of managed entity, and MUST return a &forbidden; error if it is not the case:</p>
<examplecaption='Privileged Entity Get Managed Entity Roster'><![CDATA[
<p>In some cases, it can be desirable to send notifications (e.g. PEP service), so the privileged entity must be able to send &MESSAGE; stanzas. This is allowed in server configuration in the same way as for roster permission. The permission type can have the following values:</p>
<p>A privileged entity can then send message on the behalf either of the server or of a bare JID of an entity managed by the server (i.e. a bare jid with the same domain as the server), using &xep0297;. The <forwarded/> element MUST be a child of a <privilege/> element with a namespace of <em>'urn:xmpp:privilege:1'</em>, with the following restriction:</p>
<p>Server advertises "message" permission in the same way as for "roster" permission, except that 'access' attribute has the value of "message", and the 'type' attribute as a value of 'outgoing':</p>
<examplecaption='Server Advertises Roster And Message Privileges'><![CDATA[
<p>The server sees that forwarded message 'from' attribute (<em>juliet@capulet.lit</em>) is a bare JID of the server, and that outgoing message permission was granted; it can now send the notification:</p>
<p>It can be often desirable for a privileged entity to have presence information of the managed entities (e.g. to know when to send them notificiations). As privileges must be transparent for the managed entity, this presence has to be sent by the server without modifying managed entity roster.</p>
<p>This is allowed in server configuration in the same way as for <em>roster</em> and <em>message</em> permissions. The "presence" type can have the following values:</p>
<li><strong>managed_entity</strong> — the entity is allowed to receive managed entity presence (see below).</li>
<li><strong>roster</strong> — the entity is allowed to receive presence informations of managed entity contacts, see <linkurl='#roster_presence'>Roster Presence section</link>.</li>
<p>If the privilege is granted, the server MUST use a directed presence from the full jid of the managed entity, to the privileged entity, as specified in &rfc6121; section 4.6, on the behalf of managed entity each time its presence information change.</p>
<p>Only presences with no 'type' attribute or with a 'type' attribute with the value "unavailable" are transmitted to the privileged entity, the server MUST NOT transmit &PRESENCE; stanza of any other type.</p>
<p>Server advertises "presence" permission in the same way as for "roster" or "message" permissions, except that 'access' attribute has the value of "presence", and the 'type' attribute has a value of "managed_entity"</p>
<p>In addition to "<linkurl='#managed_ent_presence'>managed entity presence</link>", a privileged entity may need to know when a contact in managed entity roster is online (for example, it's necessary for a PEP service because of the presence default access model).</p>
<p>As for other permissions, the access is granted in server's configuration, but there is an additional restriction: the privileged entity MUST have read permission on roster namespace (i.e. 'type' attribute in allowed <perm> of access <em>roster</em> MUST have a value of either <strong>get</strong> or <strong>both</strong>).</p>
<p>If the privilege is granted, the server MUST send to the privileged entity every presence information with no 'type' attribute or with a 'type' with a value of 'unavailable' that the privileged entity is receiving or would receive if it were available. It do it in the same way as for <linkurl='#managed_ent_presence'>managing entity</link> by using directed &PRESENCE; from the full jid of the entity from which presence information has changed, to the privileged entity. If the managed entity is unavailable but the privileged entity is available, the server MUST send &PRESENCE; stanza to the later anyway.</p>
<p>Having "roster" type for "presence" permission imply that you have also implicitly "managed_entity" type.</p><p>The server MUST reject the permission if the privileged entity doesn't have read permission on roster namespace.</p>
<p>Note: this permission should be given carefully, as it gives access to presence of potentially a lot of entities to the privileged entity (see <linkurl='#security'>security considerations</link>).</p>
<p>Server advertises roster "presence" permission in the same way as for other permissions, except that the 'access' attribute has the value of "presence", and the 'type' attribute has a value of "roster"</p>
<li>For "presence" access, if a privileged entity is connected after first &PRESENCE; stanzas have been received, the server MUST send it all the &PRESENCE; stanzas with no 'type' attribute it would have had if it was connected first (in other words: all the presences informations for connected entities it has access to).</li>
<li>For "presence" access, if a privileged entity is supposed to received several time the same &PRESENCE; stanza, the server SHOULD send it only once. For example: if <em>pubsub.capulet.lit</em> has a "presence" access with a "roster" type for <em>capulet.lit</em>, and <em>juliet@capulet.lit</em> and <em>nurse@capulet.it</em> both have <em>romeo@montague.lit</em> in their roster. When romeo is available, <em>pubsub.capulet.lit</em> shoud have its &PRESENCE; stanza only once (instead of 2 times).</li>
<li>Privileged entitiy has access to sensitive data, and can act as the server itself, permissions should be granted carefuly, only if you absolutely trust the entity.</li>
<li><linkurl='#roster_presence'>Roster presence</link> is particulary sensitive, because presence informations of whole rosters are shared.</li>
<p>Thanks to Sergey Dobrov, Dave Cridland, Steven Lloyd Watkin, Lance Stout, Johannes Hund, Kurt Zeilenga and Kevin Smith for their feedbacks. Thanks to Adrien Cossa for his typos/style corrections.</p>
<p>Privileged entity was initialy written to be a generic identity based access control (IBAC) which allows an entity to access sensitive data. After <linkurl='http://mail.jabber.org/pipermail/standards/2014-December/029378.html'>a discussion on standard mailing list</link>, it has been decided to restrict the current XEP to immediate needs to build an external PEP service, and to implement separately an Attribute Based Access Control (ABAC) which is more modern, generic and flexible. This XEP is still interesting for being easy to implement and doing the job.</p>