idnits 2.17.1 draft-ietf-oauth-native-apps-05.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 (October 21, 2016) is 2743 days in the past. Is this intentional? Checking references for intended status: Best Current Practice ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) No issues found here. Summary: 0 errors (**), 0 flaws (~~), 1 warning (==), 1 comment (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 OAuth Working Group W. Denniss 3 Internet-Draft Google 4 Intended status: Best Current Practice J. Bradley 5 Expires: April 24, 2017 Ping Identity 6 October 21, 2016 8 OAuth 2.0 for Native Apps 9 draft-ietf-oauth-native-apps-05 11 Abstract 13 OAuth 2.0 authorization requests from native apps should only be made 14 through external user-agents, primarily the user's browser. This 15 specification details the security and usability reasons why this is 16 the case, and how native apps and authorization servers can implement 17 this best practice. 19 Status of This Memo 21 This Internet-Draft is submitted in full conformance with the 22 provisions of BCP 78 and BCP 79. 24 Internet-Drafts are working documents of the Internet Engineering 25 Task Force (IETF). Note that other groups may also distribute 26 working documents as Internet-Drafts. The list of current Internet- 27 Drafts is at http://datatracker.ietf.org/drafts/current/. 29 Internet-Drafts are draft documents valid for a maximum of six months 30 and may be updated, replaced, or obsoleted by other documents at any 31 time. It is inappropriate to use Internet-Drafts as reference 32 material or to cite them other than as "work in progress." 34 This Internet-Draft will expire on April 24, 2017. 36 Copyright Notice 38 Copyright (c) 2016 IETF Trust and the persons identified as the 39 document authors. All rights reserved. 41 This document is subject to BCP 78 and the IETF Trust's Legal 42 Provisions Relating to IETF Documents 43 (http://trustee.ietf.org/license-info) in effect on the date of 44 publication of this document. Please review these documents 45 carefully, as they describe your rights and restrictions with respect 46 to this document. Code Components extracted from this document must 47 include Simplified BSD License text as described in Section 4.e of 48 the Trust Legal Provisions and are provided without warranty as 49 described in the Simplified BSD License. 51 Table of Contents 53 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 54 2. Notational Conventions . . . . . . . . . . . . . . . . . . . 3 55 3. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 3 56 4. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 4 57 4.1. Authorization Flow for Native Apps Using the Browser . . 5 58 5. Using Inter-app URI Communication for OAuth . . . . . . . . . 6 59 6. Initiating the Authorization Request from a Native App . . . 6 60 7. Receiving the Authorization Response in a Native App . . . . 7 61 7.1. App-declared Custom URI Scheme Redirection . . . . . . . 7 62 7.2. App-claimed HTTPS URI Redirection . . . . . . . . . . . . 8 63 7.3. Loopback URI Redirection . . . . . . . . . . . . . . . . 9 64 8. Security Considerations . . . . . . . . . . . . . . . . . . . 9 65 8.1. Embedded User-Agents . . . . . . . . . . . . . . . . . . 9 66 8.2. Protecting the Authorization Code . . . . . . . . . . . . 10 67 8.3. Loopback Redirect Considerations . . . . . . . . . . . . 11 68 8.4. Registration of Native App Clients . . . . . . . . . . . 11 69 8.5. OAuth Implicit Flow . . . . . . . . . . . . . . . . . . . 12 70 8.6. Phishability of In-App Browser Tabs . . . . . . . . . . . 12 71 8.7. Limitations of Non-verifiable Clients . . . . . . . . . . 12 72 8.8. Non-Browser External User-Agents . . . . . . . . . . . . 13 73 8.9. Client Authentication . . . . . . . . . . . . . . . . . . 13 74 8.10. Cross-App Request Forgery Protections . . . . . . . . . . 13 75 8.11. Authorization Server Mix-Up Mitigation . . . . . . . . . 13 76 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 14 77 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 14 78 10.1. Normative References . . . . . . . . . . . . . . . . . . 14 79 10.2. Informative References . . . . . . . . . . . . . . . . . 15 80 Appendix A. Server Support Checklist . . . . . . . . . . . . . . 15 81 Appendix B. Operating System Specific Implementation Details . . 16 82 B.1. iOS Implementation Details . . . . . . . . . . . . . . . 16 83 B.2. Android Implementation Details . . . . . . . . . . . . . 16 84 B.3. Windows Implementation Details . . . . . . . . . . . . . 17 85 B.4. macOS Implementation Details . . . . . . . . . . . . . . 17 86 B.5. Linux Implementation Details . . . . . . . . . . . . . . 17 87 Appendix C. Acknowledgements . . . . . . . . . . . . . . . . . . 18 88 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 18 90 1. Introduction 92 The OAuth 2.0 [RFC6749] authorization framework documents two 93 approaches in Section 9 for native apps to interact with the 94 authorization endpoint: an embedded user-agent, or an external user- 95 agent. 97 This best current practice recommends that only external user-agents 98 like the browser are used for OAuth by native apps. It documents how 99 native apps can implement authorization flows using the browser as 100 the preferred external user-agent, and the requirements for 101 authorization servers to support such usage. 103 This practice is also known as the AppAuth pattern, in reference to 104 open source libraries that implement it. 106 2. Notational Conventions 108 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 109 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 110 "OPTIONAL" in this document are to be interpreted as described in Key 111 words for use in RFCs to Indicate Requirement Levels [RFC2119]. If 112 these words are used without being spelled in uppercase then they are 113 to be interpreted with their normal natural language meanings. 115 3. Terminology 117 In addition to the terms defined in referenced specifications, this 118 document uses the following terms: 120 "native app" An application that is installed by the user to their 121 device, as distinct from a web app that runs in the browser 122 context only. Apps implemented using web-based technology but 123 distributed as a native app, so-called hybrid apps, are considered 124 equivalent to native apps for the purpose of this specification. 126 "OAuth" In this document, OAuth refers to OAuth 2.0 [RFC6749]. 128 "external user-agent" A user-agent capable of handling the 129 authorization request that is a separate entity to the native app 130 making the request (such as a browser), such that the app cannot 131 access the cookie storage or modify the page content. 133 "embedded user-agent" A user-agent hosted inside the native app 134 itself (such as via a web-view), with which the app has control 135 over to the extent it is capable of accessing the cookie storage 136 and/or modify the page content. 138 "app" Shorthand for "native app". 140 "app store" An ecommerce store where users can download and purchase 141 apps. 143 "browser" The operating system's default browser, pre-installed as 144 part of the operating system, or installed and set as default by 145 the user. 147 "browser tab" An open page of the browser. Browser typically have 148 multiple "tabs" representing various open pages. 150 "in-app browser tab" A full page browser with limited navigation 151 capabilities that is displayed inside a host app, but retains the 152 full security properties and authentication state of the browser. 153 Has different platform-specific product names, such as 154 SFSafariViewController on iOS, and Chrome Custom Tab on Android. 156 "inter-app communication" Communication between two apps on a 157 device. 159 "claimed HTTPS URL" Some platforms allow apps to claim a HTTPS URL 160 after proving ownership of the domain name. URLs claimed in such 161 a way are then opened in the app instead of the browser. 163 "custom URI scheme" A URI scheme (as defined by [RFC3986]) that the 164 app creates and registers with the OS (and is not a standard URI 165 scheme like "https:" or "tel:"). Requests to such a scheme 166 results in the app which registered it being launched by the OS. 168 "web-view" A web browser UI component that can be embedded in apps 169 to render web pages, used to create embedded user-agents. 171 "reverse domain name notation" A naming convention based on the 172 domain name system, but where where the domain components are 173 reversed, for example "app.example.com" becomes "com.example.app". 175 4. Overview 177 The best current practice for authorizing users in native apps is to 178 perform the OAuth authorization request in an external user-agent 179 (typically the browser), rather than an embedded user-agent (such as 180 one implemented with web-views). 182 Previously it was common for native apps to use embedded user-agents 183 (commonly implemented with web-views) for OAuth authorization 184 requests. That approach has many drawbacks, including the host app 185 being able to copy user credentials and cookies, and the user needing 186 to authenticate from scratch in each app. See Section 8.1 for a 187 deeper analysis of using embedded user-agents for OAuth. 189 Native app authorization requests that use the browser are more 190 secure and can take advantage of the user's authentication state. 192 Being able to use the existing authentication session in the browser 193 enables single sign-on, as users don't need to authenticate to the 194 authorization server each time they use a new app (unless required by 195 authorization server policy). 197 Supporting authorization flows between a native app and the browser 198 is possible without changing the OAuth protocol itself, as the 199 authorization request and response are already defined in terms of 200 URIs, which emcompasses URIs that can be used for inter-process 201 communication. Some OAuth server implementations that assume all 202 clients are confidential web-clients will need to add an 203 understanding of native app OAuth clients and the types of redirect 204 URIs they use to support this best practice. 206 4.1. Authorization Flow for Native Apps Using the Browser 208 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ 209 | User Device | 210 | | 211 | +---------------------------+ | +-----------+ 212 | | | | (5) Authz Code | | 213 | | Client App |----------------------->| Token | 214 | | |<-----------------------| Endpoint | 215 | +---------------------------+ | (6) Access Token, | | 216 | | ^ | Refresh Token +-----------+ 217 | | | | 218 | | | | 219 | | (1) | (4) | 220 | | Authz | Authz | 221 | | Request | Code | 222 | | | | 223 | | | | 224 | v | | 225 | +---------------------------+ | +---------------+ 226 | | | | (2) Authz Request | | 227 | | Browser |--------------------->| Authorization | 228 | | |<---------------------| Endpoint | 229 | +---------------------------+ | (3) Authz Code | | 230 | | +---------------+ 231 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ 233 Figure 1: Native App Authorization via External User-agent 235 Figure 1 illustrates the interaction of the native app with the 236 system browser to authorize the user via an external user-agent. 238 (1) The client app opens a browser tab with the authorization 239 request. 241 (2) Authorization endpoint receives the authorization request, 242 authenticates the user and obtains authorization. 243 Authenticating the user may involve chaining to other 244 authentication systems. 246 (3) Authorization server issues an authorization code to the 247 redirect URI. 249 (4) Client receives the authorization code from the redirect URI. 251 (5) Client app presents the authorization code at the token 252 endpoint. 254 (6) Token endpoint validates the authorization code and issues the 255 tokens requested. 257 5. Using Inter-app URI Communication for OAuth 259 Just as URIs are used for OAuth 2.0 [RFC6749] on the web to initiate 260 the authorization request and return the authorization response to 261 the requesting website, URIs can be used by native apps to initiate 262 the authorization request in the device's browser and return the 263 response to the requesting native app. 265 By applying the same principles from the web to native apps, we gain 266 similar benefits like the usability of a single sign-on session, and 267 the security of a separate authentication context. It also reduces 268 the implementation complexity by reusing the same flows as the web, 269 and increases interoperability by relying on standards-based web 270 flows that are not specific to a particular platform. 272 Native apps MUST use an external user-agent to perform OAuth 273 authentication requests. This is achieved by opening the 274 authorization request in the browser (detailed in Section 6), and 275 using a redirect URI that will return the authorization response back 276 to the native app, as defined in Section 7. 278 This best practice focuses on the browser as the RECOMMENDED external 279 user-agent for native apps. Other external user-agents, such as a 280 native app provided by the authorization server may meet the criteria 281 set out in this best practice, including using the same redirection 282 URI properties, but their use is out of scope for this specification. 284 6. Initiating the Authorization Request from a Native App 286 The authorization request is created as per OAuth 2.0 [RFC6749], and 287 opened in the user's browser using platform-specific APIs for that 288 purpose. 290 The function of the redirect URI for a native app authorization 291 request is similar to that of a web-based authorization request. 292 Rather than returning the authorization response to the OAuth 293 client's server, the redirect URI used by a native app returns the 294 response to the app. The various options for a redirect URI that 295 will return the code to the native app are documented in Section 7. 296 Any redirect URI that allows the app to receive the URI and inspect 297 its parameters is viable. 299 Some platforms support a browser feature known as in-app browser 300 tabs, where an app can present a tab of the browser within the app 301 context without switching apps, but still retain key benefits of the 302 browser such as a shared authentication state and security context. 303 On platforms where they are supported, it is RECOMMENDED for 304 usability reasons that apps use in-app browser tabs for the 305 Authorization Request. 307 7. Receiving the Authorization Response in a Native App 309 There are several redirect URI options available to native apps for 310 receiving the authorization response from the browser, the 311 availability and user experience of which varies by platform. 313 To fully support this best practice, authorization servers MUST 314 support the following three redirect URI options. Native apps MAY 315 use whichever redirect option suits their needs best, taking into 316 account platform specific implementation details. 318 7.1. App-declared Custom URI Scheme Redirection 320 Many mobile and desktop computing platforms support inter-app 321 communication via URIs by allowing apps to register custom URI 322 schemes, like "com.example.app:". When the browser or another app 323 attempts to load a URI with a custom scheme, the app that registered 324 it is launched to handle the request. 326 To perform an OAuth 2.0 Authorization Request with a custom URI 327 scheme-based redirect URI, the native app launches the browser with a 328 normal OAuth 2.0 Authorization Request, but provides a redirection 329 URI that utilizes a custom URI scheme registered with the operating 330 system by the calling app. 332 When the authentication server completes the request, it redirects to 333 the client's redirection URI like it would any redirect URI, but as 334 the redirection URI uses a custom scheme, this results in the OS 335 launching the native app passing in the URI. The native app then 336 processes the authorization response like any OAuth client. 338 7.1.1. Custom URI Scheme Namespace Considerations 340 When choosing a URI scheme to associate with the app, apps MUST use a 341 URI scheme based on a domain name under their control, expressed in 342 reverse order, as recommended by Section 3.8 of [RFC7595] for 343 private-use URI schemes. 345 For example, an app that controls the domain name "app.example.com" 346 can use "com.example.app:/" as their custom scheme. Some 347 authorization servers assign client identifiers based on domain 348 names, for example "client1234.usercontent.example.net", which can 349 also be used as the domain name for the custom scheme, when reversed 350 in the same manner, for example "net.example.usercontent.client1234". 352 URI schemes not based on a domain name (for example "myapp:/") MUST 353 NOT be used, as they are not collision resistant, and don't comply 354 with Section 3.8 of [RFC7595]. 356 Care must be taken when there are multiple apps by the same publisher 357 that each URI scheme is unique within that group. On platforms that 358 use app identifiers that are also based on reverse order domain 359 names, those can be re-used as the custom URI scheme for the OAuth 360 redirect. 362 In addition to the collision resistant properties, basing the URI 363 scheme off a domain name that is under the control of the app can 364 help to prove ownership in the event of a dispute where two apps 365 claim the same custom scheme (such as if an app is acting 366 maliciously). For example, if two apps claimed "com.example.app:", 367 the owner of "example.com" could petition the app store operator to 368 remove the counterfeit app. This petition is harder to prove if a 369 generic URI scheme was used. 371 7.2. App-claimed HTTPS URI Redirection 373 Some operating systems allow apps to claim HTTPS URLs in their 374 domains. When the browser encounters a claimed URL, instead of the 375 page being loaded in the browser, the native app is launched instead 376 with the URL supplied as a launch parameter. 378 App-claimed HTTPS redirect URIs have some advantages in that the 379 identity of the destination app is guaranteed by the operating 380 system. Due to this reason, they SHOULD be used over the other 381 redirect choices for native apps where possible. 383 App-claimed HTTPS redirect URIs function as normal HTTPS redirects 384 from the perspective of the authorization server, though it is 385 RECOMMENDED that the authorization server is able to distinguish 386 between public native app clients that use app-claimed HTTPS redirect 387 URIs and confidential web clients. A configuration option in the 388 client registration (as documented in Section 8.4) is one method for 389 distinguishing client types. 391 7.3. Loopback URI Redirection 393 Desktop operating systems allow native apps to listen on a local port 394 for HTTP redirects. This can be used by native apps to receive OAuth 395 authorization responses on compatible platforms. 397 Loopback redirect URIs take the form of the loopback IP, any port 398 (dynamically provided by the client), and a path component. 399 Specifically: "http://127.0.0.1:{port}/{path}" for IPv4, and 400 "http://[::1]:{port}/{path}" for IPv6. 402 For loopback IP redirect URIs, the authorization server MUST allow 403 any port to be specified at the time of the request, to accommodate 404 clients that obtain an available port from the operating system at 405 the time of the request. Other than that, the redirect is be treated 406 like any other. 408 8. Security Considerations 410 8.1. Embedded User-Agents 412 Embedded user-agents are an alternative method for authorization 413 native apps. They are however unsafe for use by third-parties to the 414 authorization server by definition, as the app that hosts the 415 embedded user-agent can access the user's full authentication 416 credential, not just the OAuth authorization grant that was intended 417 for the app. 419 In typical web-view based implementations of embedded user-agents, 420 the host application can: log every keystroke entered in the form to 421 capture usernames and passwords; automatically submit forms and 422 bypass user-consent; copy session cookies and use them to perform 423 authenticated actions as the user. 425 Even when used by trusted apps belonging to the same party as the 426 authorization server, embedded user-agents violate the principle of 427 least privilege by having access to more powerful credentials than 428 they need, potentially increasing the attack surface. 430 Encouraging users to enter credentials in an embedded user-agent 431 without the usual address bar and visible certificate validation 432 features that browsers have makes it impossible for the user to know 433 if they are signing in to the legitimate site, and even when they 434 are, it trains them that it's OK to enter credentials without 435 validating the site first. 437 Aside from the security concerns, embedded user-agents do not share 438 the authentication state with other apps or the browser, requiring 439 the user to login for every authorization request and leading to a 440 poor user experience. 442 Native apps MUST NOT use embedded user-agents to perform 443 authorization requests. 445 Authorization endpoints MAY take steps to detect and block 446 authorization requests in embedded user-agents. 448 8.2. Protecting the Authorization Code 450 The redirect URI options documented in Section 7 share the benefit 451 that only a native app on the same device can receive the 452 authorization code which limits the attack surface, however code 453 interception by a native app other than the intended app may still be 454 possible. 456 A limitation of using custom URI schemes for redirect URIs is that 457 multiple apps can typically register the same scheme, which makes it 458 indeterminate as to which app will receive the Authorization Code. 459 PKCE [RFC7636] details how this limitation can be used to execute a 460 code interception attack (see Figure 1). Loopback IP based redirect 461 URIs may be susceptible to interception by other apps listening on 462 the same loopback interface. 464 As most forms of inter-app URI-based communication sends data over 465 insecure local channels, eavesdropping and interception of the 466 authorization response is a risk for native apps. App-claimed HTTPS 467 redirects are hardened against this type of attack due to the 468 presence of the URI authority, but they are still public clients and 469 the URI is still transmitted over local channels with unknown 470 security properties. 472 The Proof Key for Code Exchange by OAuth Public Clients (PKCE 473 [RFC7636]) standard was created specifically to mitigate against this 474 attack. It is a Proof of Possession extension to OAuth 2.0 that 475 protects the code grant from being used if it is intercepted. It 476 achieves this by having the client generate a secret verifier which 477 it passes in the initial authorization request, and which it must 478 present later when redeeming the authorization code grant. An app 479 that intercepted the authorization code would not be in possession of 480 this secret, rendering the code useless. 482 Public native app clients MUST protect the authorization request with 483 PKCE [RFC7636]. Authorization servers MUST support PKCE [RFC7636] 484 for public native app clients. Authorization servers SHOULD reject 485 authorization requests from native apps that don't use PKCE by 486 returning an error message as defined in Section 4.4.1 of PKCE 487 [RFC7636]. 489 8.3. Loopback Redirect Considerations 491 Loopback interface redirect URIs use the "http" scheme (i.e. without 492 TLS). This is acceptable for loopback interface redirect URIs as the 493 HTTP request never leaves the device. 495 Clients should open the loopback port only when starting the 496 authorization request, and close it once the response is returned. 498 While redirect URIs using localhost (i.e. "http://localhost:{port}/" 499 function similarly to loopback IP redirects described in Section 7.3, 500 the use of "localhost" is NOT RECOMMENDED. Opening a port on the 501 loopback interface is more secure as only apps on the local device 502 can connect to it. It is also less susceptible to misconfigured 503 routing, and interference by client side firewalls. 505 8.4. Registration of Native App Clients 507 Authorization Servers SHOULD have a way to distinguish public native 508 app clients from confidential web-clients, as the lack of client 509 authentication means they are often handled differently. A 510 configuration option to indicate a public native app client is one 511 such popular method for achieving this. 513 As recommended in Section 3.1.2.2 of OAuth 2.0 [RFC6749], the 514 authorization server SHOULD require the client to pre-register the 515 complete redirection URI. This applies and is RECOMMENDED for all 516 redirection URIs used by native apps. 518 For Custom URI scheme based redirects, authorization servers SHOULD 519 enforce the requirement in Section 7.1.1 that clients use reverse 520 domain name based schemes. 522 Authorization servers MAY request the inclusion of other platform- 523 specific information, such as the app package or bundle name, or 524 other information used to associate the app that may be useful for 525 verifying the calling app's identity, on operating systems that 526 support such functions. 528 8.5. OAuth Implicit Flow 530 The OAuth 2.0 Implicit Flow as defined in Section 4.2 of OAuth 2.0 531 [RFC6749] generally works with the practice of performing the 532 authorization request in the browser, and receiving the authorization 533 response via URI-based inter-app communication. However, as the 534 Implicit Flow cannot be protected by PKCE (which is a recommended in 535 Section 7.1.1), the use of the Implicit Flow with native apps is NOT 536 RECOMMENDED. 538 Tokens granted via the implicit flow also cannot be refreshed without 539 user interaction making the code flow, with refresh tokens the more 540 practical option for native app authorizations that require 541 refreshing. 543 8.6. Phishability of In-App Browser Tabs 545 While in-app browser tabs provide a secure authentication context, as 546 the user initiates the flow from a native app, it is possible for 547 that native app to completely fake an in-app browser tab. 549 This can't be prevented directly - once the user is in the native 550 app, that app is fully in control of what it can render, however 551 there are several mitigating factors. 553 Importantly, such an attack that uses a web-view to fake an in-app 554 browser tab will always start with no authentication state. If all 555 native apps use the techniques described in this best practice, users 556 will not need to sign-in frequently and thus should be suspicious of 557 any sign-in request when they should have already been signed-in. 559 This is the case even for authorization servers that require 560 occasional or frequent re-authentication, as such servers can 561 preserve some user identifiable information from the old session, 562 like the email address or profile picture and display that on the re- 563 authentication. 565 Users who are particularly concerned about their security may also 566 take the additional step of opening the request in the browser from 567 the in-app browser tab, and completing the authorization there, as 568 most implementations of the in-app browser tab pattern offer such 569 functionality. 571 8.7. Limitations of Non-verifiable Clients 573 As stated in Section 10.2 of OAuth 2.0 [RFC6749], the authorization 574 server SHOULD NOT process authorization requests automatically 575 without user consent or interaction, except when the identity of the 576 client can be assured. Measures such as claimed HTTPS redirects can 577 be used by native apps to prove their identity to the authorization 578 server, and some operating systems may offer alternative platform- 579 specific identity features which may be used, as appropriate. 581 8.8. Non-Browser External User-Agents 583 This best practice recommends a particular type of external user- 584 agent, the user's browser. Other external user-agent patterns may 585 also be viable for secure and usable OAuth. This document makes no 586 comment on those patterns. 588 8.9. Client Authentication 590 Secrets that are statically included as part of an app distributed to 591 multiple users should not be treated as confidential secrets, as one 592 user may inspect their copy and learn the shared secret. For this 593 reason, and those stated in Section 5.3.1 of [RFC6819], it is NOT 594 RECOMMENDED for authorization servers to require client 595 authentication of native apps using a shared secret, as this serves 596 little value beyond client identification which is already provided 597 by the "client_id" request parameter. 599 Authorization servers that still require a shared secret for native 600 app clients MUST treat the client as a public client, and not treat 601 the secret as proof of the client's identity. In those cases, it is 602 NOT RECOMMENDED to automatically issue tokens on the basis that the 603 user has previously granted access to the same client, as there is no 604 guarantee that the client is not counterfeit. 606 8.10. Cross-App Request Forgery Protections 608 Section 5.3.5 of [RFC6819] recommends using the 'state' parameter to 609 link client requests and responses to prevent CSRF attacks. 611 It is similarly RECOMMENDED for native apps to include a high entropy 612 secure random number in the 'state' parameter of the authorization 613 request, and reject any incoming authorization responses without a 614 state value that matches a pending outgoing authorization request. 616 8.11. Authorization Server Mix-Up Mitigation 618 To protect against a compromised or malicious authorization server 619 attacking another authorization server used by the same app, it is 620 RECOMMENDED that a unique redirect URI is used for each different 621 authorization server used by the app (for example, by varying the 622 path component), and that authorization responses are rejected if the 623 redirect URI they were received on doesn't match the redirect URI in 624 a pending outgoing authorization request. 626 Authorization servers SHOULD allow the registration of a specific 627 redirect URI, including path components, and reject authorization 628 requests that specify a redirect URI that doesn't exactly match the 629 one that was registered. 631 9. IANA Considerations 633 [RFC Editor: please do not remove this section.] 635 Section 7.1 specifies how private-use URI schemes are used for inter- 636 app communication in OAuth protocol flows. This document requires in 637 Section 7.1.1 that such schemes are based on domain names owned or 638 assigned to the app, as recommended in Section 3.8 of [RFC7595]. Per 639 section 6 of [RFC7595], registration of domain based URI schemes with 640 IANA is not required. Therefore, this document has no IANA actions. 642 10. References 644 10.1. Normative References 646 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 647 Requirement Levels", BCP 14, RFC 2119, 648 DOI 10.17487/RFC2119, March 1997, 649 . 651 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 652 Resource Identifier (URI): Generic Syntax", STD 66, 653 RFC 3986, DOI 10.17487/RFC3986, January 2005, 654 . 656 [RFC6749] Hardt, D., Ed., "The OAuth 2.0 Authorization Framework", 657 RFC 6749, DOI 10.17487/RFC6749, October 2012, 658 . 660 [RFC7595] Thaler, D., Ed., Hansen, T., and T. Hardie, "Guidelines 661 and Registration Procedures for URI Schemes", BCP 35, 662 RFC 7595, DOI 10.17487/RFC7595, June 2015, 663 . 665 [RFC7636] Sakimura, N., Ed., Bradley, J., and N. Agarwal, "Proof Key 666 for Code Exchange by OAuth Public Clients", RFC 7636, 667 DOI 10.17487/RFC7636, September 2015, 668 . 670 10.2. Informative References 672 [RFC6819] Lodderstedt, T., Ed., McGloin, M., and P. Hunt, "OAuth 2.0 673 Threat Model and Security Considerations", RFC 6819, 674 DOI 10.17487/RFC6819, January 2013, 675 . 677 [AppAuth.iOSmacOS] 678 Wright, S., Denniss, W., and others, "AppAuth for iOS and 679 macOS", February 2016, . 682 [AppAuth.Android] 683 McGinniss, I., Denniss, W., and others, "AppAuth for 684 Android", February 2016, . 687 [SamplesForWindows] 688 Denniss, W., "OAuth for Apps: Samples for Windows", July 689 2016, . 692 Appendix A. Server Support Checklist 694 OAuth servers that support native apps should: 696 1. Support custom URI-scheme redirect URIs. This is required to 697 support mobile operating systems. See Section 7.1. 699 2. Support HTTPS redirect URIs for use with public native app 700 clients. This is used by apps on advanced mobile operating 701 systems that allow app-claimed HTTPS URIs. See Section 7.2. 703 3. Support loopback IP redirect URIs. This is required to support 704 desktop operating systems. See Section 7.3. 706 4. Not assume native app clients can keep a secret. If secrets are 707 distributed to multiple installs of the same native app, they 708 should not be treated as confidential. See Section 8.9. 710 5. Support PKCE. Recommended to protect authorization code grants 711 transmitted to public clients over inter-app communication 712 channels. See Section 8.2 714 Appendix B. Operating System Specific Implementation Details 716 Most of this document defines best practices in an generic manner, 717 referencing techniques commonly available in a variety of 718 environments. This non-normative section contains OS-specific 719 implementation details for the generic pattern, that are considered 720 accurate at the time of publishing, but may change over time. 722 It is expected that this OS-specific information will change, but 723 that the overall principles described in this document for using 724 external user-agents will remain valid. 726 B.1. iOS Implementation Details 728 Apps can initiate an authorization request in the browser without the 729 user leaving the app, through the SFSafariViewController class which 730 implements the browser-view pattern. Safari can be used to handle 731 requests on old versions of iOS without SFSafariViewController. 733 To receive the authorization response, both custom URI scheme 734 redirects and claimed HTTPS links (known as Universal Links) are 735 viable choices, and function the same whether the request is loaded 736 in SFSafariViewController or the Safari app. Apps can claim Custom 737 URI schemes with the "CFBundleURLTypes" key in the application's 738 property list file "Info.plist", and HTTPS links using the Universal 739 Links feature with an entitlement file and an association file on the 740 domain. 742 Universal Links are the preferred choice on iOS 9 and above due to 743 the ownership proof that is provided by the operating system. 745 A complete open source sample is included in the AppAuth for iOS and 746 macOS [AppAuth.iOSmacOS] library. 748 B.2. Android Implementation Details 750 Apps can initiate an authorization request in the browser without the 751 user leaving the app, through the Android Custom Tab feature which 752 implements the browser-view pattern. The user's default browser can 753 be used to handle requests when no browser supports Custom Tabs. 755 Android browser vendors should support the Custom Tabs protocol (by 756 providing an implementation of the "CustomTabsService" class), to 757 provide the in-app browser tab user experience optimization to their 758 users. Chrome is one such browser that implements Custom Tabs. 760 To receive the authorization response, custom URI schemes are broadly 761 supported through Android Implicit Intends. Claimed HTTPS redirect 762 URIs through Android App Links are available on Android 6.0 and 763 above. Both types of redirect URIs are registered in the 764 application's manifest. 766 A complete open source sample is included in the AppAuth for Android 767 [AppAuth.Android] library. 769 B.3. Windows Implementation Details 771 Apps can initiate an authorization request in the user's default 772 browser using platform APIs for this purpose. 774 The custom URI scheme redirect is a good choice for Universal Windows 775 Platform (UWP) apps as it will open the app returning the user right 776 back where they were. Known on UWP as URI Activation, the scheme is 777 limited to 39 characters, but may include the "." character, making 778 short reverse domain name based schemes (as recommended in 779 Section 7.1.1) possible. 781 The loopback redirect is the common choice for traditional desktop 782 apps, listening on a loopback interface port is permitted by default 783 Windows firewall rules. 785 A complete open source sample is available [SamplesForWindows]. 787 B.4. macOS Implementation Details 789 Apps can initiate an authorization request in the user's default 790 browser using platform APIs for this purpose. 792 To receive the authorization response, custom URI schemes are are a 793 good redirect URI choice on macOS, as the user is returned right back 794 to the app they launched the request from. These are registered in 795 the application's bundle information property list using the 796 "CFBundleURLSchemes" key. Loopback IP redirects are another viable 797 option, and listening on the loopback interface is allowed by default 798 firewall rules. 800 A complete open source sample is included in the AppAuth for iOS and 801 macOS [AppAuth.iOSmacOS] library. 803 B.5. Linux Implementation Details 805 Opening the Authorization Request in the user's default browser 806 requires a distro-specific command, "xdg-open" is one such tool. 808 The loopback redirect is the recommended redirect choice for desktop 809 apps on Linux to receive the authorization response. 811 Appendix C. Acknowledgements 813 The author would like to acknowledge the work of Marius Scurtescu, 814 and Ben Wiley Sittler whose design for using custom URI schemes in 815 native OAuth 2.0 clients formed the basis of Section 7.1. 817 The following individuals contributed ideas, feedback, and wording 818 that shaped and formed the final specification: 820 Andy Zmolek, Steven E Wright, Brian Campbell, Paul Madsen, Nat 821 Sakimura, Iain McGinniss, Rahul Ravikumar, Eric Sachs, Breno de 822 Medeiros, Adam Dawes, Naveen Agarwal, Hannes Tschofenig, Ashish Jain, 823 Erik Wahlstrom, Bill Fisher, Sudhi Umarji, Michael B. Jones, Vittorio 824 Bertocci, Dick Hardt, David Waite, and Ignacio Fiorentino. 826 Authors' Addresses 828 William Denniss 829 Google 830 1600 Amphitheatre Pkwy 831 Mountain View, CA 94043 832 USA 834 Email: wdenniss@google.com 835 URI: http://wdenniss.com/appauth 837 John Bradley 838 Ping Identity 840 Phone: +1 202-630-5272 841 Email: ve7jtb@ve7jtb.com 842 URI: http://www.thread-safe.com/p/appauth.html