<abstract>This specification defines an XMPP extension for generating, requesting, and using authorization tokens, which can be used to join Multi-User Chat rooms, subscribe to Publish-Subscribe nodes, and even register XMPP accounts.</abstract>
<p>Although authentication is required in order to access an XMPP network, in some situations it is desirable to require authorization in order to access certain entities on the network. For example, authorization may be required in order to join a &xep0045; room or to subscribe to a &xep0060; node. This document defines a general method for obtaining, sharing, and using authorization tokens over XMPP.</p>
<section1topic='Obtaining an Authorization Token'anchor='obtain'>
<p>In order to obtain an authorization token that can be sent to a consumer, a user requests an authorization token from the relevant service. For example, let us imagine that the user <crone1@shakespeare.lit> wishes to invite the consumer <hecate@shakespeare.lit> to the chatroom <darkcave@macbeth.shakespeare.lit>. Assuming that the user has already determined that the chatroom supports authorization tokens, the user would send the following request to the room &NSNOTE;.</p>
<p>If the room supports authorization tokens and the user is allowed to invite contacts to the room, the room returns an authorization token to the user.</p>
<li>The OPTIONAL 'expires' attribute defines a date and time when the token expires. If included, it MUST be a DateTime as specified in &xep0082;.</li>
<li>The REQUIRED 'consumer' attribute defines the URI of the entity to be authorized (e.g., an XMPP URI, mailto URI, or HTTP URL).</li>
<li>The REQUIRED 'service' attribute defines the JabberID of the service for which the consumer is being authorized.</li>
<li>The OPTIONAL 'node' attribute defines a publish-subscribe node at the service; if the 'node' attribute is included, the authorization MUST be accepted only for interactions with that particular node.</li>
<li>The XML character data of the <token/> element is the authorization token itself.</li>
<section1topic='Generating an Authorization Token'anchor='generate'>
<p>A service MAY use any algorithm in generating an authorization token. Depending on implementation and deployment policies, the algorithm MAY take into account the URI of the consumer and be limited to use by an entity that communicates via that URI. Acceptable algorithms MAY include those defined by other standards development organizations, such as &oauth;.</p>
</section1>
<section1topic='Sharing an Authorization Token'anchor='share'>
<p>The user can then send the authorization token to the consumer in an XMPP message stanza:</p>
<examplecaption='Sharing the authorization token'><![CDATA[
<section1topic='Using an Authorization Token'anchor='use'>
<p>If the consumer wishes to use the token, it MUST first determine the identity of the service (via &xep0030;) so that it can decide how to proceed.</p>
<p>Note: If the service supports this protocol, it MUST return a service discovery feature of "urn:xmpp:tmp:auth-token" in response to each disco#info request (see the <linkurl='#support'>Determining Support</link> section of this document).</p>
<section2topic='Multi-User Chat'anchor='use-muc'>
<p>In this example, the service is a multi-user chat service. If authorization is required in order to join a particular room but the joining entity does not include an authorization token in its join request, the service MUST return an error as follows.</p>
<examplecaption='Chatroom join without token'><![CDATA[
<p>If the token is acceptable, the service will then allow the consumer to enter the room.</p>
<p>Note: Although <cite>XEP-0045</cite> includes a protocol for inviting a contact to a chatroom, that protocol results in the sending of an invitation from the chatroom to the contact (a "mediated invitation"), not from the inviting user to the contact (a "direct invitation"). Because use of &xep0016; may result in blocking of XML stanzas from entities that are not in the contact's roster, mediated invitations may never be delivered to the contact. Use of authorization tokens as described herein enables a user to directly send an invitation to a contact, thus routing around the blocking of mediated invitations.</p>
<p>In this example, the service is a publish-subscribe service. If authorization is required in order to subscribe to a particular node but the subscribing entity does not include an authorization token in its subscribe request, the service MUST return an error as follows.</p>
<examplecaption='Subscription request without token'><![CDATA[
<p>In this example, the service allows new account registration using &xep0077;. The registering entity SHOULD request the registration form before attempting to register.</p>
<p>If a service provides and accepts authorization tokens, it MUST advertise support for the 'urn:xmpp:tmp:auth-token' namespace in its disco#info replies (if provided) its &xep0115; notations &NSNOTE;.</p>
<p>Until this specification advances to a status of Draft, its associated namespace shall be "urn:xmpp:tmp:auth-token"; upon advancement of this specification, the ®ISTRAR; shall issue a permanent namespace in accordance with the process defined in Section 4 of &xep0053;.</p>
<p>Thanks to Dave Cridland and Pedro Melo for their suggestions. Aspects of this specification were inspired by &rfc4467;. Some of the terminology in this specification was borrowed from OAuth.</p>