No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0235.xml 18KB

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>OAuth Over XMPP</title>
  10. <abstract>This specification defines an XMPP extension for delegating access to protected resources over XMPP, using the OAuth protocol.</abstract>
  12. <number>0235</number>
  13. <status>Deferred</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <approver>Council</approver>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. </dependencies>
  20. <supersedes/>
  21. <supersededby/>
  22. <shortname>NOT_YET_ASSIGNED</shortname>
  23. &stpeter;
  24. <revision>
  25. <version>0.7</version>
  26. <date>2009-03-24</date>
  27. <initials>psa</initials>
  28. <remark><p>Changed protocol namespace from urn:xmpp:tmp:oauth to urn:xmpp:oauth:0 to conform to XMPP Registrar policies; clarified protocol flow and error handling; corrected examples.</p></remark>
  29. </revision>
  30. <revision>
  31. <version>0.6</version>
  32. <date>2008-08-07</date>
  33. <initials>psa</initials>
  34. <remark><p>Clarified error handling and service discovery.</p></remark>
  35. </revision>
  36. <revision>
  37. <version>0.5</version>
  38. <date>2008-08-07</date>
  39. <initials>psa</initials>
  40. <remark><p>More clearly specified access request format; corrected examples to incorporate nonce, timestamp, and version; modified request URL syntax to follow XML canonicalization order; changed HMAC-SHA1 from MUST to SHOULD.</p></remark>
  41. </revision>
  42. <revision>
  43. <version>0.4</version>
  44. <date>2008-08-07</date>
  45. <initials>psa</initials>
  46. <remark><p>Incorporated consensus reached at XMPP Summit #5: narrowed the scope to cover OAuth only, specified that HTTP is used except for sending the access request via XMPP, corrected signature generation algorithm, specified security considerations, and removed invitation and account registration use cases.</p></remark>
  47. </revision>
  48. <revision>
  49. <version>0.3</version>
  50. <date>2008-03-31</date>
  51. <initials>psa</initials>
  52. <remark><p>Changed data forms usage to semantic XML format (except for in-band registration).</p></remark>
  53. </revision>
  54. <revision>
  55. <version>0.2</version>
  56. <date>2008-03-27</date>
  57. <initials>psa</initials>
  58. <remark><p>Generalized to cover authorization tokens; added use cases for pubsub node subscriptions and XMPP account registration.</p></remark>
  59. </revision>
  60. <revision>
  61. <version>0.1</version>
  62. <date>2008-03-05</date>
  63. <initials>psa</initials>
  64. <remark><p>Initial published version.</p></remark>
  65. </revision>
  66. <revision>
  67. <version>0.0.1</version>
  68. <date>2008-02-20</date>
  69. <initials>psa</initials>
  70. <remark><p>First draft.</p></remark>
  71. </revision>
  72. </header>
  73. <section1 topic='Introduction' anchor='intro'>
  74. <p>Although authentication is required in order to access the XMPP network, in some situations it is desirable to require authorization in order for an authenticated entity to access certain resources on the network. For example, authorization may be required to join a &xep0045; room, subscribe to a &xep0060; node, or to access other resources of interest (such as a media relay or communications gateway).</p>
  75. <p>Dedicated technologies exist for authorization. One such technology is &oauth;, as defined at &lt;<link url=''></link>&gt;. In the language of OAuth, a User can authorize a Consumer to access a Protected Resource that is hosted by a Service Provider; this authorization is encapsulated in a token that the User requests from the Service Provider, that the User shares with the Consumer, and that the Consumer then presents to the Service Provider in an access request.</p>
  76. <p>This specification assumes that OAuth Access Tokens will be acquired outside the XMPP (i.e., via HTTP as defined in the core OAuth specification) and merely presented over XMPP when sending a protocol-specific access request.</p>
  77. </section1>
  78. <section1 topic='Protocol Flow' anchor='flow'>
  79. <p>The typical scenario is for a Consumer to request the authorization to act as a delegated authority on behalf of the User to access a Protected Resource owned by the User at a Service Provider. For example, the owner of a pubsub node could allow a remote entity to publish to that node (the single lines "---" show protocol flows over HTTP and the double lines "===" show protocol flows over XMPP):</p>
  80. <code><![CDATA[
  81. Consumer Service Provider
  82. | |
  83. | request a Request Token |
  84. |---------------------------->|
  85. | grant the Request Token |
  86. |<----------------------------|
  87. | |
  88. | [Consumer redirects User |
  89. | to Service Provider] |
  90. | |
  91. | request an Access Token |
  92. |---------------------------->|
  93. | grant the Access Token |
  94. |<----------------------------|
  95. | access Protected Resource |
  96. |============================>|
  97. | |
  98. ]]></code>
  99. <p>Before presenting an access token to a Service Provider in a protocol-specific access request, a Consumer SHOULD verify that the Service Provider supports this protocol, as described under the <link url='#support'>Determining Support</link> section of this document.</p>
  100. <p>Consider the example of a User (say, &lt;;) who wishes to authorize a Consumer (say, an application called FindMeNow as represented by the JID &lt;travelbot@findmenow.tld&gt;) to access the User's geolocation feed at a Service Provider called WorldGPS (as represented by a publish-subscribe node of &lt;feeds.worldgps.tld/world-traveler&gt;). The order of events might be as follows.</p>
  101. <ol start='1'>
  102. <li>FindMeNow has registered as a Consumer for WorldGPS' API and has been assigned an OAuth consumer key and secret for use in its dealings with WorldGPS.</li>
  103. <li>The User registers with WorldGPS, which creates a feed for the User's location data in an XMPP PubSub Node at WorldGPS.</li>
  104. <li>The User visits FindMeNow.tld and requests real-time updates from his WorldGPS feed.</li>
  105. <li>FindMeNow, over HTTP, requests an OAuth "request token" from WorldGPS, signing it with FindMeNow's OAuth consumer key and secret.</li>
  106. <li>WorldGPS, if the signature was valid, sends FindMeNow an OAuth "request token."</li>
  107. <li>FindMeNow then redirects the user to a WorldGPS webpage.</li>
  108. <li>On the WorldGPS webpage, the User logs in (or is already logged in) and is then asked whether to approve of FindMeNow having read-only access to his geolocation information.</li>
  109. <li>The User approves the request and WorldGPS redirects the User back to FindMeNow.</li>
  110. <li>FindMeNow, over HTTP, requests an OAuth "access token" from WorldGPS, signing the request with the "request token" that has now been approved by the User.</li>
  111. <li>WorldGPS, if the signature is correct and the request token was approved, replies to FindMeNow with an OAuth "access token".</li>
  112. <li>FindMeNow, over XMPP, subscribes to the User's pubsub node using the OAuth "access token" as described below.</li>
  113. </ol>
  114. <p>As a result, FindMeNow gets updated every time the User publishes items to his geolocation node at WorldGPS.</p>
  115. <p>Steps 1-10 describe OAuth's standard HTTP flow and represent an out-band means for obtaining OAuth access tokens for use in XMPP operations.</p>
  116. </section1>
  117. <section1 topic='Access Request Format' anchor='request'>
  118. <p>The access request MUST include the following parameters:</p>
  119. <ul>
  120. <li>oauth_consumer_key</li>
  121. <li>oauth_nonce</li>
  122. <li>oauth_signature (note: in XMPP this value is <strong>not</strong> escaped)</li>
  123. <li>oauth_signature_method</li>
  124. <li>oauth_timestamp</li>
  125. <li>oauth_token</li>
  126. </ul>
  127. <p>The access MAY also include the "oauth_version" parameter</p>
  128. <p>An example follows.</p>
  129. <example caption='Pubsub subscription request with OAuth access token'><![CDATA[
  130. <iq from='travelbot@findmenow.tld/bot'
  131. id='sub1'
  132. to='feeds.worldgps.tld'
  133. type='set'>
  134. <pubsub xmlns=''>
  135. <subscribe jid='travelbot@findmenow.tld' node='bard_geoloc'/>
  136. <oauth xmlns='urn:xmpp:oauth:0'>
  137. <oauth_consumer_key>0685bd9184jfhq22</oauth_consumer_key>
  138. <oauth_nonce>4572616e48616d6d65724c61686176</oauth_nonce>
  139. <oauth_signature>9PQkM4YKgaM067wqrDGshXOwDW0=</oauth_signature>
  140. <oauth_signature_method>HMAC-SHA1</oauth_signature_method>
  141. <oauth_timestamp>1218137833</oauth_timestamp>
  142. <oauth_token>ad180jjd733klru7</oauth_token>
  143. <oauth_version>1.0</oauth_version>
  144. </oauth>
  145. </pubsub>
  146. </iq>
  147. ]]></example>
  148. </section1>
  149. <section1 topic='Signature Generation Algorithm' anchor='signature'>
  150. <p>When sending an OAuth access request over XMPP, the signature method SHOULD be HMAC-SHA1. The Signature Base String SHALL be constructed from the following items:</p>
  151. <ul>
  152. <li>The HTTP request method SHALL be the qname of the XMPP stanza element used, that is, either "message" or "presence" or "iq".</li>
  153. <li>The request URL SHALL be the 'from' address of the XMPP stanza concatenated with the ampersand character "&amp;" and the 'to' address of the XMPP stanza.</li>
  154. <li>The normalized request parameters string SHALL be all of the oauth_* parameters included in the &lt;oauth/&gt; element (except oauth_signature).</li>
  155. </ul>
  156. <p>As an example, consider the stanza shown above.</p>
  157. <p>The Signature Base String would be as follows (where line endings have been added for readability and are denoted by the "\" character):</p>
  158. <code><![CDATA[
  159. iq%26travelbot%40findmenow.tld%2Fbot%26feeds.worldgps.tld%26\
  160. oauth_consumer_key%3D0685bd9184jfhq22%26\
  161. oauth_nonce%3D4572616e48616d6d65724c61686176%26\
  162. oauth_signature_method%3DHMAC-SHA1%26\
  163. oauth_timestamp%3D1218137833%26\
  164. oauth_token%3Dad180jjd733klru7%26\
  165. oauth_version%3D1.0
  166. ]]></code>
  167. <p>Assuming a consumer secret of 'consumersecret' and a token secret of 'tokensecret', the signature will be:</p>
  168. <code><![CDATA[
  169. 9PQkM4YKgaM067wqrDGshXOwDW0=
  170. ]]></code>
  171. </section1>
  172. <section1 topic='Error Handling' anchor='error'>
  173. <p>If a Service Provider rejects a Consumer's request to access a Protected Resource over XMPP, the Service Provider MUST return an XMPP stanza error. The XMPP error condition SHOULD be either &badrequest; or &notauthorized; and the stanza SHOULD include an OAuth-specific error condition as described in the following table.</p>
  174. <table caption='Application-Specific Error Conditions'>
  175. <tr>
  176. <th>OAuth-Specific Condition</th>
  177. <th>Generic Condition</th>
  178. <th>Description</th>
  179. </tr>
  180. <tr>
  181. <td>&lt;duplicated-parameter/&gt;</td>
  182. <td>&badrequest;</td>
  183. <td>One of the oauth_* elements was included more than once.</td>
  184. </tr>
  185. <tr>
  186. <td>&lt;invalid-consumer-key/&gt;</td>
  187. <td>&notauthorized;</td>
  188. <td>The Consumer's OAuth consumer key is not valid.</td>
  189. </tr>
  190. <tr>
  191. <td>&lt;invalid-nonce/&gt;</td>
  192. <td>&notauthorized;</td>
  193. <td>The provided nonce is invalid; it might have already been used.</td>
  194. </tr>
  195. <tr>
  196. <td>&lt;invalid-signature/&gt;</td>
  197. <td>&notauthorized;</td>
  198. <td>The provided signature is invalid; the Consumer needs to confirm that the signature base string is calculated correctly.</td>
  199. </tr>
  200. <tr>
  201. <td>&lt;invalid-token/&gt;</td>
  202. <td>&notauthorized;</td>
  203. <td>The provided access token is invalid; it might have been revoked.</td>
  204. </tr>
  205. <tr>
  206. <td>&lt;missing-parameter/&gt;</td>
  207. <td>&badrequest;</td>
  208. <td>One of the required oauth_* elements is missing.</td>
  209. </tr>
  210. <tr>
  211. <td>&lt;token-required/&gt;</td>
  212. <td>&notauthorized;</td>
  213. <td>The Consumer did not include an OAuth access token in its request; this error condition is XMPP-specific and does not have a counterpart in the OAuth specification.</td>
  214. </tr>
  215. <tr>
  216. <td>&lt;unsupported-parameter/&gt;</td>
  217. <td>&badrequest;</td>
  218. <td>The &lt;oauth/&gt; stanza contains unknown or unsupported parameters.</td>
  219. </tr>
  220. <tr>
  221. <td>&lt;unsupported-signature-method/&gt;</td>
  222. <td>&badrequest;</td>
  223. <td>The specified signature method is not supported by the server.</td>
  224. </tr>
  225. </table>
  226. <p>An example follows.</p>
  227. <example caption='OAuth-specific error'><![CDATA[
  228. <iq from='feeds.worldgps.tld'
  229. id='sub1'
  230. to='travelbot@findmenow.tld/bot'
  231. type='error'>
  232. <error type='modify'>
  233. <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  234. <invalid-nonce xmlns='urn:xmpp:oauth:0:errors'/>
  235. </error>
  236. </iq>
  237. ]]></example>
  238. </section1>
  239. <section1 topic='Determining Support' anchor='support'>
  240. <p>If an entity supports the protocol specified herein, it MUST advertise that fact by returning a feature of "urn:xmpp:oauth:0" in response to &xep0030; information requests &NSNOTE;.</p>
  241. <example caption="Service discovery information request"><![CDATA[
  242. <iq from='travelbot@findmenow.tld/bot'
  243. id='disco1'
  244. to='feeds.worldgps.tld'
  245. type='get'>
  246. <query xmlns=''/>
  247. </iq>
  248. ]]></example>
  249. <example caption="Service discovery information response"><![CDATA[
  250. <iq from='feeds.worldgps.tld'
  251. id='disco1'
  252. to='travelbot@findmenow.tld/bot'
  253. type='result'>
  254. <query xmlns=''>
  255. <feature var='urn:xmpp:oauth:0'/>
  256. </query>
  257. </iq>
  258. ]]></example>
  259. <p>In order for an application to determine whether an entity supports this protocol, where possible it SHOULD use the dynamic, presence-based profile of service discovery defined in &xep0115;. However, if an application has not received entity capabilities information from an entity, it SHOULD use explicit service discovery instead.</p>
  260. </section1>
  261. <section1 topic='Security Considerations' anchor='security'>
  262. <section2 topic='Replay Attacks' anchor='security-replay'>
  263. <p>Signatures generated according to the signature generation algorithm might be subject to replay attacks. However, inclusion of the XMPP "from" and "to" addresses limits these attacks to compromised servers or client-to-server connections. In addition, inclusion of the nonce value also helps to prevent replay attacks.</p>
  264. </section2>
  265. <section2 topic='Encryption' anchor='security-encryption'>
  266. <p>OAuth tokens SHOULD be sent only over TLS-encrypted client-to-server connections, and all server-to-server connections SHOULD be TLS-enabled. Additional security can be provided using appropriate methods for the end-to-end encryption of XMPP traffic, such as &xep0027;, &rfc3923; &xep0116;, or &xep0246;.</p>
  267. </section2>
  268. </section1>
  269. <section1 topic='IANA Considerations' anchor='iana'>
  270. <p>This document requires no interaction with &IANA;.</p>
  271. </section1>
  272. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  273. <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
  274. <p>This specification defines the following XML namespace:</p>
  275. <ul>
  276. <li>urn:xmpp:oauth:0</li>
  277. </ul>
  278. <p>Upon advancement of this specification from a status of Experimental to a status of Draft, the &REGISTRAR; shall add the foregoing namespaces to the registry located at &NAMESPACES;, as described in Section 4 of &xep0053;.</p>
  279. </section2>
  280. <section2 topic='Protocol Versioning' anchor='registrar-versioning'>
  281. &NSVER;
  282. </section2>
  283. </section1>
  284. <section1 topic='XML Schema' anchor='schema'>
  285. <section2 topic='Protocol Namespace' anchor='schema-proto'>
  286. <code><![CDATA[
  287. <?xml version='1.0' encoding='UTF-8'?>
  288. <xs:schema
  289. xmlns:xs=''
  290. targetNamespace='urn:xmpp:oauth:0'
  291. xmlns='urn:xmpp:oauth:0'
  292. elementFormDefault='qualified'>
  293. <xs:element name='oauth'>
  294. <xs:complexType>
  295. <xs:choice>
  296. <xs:element name='oauth_consumer_key' type='xs:string'/>
  297. <xs:element name='oauth_nonce' type='xs:string'/>
  298. <xs:element name='oauth_signature' type='xs:string'/>
  299. <xs:element name='oauth_signature_method' type='xs:string'/>
  300. <xs:element name='oauth_timestamp' type='xs:string'/>
  301. <xs:element name='oauth_token' type='xs:string'/>
  302. <xs:element name='oauth_version' type='xs:string'/>
  303. </xs:choice>
  304. </xs:complexType>
  305. </xs:element>
  306. </xs:schema>
  307. ]]></code>
  308. </section2>
  309. <section2 topic='Error Namespace' anchor='schema-error'>
  310. <code><![CDATA[
  311. <?xml version='1.0' encoding='UTF-8'?>
  312. <xs:schema
  313. xmlns:xs=''
  314. targetNamespace='urn:xmpp:oauth:0:errors'
  315. xmlns='urn:xmpp:oauth:0:errors'
  316. elementFormDefault='qualified'>
  317. <xs:element name='duplicated-parameter' type='empty'/>
  318. <xs:element name='invalid-consumer-key' type='empty'/>
  319. <xs:element name='invalid-nonce' type='empty'/>
  320. <xs:element name='invalid-signature' type='empty'/>
  321. <xs:element name='invalid-token' type='empty'/>
  322. <xs:element name='missing-parameter' type='empty'/>
  323. <xs:element name='token-required' type='empty'/>
  324. <xs:element name='unsupported-parameter' type='empty'/>
  325. <xs:element name='unsupported-signature-method' type='empty'/>
  326. <xs:simpleType name='empty'>
  327. <xs:restriction base='xs:string'>
  328. <xs:enumeration value=''/>
  329. </xs:restriction>
  330. </xs:simpleType>
  331. </xs:schema>
  332. ]]></code>
  333. </section2>
  334. </section1>
  335. <section1 topic='Acknowledgements' anchor='ack'>
  336. <p>The author gratefully acknowledges the contributions of Blaine Cook, Leah Culver, Kellan Elliott-McCrea, Seth Fitzsimmons, Nathan Fritz, Evan Henshaw-Plath, Joe Hildebrand, and Ralph Meijer to the content of this specification, as provided during the XMPP Summit held in Portland, Oregon, on July 21 and 22, 2008. Thanks also to Dave Cridland and Pedro Melo for their comments on an early draft. Seth Fitzsimmons checked many details and provided text regarding the protocol flow and error handling.</p>
  337. </section1>
  338. </xep>