<copyright>This XMPP Extension Protocol is copyright (c) 1999 - 2014 by the XMPP Standards Foundation (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. In no event shall the XMPP Standards Foundation or the authors of this Specification be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification. ##</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 out of the use or inability to use 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 may be found at <<linkurl='http://xmpp.org/extensions/ipr-policy.shtml'>http://xmpp.org/extensions/ipr-policy.shtml</link>> or obtained by writing to XSF, P.O. Box 1641, Denver, CO 80201 USA).</conformance>
<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 an other entity data with the same privileges than the entity itself, that means send and receive &IQ; stanzas on its behalf (and in <linkurl='#special'>some cases</link>, send &MESSAGE; or receive &PRESENCE; stanzas).</p>
<p>Privileged entities have numerous advantages, including:</p>
<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>In <em>admin</em> mode, the privileged entity MAY be able to emit &IQ; stanzas in the same way as any entity, including managing roster or accessing persistent storage. The privilege mechanism MUST be totally transparent for the managed entities.</p>
<p>In <em>client</em> mode, a privileged entity MUST have an explicit authorization for any &IQ; namespace he wants to use. Client SHOULD be able to check and revoke granted permissions, and if it's not possible, permissions MUST be revoked after a disconnection.</p>
<p>In addition, some <linkurl='#special'>special permissions</link> can permit to send &MESSAGE; stanzas on behalf of the server or access &PRESENCE; informations.</p>
<p>Once an entity is authenticated and stream is started, it can request a privileged status. It does it by sending an &IQ; stanza with <strong>'urn:xmpp:privilege:0'</strong> namespace.</p>
<p>The &QUERY; element MUST have a "request" type and MAY have a 'privilege' attribute with the value "admin". Namespace permissions are asked with a <perm/> element, which MUST contain a 'namespace' attribute set to the requested namespace and a 'type' attribute which can be:</p>
<p>If the server accepts the privileged status (e.g.: admin status specified in configuration), it MUST return an &IQ; result stanza with a &QUERY; element of type "allowed", and listing the allowed permissions in <perm/> elements:</p>
<p>Sending an &IQ; stanza is done by sending the stanza the way it would be done by the managed entity, except that its JID is in the 'to' attribute. In the following example, the PubSub service want to know Juliet's roster because she owns a node with access model based on publiser's roster:</p>
<examplecaption='Privileged Entity Sends A Roster Stanza'><![CDATA[
<p>In the following example, the sync.capulet.net privileged entity want to access managed entity's bookmarks to synchronize them with an online service. It can request the bookmarks in the following way:</p>
<p>In <em>client</em> mode, the privileged entity is not certified by the server administrator, so the permissions MUST be <strong>explicitly</strong> allowed by the managed entity. This is initiated by the privileged entity (it can be after an interaction with a managed entity, like a subscription). It's done in the same way as for <em>admin</em> mode with the following exceptions:</p>
<p>Once received the permission request, the server asks the client to grant or deny the requested permission using &xep0004;. The form SHOULD allow to fine tune the granted permissions. The server uses a challenge which it MUST have generated himself.
<p>The server SHOULD include a warning message, SHOULD translate the namespace to human friendly names (and MAY keep the original namespace in addition) and MUST set the default value to "<strong>none</strong>" (permission refused). The server SHOULD use namespace as field var, so a client can use it to have a customized display.</p>
<p>Here Juliet allows <em>priv.montaigu.net</em> to use 'set' and 'get' in order to manage her roster, but doesn't want it to do any 'get' on her pubsub nodes.</p>
<p>Finaly, the server notify the entity of the granted permissions. For this it uses a &QUERY; element with the 'allowed' type, and puts the client JID in a 'from' attribute:</p>
<p>Sending &IQ; stanzas is done in the exact same way as for <linkurl='#priv_iq_admin'>admin mode</link>. If an entity wants to sent a non authorized &IQ;, it will get a &forbidden; error:</p>
<p>In some cases, an entity may need extra permission beyond what &IQ; stanzas can do. An entity may want to send &MESSAGE; stanzas on behalf of the server, or get &PRESENCE; informations. The special permissions manage these cases with some restrictions.</p>
<p>With some namespaces it can be desirable to send notifications (e.g. PEP service), so the privileged entity must be able to send &MESSAGE; stanzas. To do this, it MUST request it by using a <perm/> element with the special "message" namespace attribute and a 'type' attribute with the value "outgoing" (any other type MUST be rejected with a &forbidden; error).</p>
<p>A privileged entity can then send message on the behalf either of the server or of a bare JID of the server, using &xep0297;, with the following restrictions:</p>
<ol>
<li>forwarded &MESSAGE; 'type' attribute has the value of "headline"</li>
<li>forwarded &MESSAGE; 'from' attribute MUST be a bare JID from the server, no resource is allowed</li>
<li>in client mode, the forwarded &MESSAGE; 'from' attribute can only be one of a managed entity which has explicitly accepted the delegation</li>
</ol>
<p>If any of this rules is violated, the server MUST return a <not-authorized/> stream error and close the connection, as explained in &rfc6120; section 4.9.3.12.</p>
<p>In the following example, <em>pubsub.capulet.lit</em> asks for pubsub and outgoing messages permission</p>
<examplecaption='entity asks for outgoing messages permission'><![CDATA[
<p>The server sees that forwarded message type is '<em>headline</em>', that <em>juliet@capulet.lit</em> is a bare JID of the server, and that outgoing message permission was granted in admin mode (so all bare JIDs from server are allowed); it can now send the notification:</p>
<examplecaption='server sends the notification as if it was originating from him'><![CDATA[
<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 it notificiations). As privileges must be transparent for the managed entity (in admin mode), this presence has to be sent by the server without modifying managed entity roster.</p>
<p>To do this, the privileged entity MUST ask for presence information when requesting privileges, using a special "presence" namespace attribute and a 'type' attribute with the value "managed_entity".</p><p>If the delegation is granted, the server MUST use a directed presence, as specified in &rfc6121; section 4.6 on the behalf of managed entity each time its presence information change.</p><p>This privilege MUST NOT be requested in client mode, if so the server MUST reject the request by setting the allowed type to "none". If an entity needs presence information in client mode, it SHOULD request it using the normal &PRESENCE; subscription mechanism.</p>
<examplecaption='privileged entity asks for pusub privilege with presence'><![CDATA[
<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>In this case, privileged entity MUST ask for presence information when requesting privileges, using a special "presence" namespace attribute (as in previous section) and a 'type' attribute with the value "roster". Furthermore, the privileged entity MUST have read permission on roster namespace (i.e. 'type' attribute in allowed <perm> of namespace <em>jabber:iq:roster</em> MUST have a value of either <strong>get</strong> or <strong>both</strong>).</p>
<p>If the delegation is granted, the server MUST send to the privileged entity every presence information that the managing entity is receiving.</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>). If allowed in client mode, server SHOULD display an extra warning when requesting permissions to the managed entity.</p>
<examplecaption='privileged entity asks for pusub privilege with presence roster'><![CDATA[
<p>Server SHOULD provide a way for clients to check already granted permission, and revoke them by using &xep0050; on the well-defined command node <strong>'urn:xmpp:privilege:0#configure'</strong>.</p>
<p>If present, the configuration commands MUST allow at least to check permissions granted to a privileged entity, and to revoke them. A server MAY offer an option to keep permission from one session to an other (see <linkurl='#rules'>business rules</link>).</p>
<p>If a server or an entity supports the privileged entity protocol, it MUST report that fact by including a service discovery feature of "urn:xmpp:privilege:0" in response to a &xep0030; information request:</p>
<li>In client mode, server MAY keep permission granted to an entity by a client from one session to an other, but if it do so, it MUST provide configuration like explained in the <linkurl='#configuration'>suitable section</link>. If server offers this feature, it SHOULD add a field directly in configuration commands.</li>
<li>If a client can't check or revoke permission (i.e. it doesn't support &xep0050;) when granting permissions, the server MUST NOT keep granted permissions from one session to an other, and permissions will be asked on each new session.</li>
<li>If permissions are changed during a session, server MUST notify privileged entity of the new permissions, like in <linkurl='#client_perm'>permission request use case</link>.</li>
<li>A server MUST NOT grant permission for this XEP namespace (<strong>'urn:xmpp:privilege:0'</strong>).</li>
<li>Privileged entity nearly have the same possibility as the server itself, <em>admin</em> permission should be granted carefuly, only if you absolutely trust the entity.</li>
<li>A server MAY choose to filter allowed namespaces, to avoid giving dangerous permissions. In this case, it MUST always set the allowed type of filtered namespaces to "<strong>none</strong>"</li>
<li><linkurl='#roster_presence'>Roster presence</link> is particulary sensitive, because if an entity accept this permission, it shares presence information of its whole roster. For this reason, a server MAY choose to forbid its use in client mode (by always setting the allowed type to "<strong>none</strong>"). A server SHOULD at least disallow it in default configuration.</li>
<li>In case of filtering, a whitelist system is more secure and SHOULD be prefered to a blacklist (idealy, configuration would allow no filtering, whitelist filtering and blacklist filtering).</li>
<p>Thanks to Sergey Dobrov, Dave Cridland, Steven Lloyd Watkin, Lance Stout and Johannes Hund for their feedbacks. Thanks to Adrien Cossa for his typos/style corrections.</p>
<p>The client mode permission mechanism is inspired from &xep0321; permission request.</p>