<?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>Remote Authentication</title>
  <abstract>This document defines an XMPP protocol extension that enables entities to use SASL for authentication with remote services (such as Multi-User Chat rooms).</abstract>
  &LEGALNOTICE;
  <number>XXXX</number>
  <status>ProtoXEP</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>RFC 3920</spec>
    <spec>RFC 4422</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>none</shortname>
  &stpeter;
  <revision>
    <version>0.0.1</version>
    <date>2010-12-01</date>
    <initials>psa</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>
<section1 topic='Introduction' anchor='intro'>
  <p>At present, XMPP entities use SASL &rfc4422; for authentication of XML streams but do not have strong authentication methods available for authentication of interactions with remote entities. One glaring example is &xep0045;, which uses only plaintext passwords for authentication. Stronger authentication technologies would be preferable. This document defines one such approach: re-use of the XMPP-specific profile of SASL already defined in &xmppcore;.</p>
</section1>
<section1 topic='How It Works' anchor='how'>
  <p>This specification simply re-uses the existing XML namespace defined in <cite>XMPP Core</cite>, and encapsulates the interactions in XMPP &IQ; stanzas.</p>
  <p>Consider an attempt by an XMPP client to join a MUC room:</p>
  <example caption='User Seeks to Enter a Chatroom'><![CDATA[
<presence
    from='hag66@shakespeare.lit/pda'
    to='coven@chat.shakespeare.lit/thirdwitch'>
  <x xmlns='http://jabber.org/protocol/muc'/>
</presence>
  ]]></example>
  <p>As MUC is currently defined, the service would return a &notauthorized; stanza error:</p>
  <example caption='Service Denies Access Because No Password Provided'><![CDATA[
<presence
    from='coven@chat.shakespeare.lit'
    to='hag66@shakespeare.lit/pda'
    type='error'>
  <x xmlns='http://jabber.org/protocol/muc'/>
  <error type='auth'>
    <not-authorized xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</presence>
  ]]></example>
  <p>The client would then log in with a plaintext password:</p>
  <example caption='User Provides Password On Entering a Room'><![CDATA[
<presence
    from='hag66@shakespeare.lit/pda'
    to='coven@chat.shakespeare.lit/thirdwitch'>
  <x xmlns='http://jabber.org/protocol/muc'>
    <password>cauldronburn</password>
  </x>
</presence>
  ]]></example>
  <p>This document proposes instead that the service would return a &notauthorized; stanza error along with an application-specific error condition &xep0182; of &lt;sasl-required/&gt;.</p>
  <example caption='Service Denies Access Because No Password Provided'><![CDATA[
<presence
    from='coven@chat.shakespeare.lit'
    to='hag66@shakespeare.lit/pda'
    type='error'>
  <x xmlns='http://jabber.org/protocol/muc'/>
  <error type='auth'>
    <not-authorized xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
    <sasl-required xmlns='urn:xmpp:errors'/>
  </error>
</presence>
  ]]></example>
  <p>The client would then initiate an in-band SASL negotiation with the chatroom.</p>
  <p>First, the client will request the mechanisms supported by the chatroom.</p>
  <example caption='Client Requests Supported Mechanisms'><![CDATA[
<iq from='hag66@shakespeare.lit/pda'
    id='ja71b37f'
    to='coven@chat.shakespeare.lit'
    type='get'>
  <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
</iq>
  ]]></example>
  <p>The service then returns its list of supported mechanisms.</p>
  <example caption='Service Returns Supported Mechanisms'><![CDATA[
<iq from='coven@chat.shakespeare.lit'
    id='ja71b37f'
    to='hag66@shakespeare.lit/pda'
    type='result'>
  <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
    <mechanism>EXTERNAL</mechanism>
    <mechanism>SCRAM-SHA-1</mechanism>
    <mechanism>PLAIN</mechanism>
  </mechanisms>
</iq>
  ]]></example>
  <p>The client can then begin the authentication handshake using one of the advertised mechanisms.</p>
  <example caption='Client Chooses a Mechanism'><![CDATA[
<iq from='hag66@shakespeare.lit/pda'
    id='ib2va629'
    to='coven@chat.shakespeare.lit'
    type='set'>
  <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
        mechanism='SCRAM-SHA-1'>
     biwsbj1qdWxpZXQscj1vTXNUQUF3QUFBQU1BQUFBTlAwVEFBQUFBQUJQVTBBQQ==
  </auth>
</iq>
  ]]></example>
  <p>The handshake proceeds through a series of challenges and responses.</p>
  <example caption='Service Returns a Challenge'><![CDATA[
<iq from='coven@chat.shakespeare.lit'
    id='ib2va629'
    to='hag66@shakespeare.lit/pda'
    type='result'>
  <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
    cj1vTXNUQUF3QUFBQU1BQUFBTlAwVEFBQUFBQUJQVTBBQWUxMjQ2OTViLTY5Y
    TktNGRlNi05YzMwLWI1MWIzODA4YzU5ZSxzPU5qaGtZVE0wTURndE5HWTBaaT
    AwTmpkbUxUa3hNbVV0TkRsbU5UTm1ORE5rTURNeixpPTQwOTY=
  </challenge>
</iq>
  ]]></example>
  <example caption='Client Responds to the Challenge'><![CDATA[
<iq from='hag66@shakespeare.lit/pda'
    id='qh3bx613'
    to='coven@chat.shakespeare.lit'
    type='set'>
  <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
    Yz1iaXdzLHI9b01zVEFBd0FBQUFNQUFBQU5QMFRBQUFBQUFCUFUwQUFlMTI0N
    jk1Yi02OWE5LTRkZTYtOWMzMC1iNTFiMzgwOGM1OWUscD1VQTU3dE0vU3ZwQV
    RCa0gyRlhzMFdEWHZKWXc9
  </response>
</iq>
  ]]></example>
  <example caption='Service Informs Client of Success'><![CDATA[
<iq from='coven@chat.shakespeare.lit'
    id='qh3bx613'
    to='hag66@shakespeare.lit/pda'
    type='result'>
  <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
     dj1wTk5ERlZFUXh1WHhDb1NFaVc4R0VaKzFSU289
   </success>
</iq>
  ]]></example>
  <p>Having been authenticated, the client can now join the chatroom.</p>
  <example caption='User Enters the Chatroom'><![CDATA[
<presence
    from='hag66@shakespeare.lit/pda'
    to='coven@chat.shakespeare.lit/thirdwitch'>
  <x xmlns='http://jabber.org/protocol/muc'/>
</presence>
  ]]></example>
  <p>OPEN ISSUE: does the client need to provide a token of some kind here, or is it sufficient to send a stanza from the authenticated resource?</p>
</section1>
<section1 topic='Security Considerations' anchor='security'>
  <p>There is no guarantee that stanzas sent over multiple hops will be protected with regard to confidentiality or integrity across all hops. This failing leads to the possibility of man-in-the-middle attacks. No solution to that problem is proposed in this document.</p>
</section1>
<section1 topic='IANA Considerations' anchor='iana'>
  <p>This document requires no action on the part of &IANA;.</p>
</section1>
<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  <p>The &REGISTRAR; shall add an error condition of &lt;sasl-required/&gt; to its registry of application-specific error conditions located at &APPERRORS;. The registration is as follows:</p>
  <code caption='Registry Submission'><![CDATA[
<condition>
  <ns>urn:xmpp:errors</ns>
  <element>sasl-required</element>
  <desc>authentication via SASL is required in order to perform the requested action</desc>
  <doc>XEP-XXXX</doc>
</condition>
  ]]></code>
</section1>
<section1 topic='XML Schema' anchor='schema'>
  <p>The schema from RFC 3920 applies.</p>
</section1>
</xep>

