idnits 2.17.1 draft-ietf-kitten-sasl-oauth-21.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (April 17, 2015) is 3297 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) ** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446) ** Obsolete normative reference: RFC 5849 (Obsoleted by RFC 6749) ** Obsolete normative reference: RFC 7159 (Obsoleted by RFC 8259) == Outdated reference: A later version (-30) exists of draft-ietf-oauth-dyn-reg-27 -- Obsolete informational reference (is this intentional?): RFC 3501 (Obsoleted by RFC 9051) -- Obsolete informational reference (is this intentional?): RFC 7230 (Obsoleted by RFC 9110, RFC 9112) Summary: 3 errors (**), 0 flaws (~~), 2 warnings (==), 3 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 KITTEN W. Mills 3 Internet-Draft Microsoft 4 Intended status: Standards Track T. Showalter 5 Expires: October 19, 2015 6 H. Tschofenig 7 ARM Ltd. 8 April 17, 2015 10 A set of SASL Mechanisms for OAuth 11 draft-ietf-kitten-sasl-oauth-21.txt 13 Abstract 15 OAuth enables a third-party application to obtain limited access to a 16 protected resource, either on behalf of a resource owner by 17 orchestrating an approval interaction, or by allowing the third-party 18 application to obtain access on its own behalf. 20 This document defines how an application client uses credentials 21 obtained via OAuth over the Simple Authentication and Security Layer 22 (SASL) to access a protected resource at a resource serve. Thereby, 23 it enables schemes defined within the OAuth framework for non-HTTP- 24 based application protocols. 26 Clients typically store the user's long-term credential. This does, 27 however, lead to significant security vulnerabilities, for example, 28 when such a credential leaks. A significant benefit of OAuth for 29 usage in those clients is that the password is replaced by a shared 30 secret with higher entropy, i.e., the token. Tokens typically 31 provide limited access rights and can be managed and revoked 32 separately from the user's long-term password. 34 Status of This Memo 36 This Internet-Draft is submitted in full conformance with the 37 provisions of BCP 78 and BCP 79. 39 Internet-Drafts are working documents of the Internet Engineering 40 Task Force (IETF). Note that other groups may also distribute 41 working documents as Internet-Drafts. The list of current Internet- 42 Drafts is at http://datatracker.ietf.org/drafts/current/. 44 Internet-Drafts are draft documents valid for a maximum of six months 45 and may be updated, replaced, or obsoleted by other documents at any 46 time. It is inappropriate to use Internet-Drafts as reference 47 material or to cite them other than as "work in progress." 48 This Internet-Draft will expire on October 19, 2015. 50 Copyright Notice 52 Copyright (c) 2015 IETF Trust and the persons identified as the 53 document authors. All rights reserved. 55 This document is subject to BCP 78 and the IETF Trust's Legal 56 Provisions Relating to IETF Documents 57 (http://trustee.ietf.org/license-info) in effect on the date of 58 publication of this document. Please review these documents 59 carefully, as they describe your rights and restrictions with respect 60 to this document. Code Components extracted from this document must 61 include Simplified BSD License text as described in Section 4.e of 62 the Trust Legal Provisions and are provided without warranty as 63 described in the Simplified BSD License. 65 Table of Contents 67 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 68 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 5 69 3. OAuth SASL Mechanism Specifications . . . . . . . . . . . . . 6 70 3.1. Initial Client Response . . . . . . . . . . . . . . . . . 7 71 3.1.1. Reserved Key/Values . . . . . . . . . . . . . . . . . 8 72 3.2. Server's Response . . . . . . . . . . . . . . . . . . . . 8 73 3.2.1. OAuth Identifiers in the SASL Context . . . . . . . . 9 74 3.2.2. Server Response to Failed Authentication . . . . . . 9 75 3.2.3. Completing an Error Message Sequence . . . . . . . . 10 76 3.3. OAuth Access Token Types using Keyed Message Digests . . 10 77 4. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 11 78 4.1. Successful Bearer Token Exchange . . . . . . . . . . . . 12 79 4.2. Successful OAuth 1.0a Token Exchange . . . . . . . . . . 13 80 4.3. Failed Exchange . . . . . . . . . . . . . . . . . . . . . 13 81 4.4. SMTP Example of a Failed Negotiation . . . . . . . . . . 14 82 5. Security Considerations . . . . . . . . . . . . . . . . . . . 15 83 6. Internationalization Considerations . . . . . . . . . . . . . 16 84 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 17 85 7.1. SASL Registration . . . . . . . . . . . . . . . . . . . . 17 86 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 18 87 8.1. Normative References . . . . . . . . . . . . . . . . . . 18 88 8.2. Informative References . . . . . . . . . . . . . . . . . 19 89 Appendix A. Acknowlegements . . . . . . . . . . . . . . . . . . 19 90 Appendix B. Document History . . . . . . . . . . . . . . . . . . 20 91 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 23 93 1. Introduction 95 OAuth 1.0a [RFC5849] and OAuth 2.0 [RFC6749] are protocol frameworks 96 that enable a third-party application to obtain limited access to a 97 protected resource, either on behalf of a resource owner by 98 orchestrating an approval interaction, or by allowing the third-party 99 application to obtain access on its own behalf. 101 The core OAuth 2.0 specification [RFC6749] specifies the interaction 102 between the OAuth client and the authorization server; it does not 103 define the interaction between the OAuth client and the resource 104 server for the access to a protected resource using an Access Token. 105 Instead, the OAuth client to resource server interaction is described 106 in separate specifications, such as the bearer token specification 107 [RFC6750]. OAuth 1.0a included the protocol specification for the 108 communication between the OAuth client and the resource server in 109 [RFC5849]. 111 The main use cases for OAuth 2.0 and OAuth 1.0a have so far focused 112 on an HTTP-based [RFC7230] environment only. This document 113 integrates OAuth 1.0a and OAuth 2.0 into non-HTTP-based applications 114 using the integration into SASL. Hence, this document takes 115 advantage of the OAuth protocol and its deployment base to provide a 116 way to use the Simple Authentication and Security Layer (SASL) 117 [RFC4422] to gain access to resources when using non-HTTP-based 118 protocols, such as the Internet Message Access Protocol (IMAP) 119 [RFC3501] and the Simple Mail Transfer Protocol (SMTP) [RFC5321], 120 which is what this memo uses in the examples. 122 To illustrate the impact of integrating this specification into an 123 OAuth-enabled application environment, Figure 1 shows the abstract 124 message flow of OAuth 2.0 [RFC6749]. As indicated in the figure, 125 this document impacts the exchange of messages (E) and (F) since SASL 126 is used for interaction between the client and the resource server 127 instead of HTTP. 129 ----+ 130 +--------+ +---------------+ | 131 | |--(A)-- Authorization Request --->| Resource | | 132 | | | Owner | |Plain 133 | |<-(B)------ Access Grant ---------| | |OAuth 134 | | +---------------+ |2.0 135 | | | 136 | | Client Credentials & +---------------+ | 137 | |--(C)------ Access Grant -------->| Authorization | | 138 | Client | | Server | | 139 | |<-(D)------ Access Token ---------| | | 140 | | (w/ Optional Refresh Token) +---------------+ | 141 | | ----+ 142 | | ----+ 143 | | +---------------+ | 144 | | | | |OAuth 145 | |--(E)------ Access Token -------->| Resource | |over 146 | | | Server | |SASL 147 | |<-(F)---- Protected Resource -----| | | 148 | | | | | 149 +--------+ +---------------+ | 150 ----+ 152 Figure 1: OAuth 2.0 Protocol Flow 154 The Simple Authentication and Security Layer (SASL) is a framework 155 for providing authentication and data security services in 156 connection-oriented protocols via replaceable authentication 157 mechanisms. It provides a structured interface between protocols and 158 mechanisms. The resulting framework allows new protocols to reuse 159 existing authentication mechanisms and allows old protocols to make 160 use of new authentication mechanisms. The framework also provides a 161 protocol for securing subsequent exchanges within a data security 162 layer. 164 When OAuth is integrated into SASL the high-level steps are as 165 follows: 167 (A) The client requests authorization from the resource owner. 168 The authorization request can be made directly to the resource 169 owner (as shown), or preferably indirectly via the authorization 170 server as an intermediary. 172 (B) The client receives an authorization grant which is a 173 credential representing the resource owner's authorization, 174 expressed using one of the grant types defined in [RFC6749] or 175 [RFC5849] or using an extension grant type. The authorization 176 grant type depends on the method used by the client to request 177 authorization and the types supported by the authorization server. 179 (C) The client requests an access token by authenticating with the 180 authorization server and presenting the authorization grant. 182 (D) The authorization server authenticates the client and 183 validates the authorization grant, and if valid issues an access 184 token. 186 (E) The client requests the protected resource from the resource 187 server and authenticates by presenting the access token. 189 (F) The resource server validates the access token, and if valid, 190 indicates a successful authentication. 192 Again, steps (E) and (F) are not defined in [RFC6749] (but are 193 described in, for example, [RFC6750] for the OAuth Bearer Token 194 instead) and are the main functionality specified within this 195 document. Consequently, the message exchange shown in Figure 1 is 196 the result of this specification. The client will generally need to 197 determine the authentication endpoints (and perhaps the service 198 endpoints) before the OAuth 2.0 protocol exchange messages in steps 199 (A)-(D) are executed. The discovery of the resource owner, 200 authorization server endpoints, and client registration are outside 201 the scope of this specification. The client must discover the 202 authorization endpoints using a discovery mechanism such as OpenID 203 Connect Discovery [OpenID.Discovery] or Webfinger using host-meta 204 [RFC7033]. Once credentials are obtained the client proceeds to 205 steps (E) and (F) defined in this specification. Authorization 206 endpoints MAY require client registration and generic clients SHOULD 207 support the Dynamic Client Registration protocol 208 [I-D.ietf-oauth-dyn-reg]. 210 OAuth 1.0 follows a similar model but uses a different terminology 211 and does not separate the resource server from the authorization 212 server. 214 2. Terminology 216 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 217 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 218 "OPTIONAL" in this document are to be interpreted as described in 219 [RFC2119]. 221 The reader is assumed to be familiar with the terms used in the OAuth 222 2.0 specification [RFC6749] and SASL [RFC4422]. 224 In examples, "C:" and "S:" indicate lines sent by the client and 225 server respectively. Line breaks have been inserted for readability. 227 Note that the IMAP SASL specification requires base64 encoding, see 228 Section 4 of [RFC4648], not this memo. 230 3. OAuth SASL Mechanism Specifications 232 SASL is used as an authentication framework in a variety of 233 application layer protocols. This document defines the following 234 SASL mechanisms for usage with OAuth: 236 OAUTHBEARER: OAuth 2.0 bearer tokens, as described in [RFC6750]. 237 RFC 6750 uses Transport Layer Security (TLS) [RFC5246] to 238 secure the protocol interaction between the client and the 239 resource server. 241 OAUTH10A: OAuth 1.0a MAC tokens (using the HMAC-SHA1 keyed 242 message digest), as described in Section 3.4.2 of [RFC5849]. 244 New extensions may be defined to add additional OAuth Access Token 245 Types. Such a new SASL OAuth mechanism can be added by simply 246 registering the new name(s) and citing this specification for the 247 further definition. 249 These mechanisms are client initiated and lock-step, the server 250 always replying to a client message. In the case where the client 251 has and correctly uses a valid token the flow is: 253 1. Client sends a valid and correct initial client response. 255 2. Server responds with a successful authentication. 257 In the case where authentication fails the server sends an error 258 result, then client MUST then send an additional message to the 259 server in order to allow the server to finish the exchange. Some 260 protocols and common SASL implementations do not support both sending 261 a SASL message and finalizing a SASL negotiation. The additional 262 client message in the error case deals with this problem. This 263 exchange is: 265 1. Client sends an invalid initial client response. 267 2. Server responds with an error message. 269 3. Client sends a dummy client response. 271 4. Server fails the authentication. 273 3.1. Initial Client Response 275 Client responses are a GS2 [RFC5801] header followed by zero or more 276 key/value pairs, or may be empty. The gs2-header is defined here for 277 compatibility with GS2 if a GS2 mechanism is formally defined, but 278 this document does not define one. The key/value pairs take the 279 place of the corresponding HTTP headers and values to convey the 280 information necessary to complete an OAuth style HTTP authorization. 281 Unknown key/value pairs MUST be ignored by the server. The ABNF 282 [RFC5234] syntax is: 284 kvsep = %x01 285 key = 1*(ALPHA) 286 value = *(VCHAR / SP / HTAB / CR / LF ) 287 kvpair = key "=" value kvsep 288 ;;gs2-header = See RFC 5801 289 client_resp = (gs2-header kvsep *kvpair kvsep) / kvsep 291 The GS2 header MAY include the user name associated with the resource 292 being accessed, the "authzid". It is worth noting that application 293 protocols are allowed to require an authzid, as are specific server 294 implementations. 296 The client response consisting of only a single kvsep is used only 297 when authentication fails, and is only valid in that context. If 298 sent as the first message from the client the server MAY simply fail 299 the authentication without returning discovery information since 300 there is no user or server name indication. 302 The following keys and corresponding values are defined in the client 303 response: 305 auth (REQUIRED): The payload that would be in the HTTP 306 Authorization header if this OAuth exchange was being carried 307 out over HTTP. 309 host: Contains the host name to which the client connected. In 310 an HTTP context this is the value of the HTTP Host header. 312 port: Contains the port number represented as a decimal positive 313 integer string without leading zeros to which the client 314 connected. 316 For OAuth token types such as OAuth 1.0a that use keyed message 317 digests the client MUST send host and port number key/values, and the 318 server MUST fail an authorization request requiring keyed message 319 digests that are not accompanied by host and port values. In OAuth 320 1.0a for example, the so-called "signature base string calculation" 321 includes the reconstructed HTTP URL. 323 3.1.1. Reserved Key/Values 325 In these mechanisms values for path, query string and post body are 326 assigned default values. OAuth authorization schemes MAY define 327 usage of these in the SASL context and extend this specification. 328 For OAuth Access Token Types that include a keyed message digest of 329 the request the default values MUST be used unless explicit values 330 are provided in the client response. The following key values are 331 reserved for future use: 333 mthd (RESERVED): HTTP method, the default value is "POST". 335 path (RESERVED): HTTP path data, the default value is "/". 337 post (RESERVED): HTTP post data, the default value is "". 339 qs (RESERVED): The HTTP query string, the default value is "". 341 3.2. Server's Response 343 The server validates the response according the specification for the 344 OAuth Access Token Types used. If the OAuth Access Token Type 345 utilizes a keyed message digest of the request parameters then the 346 client must provide a client response that satisfies the data 347 requirements for the scheme in use. 349 The server responds to a successfully verified client message by 350 completing the SASL negotiation. The authenticated identity reported 351 by the SASL mechanism is the identity securely established for the 352 client with the OAuth credential. The application, not the SASL 353 mechanism, based on local access policy determines whether the 354 identity reported by the mechanism is allowed access to the requested 355 resource. Note that the semantics of the authzid is specified by the 356 SASL framework [RFC4422]. 358 3.2.1. OAuth Identifiers in the SASL Context 360 In the OAuth framework the client may be authenticated by the 361 authorization server and the resource owner is authenticated to the 362 authorization server. OAuth access tokens may contain information 363 about the authentication of the resource owner and about the client 364 and may therefore make this information accessible to the resource 365 server. 367 If both identifiers are needed by an application the developer will 368 need to provide a way to communicate that from the SASL mechanism 369 back to the application. 371 3.2.2. Server Response to Failed Authentication 373 For a failed authentication the server returns a JSON [RFC7159] 374 formatted error result, and fails the authentication. The error 375 result consists of the following values: 377 status (REQUIRED): The authorization error code. Valid error 378 codes are defined in the IANA "OAuth Extensions Error Registry" 379 specified in the OAuth 2 core specification. 381 scope (OPTIONAL): An OAuth scope which is valid to access the 382 service. This may be omitted which implies that unscoped 383 tokens are required. If a scope is specified then a single 384 scope is preferred, use of a space separated list of scopes is 385 NOT RECOMMENDED. 387 openid-configuration (OPTIONAL): The URL for a document following 388 the OpenID Provider Configuration Information schema as 389 described in OpenID Connect Discovery (OIDCD) 390 [OpenID.Discovery] section 3 that is appropriate for the user. 391 As specified in OIDCD this will have the "https" URL scheme. 392 This document MUST have all OAuth related data elements 393 populated. The server MAY return different URLs for users in 394 different domains and the client SHOULD NOT cache a single 395 returned value and assume it applies for all users/domains that 396 the server suports. The returned discovery document SHOULD 397 have all data elements required by the OpenID Connect Discovery 398 specification populated. In addition, the discovery document 399 SHOULD contain the 'registration_endpoint' element to identify 400 the endpoint to be used with the Dynamic Client Registration 401 protocol [I-D.ietf-oauth-dyn-reg] to obtain the minimum number 402 of parameters necessary for the OAuth protocol exchange to 403 function. Another comparable discovery or client registration 404 mechanism MAY be used if available. 406 The use of the 'offline_access' scope, as defined in 407 [OpenID.Core] is RECOMMENDED to give clients the capability to 408 explicitly request a refresh token. 410 If the resource server provides a scope then the client MUST always 411 request scoped tokens from the token endpoint. If the resource 412 server does not return a scope the client SHOULD presume an unscoped 413 token is required to access the resource. 415 Since clients may interact with a number of application servers, such 416 as email servers and XMPP [RFC6120] servers, they need to have a way 417 to determine whether dynamic client registration has been performed 418 already and whether an already available refresh token can be re-used 419 to obtain an access token for the desired resource server. This 420 specification RECOMMENDs that a client uses the information in the 421 'iss' element defined in OpenID Connect Core [OpenID.Core] to make 422 this determination. 424 3.2.3. Completing an Error Message Sequence 426 Section 3.6 of SASL [RFC4422] explicitly prohibits additional 427 information in an unsuccessful authentication outcome. Therefore, 428 the error message is sent in a normal message. The client MUST then 429 send either an additional client response consisting of a single %x01 430 (control A) character to the server in order to allow the server to 431 finish the exchange or send a SASL cancellation token as generally 432 defined in section 3.5 of SASL [RFC4422]. A specific example of a 433 cancellation token can be found in IMAP [RFC3501] section 6.2.2. 435 3.3. OAuth Access Token Types using Keyed Message Digests 437 OAuth Access Token Types may use keyed message digests and the client 438 and the resource server may need to perform a cryptographic 439 computation for integrity protection and data origin authentication. 441 OAuth is designed for access to resources identified by URIs. SASL 442 is designed for user authentication, and has no facility for more 443 fine-grained access control. In this specification we require or 444 define default values for the data elements from an HTTP request 445 which allow the signature base string to be constructed properly. 446 The default HTTP path is "/" and the default post body is empty. 447 These atoms are defined as extension points so that no changes are 448 needed if there is a revision of SASL which supports more specific 449 resource authorization, e.g., IMAP access to a specific folder or FTP 450 access limited to a specific directory. 452 Using the example in the OAuth 1.0a specification as a starting 453 point, on an IMAP server running on port 143 and given the OAuth 1.0a 454 style authorization request (with %x01 shown as ^A and line breaks 455 added for readability) below: 457 n,a=user@example.com,^A 458 host=example.com^A 459 port=143^A 460 auth=OAuth realm="Example", 461 oauth_consumer_key="9djdj82h48djs9d2", 462 oauth_token="kkk9d7dh3k39sjv7", 463 oauth_signature_method="HMAC-SHA1", 464 oauth_timestamp="137131201", 465 oauth_nonce="7d8f3e4a", 466 oauth_signature="Tm90IGEgcmVhbCBzaWduYXR1cmU"^A^A 468 The signature base string would be constructed per the OAuth 1.0 469 specification [RFC5849] with the following things noted: 471 o The method value is defaulted to POST. 473 o The scheme defaults to be "http", and any port number other than 474 80 is included. 476 o The path defaults to "/". 478 o The query string defaults to "". 480 In this example the signature base string with line breaks added for 481 readability would be: 483 POST&http%3A%2F%2Fexample.com:143%2F&oauth_consumer_key%3D9djdj82h4 484 8djs9d2%26oauth_nonce%3D7d8f3e4a%26oauth_signature_method%3DHMAC-SH 485 A1%26oauth_timestamp%3D137131201%26oauth_token%3Dkkk9d7dh3k39sjv7 487 4. Examples 489 These examples illustrate exchanges between IMAP and SMTP clients and 490 servers. All IMAP examples use SASL-IR [RFC4959] and send payload in 491 the initial client response. The Bearer Token examples assume 492 encrypted transport; if the underlying connection is not already TLS 493 then STARTTLS MUST be used as TLS is required in the Bearer Token 494 specification. 496 Note to implementers: The SASL OAuth method names are case 497 insensitive. One example uses "Bearer" but that could as easily be 498 "bearer", "BEARER", or "BeArEr". 500 4.1. Successful Bearer Token Exchange 502 This example shows a successful OAuth 2.0 bearer token exchange in 503 IMAP. Note that line breaks are inserted for readability. The 504 underlying TLS establishment is not shown but is required for using 505 Bearer Tokens per that specification. 507 S: * OK IMAP4rev1 Server Ready 508 C: t0 CAPABILITY 509 S: * CAPABILITY IMAP4rev1 AUTH=OAUTHBEARER SASL-IR 510 S: t0 OK Completed 511 C: t1 AUTH OAUTHBEARER bixhPXVzZXJAZXhhbXBsZS5jb20sAWhvc3Q9c2Vy 512 dmVyLmV4YW1wbGUuY29tAXBvcnQ9MTQzAWF1dGg9QmVhcmVyIHZGOWRmd 513 DRxbVRjMk52YjNSbGNrQmhiSFJoZG1semRHRXVZMjl0Q2c9PQEB 514 S: t1 OK SASL authentication succeeded 516 As required by IMAP [RFC3501], the payloads are base64-encoded. The 517 decoded initial client response (with %x01 represented as ^A and long 518 lines wrapped for readability) is: 520 n,a=user@example.com,^Ahost=server.example.com^Aport=143^A 521 auth=Bearer vF9dft4qmTc2Nvb3RlckBhbHRhdmlzdGEuY29tCg==^A^A 523 The same credential used in an SMTP exchange is shown below. Note 524 that line breaks are inserted for readability, and that the SMTP 525 protocol terminates lines with CR and LF characters (ASCII values 526 0x0D and 0x0A), these are not displayed explicitly in the example. 527 Again this example assumes that TLS is already established per the 528 Bearer Token specification requirements. 530 [connection begins] 531 S: 220 mx.example.com ESMTP 12sm2095603fks.9 532 C: EHLO sender.example.com 533 S: 250-mx.example.com at your service,[172.31.135.47] 534 S: 250-SIZE 35651584 535 S: 250-8BITMIME 536 S: 250-AUTH LOGIN PLAIN OAUTHBEARER 537 S: 250-ENHANCEDSTATUSCODES 538 S: 250-STARTTLS 539 S: 250 PIPELINING 540 [Negotiate TLS...] 541 C: t1 AUTH OAUTHBEARER bixhPXVzZXJAZXhhbXBsZS5jb20sAWhvc3Q9c2Vy 542 dmVyLmV4YW1wbGUuY29tAXBvcnQ9MTQzAWF1dGg9QmVhcmVyIHZGOWRmd 543 DRxbVRjMk52YjNSbGNrQmhiSFJoZG1semRHRXVZMjl0Q2c9PQEB 544 S: 235 Authentication successful. 545 [connection continues...] 547 4.2. Successful OAuth 1.0a Token Exchange 549 This IMAP example shows a successful OAuth 1.0a token exchange. Note 550 that line breaks are inserted for readability. This example assumes 551 that TLS is already established. Signature computation is discussed 552 in Section 3.3. 554 S: * OK IMAP4rev1 Server Ready 555 C: t0 CAPABILITY 556 S: * CAPABILITY IMAP4rev1 AUTH=OAUTHBEARER OAUTH10A SASL-IR 557 S: t0 OK Completed 558 C: t1 AUTH OAUTH10A bixhPXVzZXJAZXhhbXBsZS5jb20sAWhvc3Q9ZXhhb 559 XBsZS5jb20BcG9ydD0xNDMBYXV0aD1PQXV0aCByZWFsbT0iRXhhbXBsZSIsb2F1 560 dGhfY29uc3VtZXJfa2V5PSI5ZGpkajgyaDQ4ZGpzOWQyIixvYXV0aF90b2tlbj0 561 ia2trOWQ3ZGgzazM5c2p2NyIsb2F1dGhfc2lnbmF0dXJlX21ldGhvZD0iSE1BQy 562 1TSEExIixvYXV0aF90aW1lc3RhbXA9IjEzNzEzMTIwMSIsb2F1dGhfbm9uY2U9I 563 jdkOGYzZTRhIixvYXV0aF9zaWduYXR1cmU9IlRtOTBJR0VnY21WaGJDQnphV2R1 564 WVhSMWNtVSUzRCIBAQ== 565 S: t1 OK SASL authentication succeeded 567 As required by IMAP [RFC3501], the payloads are base64-encoded. The 568 decoded initial client response (with %x01 represented as ^A and 569 lines wrapped for readability) is: 571 n,a=user@example.com,^A 572 host=example.com^A 573 port=143^A 574 auth=OAuth realm="Example", 575 oauth_consumer_key="9djdj82h48djs9d2", 576 oauth_token="kkk9d7dh3k39sjv7", 577 oauth_signature_method="HMAC-SHA1", 578 oauth_timestamp="137131201", 579 oauth_nonce="7d8f3e4a", 580 oauth_signature="SSdtIGEgbGl0dGxlIHRlYSBwb3Qu"^A^A 582 4.3. Failed Exchange 584 This IMAP example shows a failed exchange because of the empty 585 Authorization header, which is how a client can query for the needed 586 scope. Note that line breaks are inserted for readability. 588 S: * OK IMAP4rev1 Server Ready 589 C: t0 CAPABILITY 590 S: * CAPABILITY IMAP4rev1 AUTH=OAUTHBEARER SASL-IR 591 S: t0 OK Completed 592 C: t1 AUTH OAUTHBEARER bixhPXVzZXJAZXhhbXBsZS5jb20sAW 593 hvc3Q9c2VydmVyLmV4YW1wbGUuY29tAXBvcnQ9MTQzAWF1dGg9AQE= 594 S: + eyJzdGF0dXMiOiJpbnZhbGlkX3Rva2VuIiwic2NvcGUiOiJleGFtcGxl 595 X3Njb3BlIiwib3BlbmlkLWNvbmZpZ3VyYXRpb24iOiJodHRwczovL2V4 596 YW1wbGUuY29tLy53ZWxsLWtub3duL29wZW5pZC1jb25maWcifQ== 597 C: AQ== 598 S: t1 NO SASL authentication failed 600 The decoded initial client response is: 602 n,a=user@example.com,^Ahost=server.example.com^A 603 port=143^Aauth=^A^A 605 The decoded server error response is: 607 { 608 "status":"invalid_token", 609 "scope":"example_scope", 610 "openid-configuration":"https://example.com/.well-known/openid-config" 611 } 613 The client responds with the required dummy response, "AQ==" is the 614 base64 encoding of the ASCII value 0x01. The same exchange using the 615 IMAP specific method of cancelling an AUTHENTICATE command sends "*" 616 and is shown below. 618 S: * OK IMAP4rev1 Server Ready 619 C: t0 CAPABILITY 620 S: * CAPABILITY IMAP4rev1 AUTH=OAUTHBEARER SASL-IR IMAP4rev1 621 S: t0 OK Completed 622 C: t1 AUTH OAUTHBEARER bixhPXVzZXJAZXhhbXBsZS5jb20sAW 623 hvc3Q9c2VydmVyLmV4YW1wbGUuY29tAXBvcnQ9MTQzAWF1dGg9AQE= 624 S: + eyJzdGF0dXMiOiJpbnZhbGlkX3Rva2VuIiwic2NvcGUiOiJleGFtcGxl 625 X3Njb3BlIiwib3BlbmlkLWNvbmZpZ3VyYXRpb24iOiJodHRwczovL2V4 626 YW1wbGUuY29tLy53ZWxsLWtub3duL29wZW5pZC1jb25maWd1cmF0aW9u 627 In0= 628 C: * 629 S: t1 NO SASL authentication failed 631 4.4. SMTP Example of a Failed Negotiation 633 This example shows an authorization failure in an SMTP exchange. 634 Note that line breaks are inserted for readability, and that the SMTP 635 protocol terminates lines with CR and LF characters (ASCII values 636 0x0D and 0x0A), these are not displayed explicitly in the example. 637 TLS negotiation is not shown but as noted above it is required for 638 the use of Bearer Tokens. 640 [connection begins] 641 S: 220 mx.example.com ESMTP 12sm2095603fks.9 642 C: EHLO sender.example.com 643 S: 250-mx.example.com at your service,[172.31.135.47] 644 S: 250-SIZE 35651584 645 S: 250-8BITMIME 646 S: 250-AUTH LOGIN PLAIN OAUTHBEARER 647 S: 250-ENHANCEDSTATUSCODES 648 S: 250 PIPELINING 649 C: AUTH OAUTHBEARER bix1c2VyPXNvbWV1c2VyQGV4YW1wbGUuY29tLAFhdXRoPUJlYXJl 650 ciB2RjlkZnQ0cW1UYzJOdmIzUmxja0JoZEhSaGRtbHpkR0V1WTI5dENnPT0BAQ== 651 S: 334 eyJzdGF0dXMiOiJpbnZhbGlkX3Rva2VuIiwic2NoZW1lcyI6ImJlYXJlciBtYWMiL 652 CJzY29wZSI6Imh0dHBzOi8vbWFpbC5nb29nbGUuY29tLyJ9 653 C: AQ== 654 S: 535-5.7.1 Username and Password not accepted. Learn more at 655 S: 535 5.7.1 http://support.example.com/mail/oauth 656 [connection continues...] 658 The server returned an error message in the 334 SASL message, the 659 client responds with the required dummy response, and the server 660 finalizes the negotiation. 662 5. Security Considerations 664 OAuth 1.0a and OAuth 2 allow for a variety of deployment scenarios, 665 and the security properties of these profiles vary. As shown in 666 Figure 1 this specification is aimed to be integrated into a larger 667 OAuth deployment. Application developers therefore need to 668 understand their security requirements based on a threat assessment 669 before selecting a specific SASL OAuth mechanism. For OAuth 2.0 a 670 detailed security document [RFC6819] provides guidance to select 671 those OAuth 2.0 components that help to mitigate threats for a given 672 deployment. For OAuth 1.0a Section 4 of RFC 5849 [RFC5849] provides 673 guidance specific to OAuth 1.0. 675 This document specifies two SASL Mechanisms for OAuth and each comes 676 with different security properties. 678 OAUTHBEARER: This mechanism borrows from OAuth 2.0 bearer tokens 679 [RFC6750]. It relies on the application using TLS to protect the 680 OAuth 2.0 Bearer Token exchange; without TLS usage at the 681 application layer this method is completely insecure. 682 Consequently, TLS MUST be provided by the application when 683 choosing this authentication mechanism. 685 OAUTH10A: This mechanism re-uses OAuth 1.0a MAC tokens (using the 686 HMAC-SHA1 keyed message digest), as described in Section 3.4.2 of 687 [RFC5849]. To compute the keyed message digest in the same way as 688 in RFC 5839 this specification conveys additional parameters 689 between the client and the server. This SASL mechanism only 690 supports client authentication. If server-side authentication is 691 desireable then it must be provided by the application underneath 692 the SASL layer. The use of TLS is strongly RECOMMENDED. 694 Additionally, the following aspects are worth pointing out: 696 An access token is not equivalent to the user's long term password. 698 Care has to be taken when these OAuth credentials are used for 699 actions like changing passwords (as it is possible with some 700 protocols, e.g., XMPP [RFC6120]). The resource server should 701 ensure that actions taken in the authenticated channel are 702 appropriate to the strength of the presented credential. 704 Lifetime of the appliation sessions. 706 It is possible that SASL will be authenticating a connection and 707 the life of that connection may outlast the life of the access 708 token used to establish it. This is a common problem in 709 application protocols where connections are long-lived, and not a 710 problem with this mechanism per se. Resource servers may 711 unilaterally disconnect clients in accordance with the application 712 protocol. 714 Access tokens have a lifetime. 716 Reducing the lifetime of an access token provides security 717 benefits and OAuth 2.0 introduces refresh tokens to obtain new 718 access token on the fly without any need for a human interaction. 719 Additionally, a previously obtained access token might be revoked 720 or rendered invalid at any time. The client MAY request a new 721 access token for each connection to a resource server, but it 722 SHOULD cache and re-use valid credentials. 724 6. Internationalization Considerations 726 The identifer asserted by the OAuth authorization server about the 727 resource owner inside the access token may be displayed to a human. 728 For example, when SASL is used in the context of IMAP the client may 729 assert the resource owner's email address to the IMAP server for 730 usage in an email-based application. The identifier may therefore 731 contain internationalized characters and an application needs to 732 ensure that the mapping between the identifier provided by OAuth is 733 suitable for use with the application layer protocol SASL is 734 incorporated into. 736 At the time of writing the standardization of the various claims in 737 the access token (in JSON format) is still ongoing, see 738 [I-D.ietf-oauth-json-web-token]. Once completed it will provide a 739 standardized format for exchanging identity information between the 740 authorization server and the resource server. 742 7. IANA Considerations 744 7.1. SASL Registration 746 The IANA is requested to register the following entry in the SASL 747 Mechanisms registry: 749 SASL mechanism name: OAUTHBEARER 751 Security Considerations: See this document 753 Published Specification: See this document 755 For further information: Contact the authors of this document. 757 Intended usage: common 759 Owner/Change controller: the IESG 761 Note: None 763 The IANA is requested to register the following entry in the SASL 764 Mechanisms registry: 766 SASL mechanism name: OAUTH10A 768 Security Considerations: See this document 770 Published Specification: See this document 772 For further information: Contact the authors of this document. 774 Intended usage: common 776 Owner/Change controller: the IESG 778 Note: None 780 8. References 782 8.1. Normative References 784 [OpenID.Core] 785 Sakimura, N., Bradley, J., Jones, M., de Medeiros, B., and 786 C. Mortimore, "OpenID Connect Core 1.0", February 2014. 788 [OpenID.Discovery] 789 Sakimura, N., Bradley, J., Jones, M., and E. Jay, "OpenID 790 Connect Discovery 1.0", July 2011. 792 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 793 Requirement Levels", BCP 14, RFC 2119, March 1997. 795 [RFC4422] Melnikov, A. and K. Zeilenga, "Simple Authentication and 796 Security Layer (SASL)", RFC 4422, June 2006. 798 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 799 Encodings", RFC 4648, October 2006. 801 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 802 Specifications: ABNF", STD 68, RFC 5234, January 2008. 804 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 805 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 807 [RFC5801] Josefsson, S. and N. Williams, "Using Generic Security 808 Service Application Program Interface (GSS-API) Mechanisms 809 in Simple Authentication and Security Layer (SASL): The 810 GS2 Mechanism Family", RFC 5801, July 2010. 812 [RFC5849] Hammer-Lahav, E., "The OAuth 1.0 Protocol", RFC 5849, 813 April 2010. 815 [RFC6749] Hardt, D., "The OAuth 2.0 Authorization Framework", RFC 816 6749, October 2012. 818 [RFC6750] Jones, M. and D. Hardt, "The OAuth 2.0 Authorization 819 Framework: Bearer Token Usage", RFC 6750, October 2012. 821 [RFC7159] Bray, T., "The JavaScript Object Notation (JSON) Data 822 Interchange Format", RFC 7159, March 2014. 824 8.2. Informative References 826 [I-D.ietf-oauth-dyn-reg] 827 Richer, J., Jones, M., Bradley, J., Machulak, M., and P. 828 Hunt, "OAuth 2.0 Dynamic Client Registration Protocol", 829 draft-ietf-oauth-dyn-reg-27 (work in progress), March 830 2015. 832 [I-D.ietf-oauth-json-web-token] 833 Jones, M., Bradley, J., and N. Sakimura, "JSON Web Token 834 (JWT)", draft-ietf-oauth-json-web-token-32 (work in 835 progress), December 2014. 837 [RFC3501] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 838 4rev1", RFC 3501, March 2003. 840 [RFC4959] Siemborski, R. and A. Gulbrandsen, "IMAP Extension for 841 Simple Authentication and Security Layer (SASL) Initial 842 Client Response", RFC 4959, September 2007. 844 [RFC5321] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 845 October 2008. 847 [RFC6120] Saint-Andre, P., "Extensible Messaging and Presence 848 Protocol (XMPP): Core", RFC 6120, March 2011. 850 [RFC6819] Lodderstedt, T., McGloin, M., and P. Hunt, "OAuth 2.0 851 Threat Model and Security Considerations", RFC 6819, 852 January 2013. 854 [RFC7033] Jones, P., Salgueiro, G., Jones, M., and J. Smarr, 855 "WebFinger", RFC 7033, September 2013. 857 [RFC7230] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol 858 (HTTP/1.1): Message Syntax and Routing", RFC 7230, June 859 2014. 861 Appendix A. Acknowlegements 863 The authors would like to thank the members of the Kitten working 864 group, and in addition and specifically: Simon Josefson, Torsten 865 Lodderstadt, Ryan Troll, Alexey Melnikov, Jeffrey Hutzelman, Nico 866 Williams, Matt Miller, and Benjamin Kaduk. 868 This document was produced under the chairmanship of Alexey Melnikov, 869 Tom Yu, Shawn Emery, Josh Howlett, Sam Hartman. The supervising area 870 director was Stephen Farrell. 872 Appendix B. Document History 874 [[ to be removed by RFC editor before publication as an RFC ]] 876 -19 878 o Last call feedback agaiun. 880 o Clarified usage of TLS in examples and fixed them some more. 881 Adding reference to RFC4422 and cancellation token and an example 882 for that. 884 -18 886 o Last call feedback round #5. Fixed -17 change log. 888 o Corrected "issue" to "iss", other minor changes. 890 -17 892 o Last call feedback again (WGLC #4). eradicated comma splicing. 893 Removed extra server message in example 4.3. 895 o Added recommendations for discovery and dynamic client 896 registration support. 898 -16 900 o Last call feedback again. Primarily editorial changes. Corrected 901 examples. 903 -15 905 o Last call feedack on the GS2 stuff being ripped out completely. 907 o Removed the "user" parameter and put stuff back into the 908 gs2-header. Call out that the authzid goes in the gs2-header with 909 some prose about when it might be required. Very comparable to 910 -10. 912 o Added an OAuth 1.0A example explicitly. 914 -14 916 o Last call feedack on RFC citations needed, small editorial. 918 o Added the "user" parameter back, which was pulled when we started 919 down the GS2 path. Same language as -03. 921 o Defined a stub GS2 header to make sure that when the GS2 bride is 922 defined for this that nothing will break when it actually starts 923 to get populated. 925 -13 927 o Changed affiliation. 929 -12 931 o Removed -PLUS components from the specification. 933 -11 935 o Removed GSS-API components from the specification. 937 o Updated security consideration section. 939 -10 941 o Clarifications throughout the document in response to the feedback 942 from Jeffrey Hutzelman. 944 -09 946 o Incorporated review by Alexey and Hannes. 948 o Clarified the three OAuth SASL mechanisms. 950 o Updated references 952 o Extended acknowledgements 954 -08 956 o Fixed the channel binding examples for p=$cbtype 958 o More tuning of the authcid language and edited and renamed 3.2.1. 960 -07 962 o Struck the MUST langiage from authzid. 964 o 966 -06 968 o Removed the user field. Fixed the examples again. 970 o Added canonicalization language. 972 o 974 -05 976 o Fixed the GS2 header language again. 978 o Separated out different OAuth schemes into different SASL 979 mechanisms. Took out the scheme in the error return. Tuned up 980 the IANA registrations. 982 o Added the user field back into the SASL message. 984 o Fixed the examples (again). 986 o 988 -04 990 o Changed user field to be carried in the gs2-header, and made gs2 991 header explicit in all cases. 993 o Converted MAC examples to OAuth 1.0a. Moved MAC to an informative 994 reference. 996 o Changed to sending an empty client response (single control-A) as 997 the second message of a failed sequence. 999 o Fixed channel binding prose to refer to the normative specs and 1000 removed the hashing of large channel binding data, which brought 1001 mroe problems than it solved. 1003 o Added a SMTP examples for Bearer use case. 1005 -03 1007 o Added user field into examples and fixed egregious errors there as 1008 well. 1010 o Added text reminding developers that Authorization scheme names 1011 are case insensitive. 1013 -02 1015 o Added the user data element back in. 1017 o Minor editorial changes. 1019 -01 1021 o Ripping out discovery. Changed to refer to I-D.jones-appsawg- 1022 webfinger instead of WF and SWD older drafts. 1024 o Replacing HTTP as the message format and adjusted all examples. 1026 -00 1028 o Renamed draft into proper IETF naming format now that it's 1029 adopted. 1031 o Minor fixes. 1033 Authors' Addresses 1035 William Mills 1036 Microsoft 1038 Email: wimills@microsoft.com 1040 Tim Showalter 1042 Email: tjs@psaux.com 1044 Hannes Tschofenig 1045 ARM Ltd. 1046 110 Fulbourn Rd 1047 Cambridge CB1 9NJ 1048 Great Britain 1050 Email: Hannes.tschofenig@gmx.net 1051 URI: http://www.tschofenig.priv.at