idnits 2.17.1 draft-ietf-oauth-native-apps-06.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 (November 13, 2016) is 2721 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: May 17, 2017 Ping Identity 6 November 13, 2016 8 OAuth 2.0 for Native Apps 9 draft-ietf-oauth-native-apps-06 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 May 17, 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 with the 376 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 authorizing native 413 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). 462 Loopback IP based redirect URIs may be susceptible to interception by 463 other apps listening on the same loopback interface. 465 As most forms of inter-app URI-based communication sends data over 466 insecure local channels, eavesdropping and interception of the 467 authorization response is a risk for native apps. App-claimed HTTPS 468 redirects are hardened against this type of attack due to the 469 presence of the URI authority, but they are still public clients and 470 the URI is still transmitted over local channels with unknown 471 security properties. 473 The Proof Key for Code Exchange by OAuth Public Clients (PKCE 474 [RFC7636]) standard was created specifically to mitigate against this 475 attack. It is a Proof of Possession extension to OAuth 2.0 that 476 protects the code grant from being used if it is intercepted. It 477 achieves this by having the client generate a secret verifier which 478 it passes in the initial authorization request, and which it must 479 present later when redeeming the authorization code grant. An app 480 that intercepted the authorization code would not be in possession of 481 this secret, rendering the code useless. 483 Public native app clients MUST protect the authorization request with 484 PKCE [RFC7636]. Authorization servers MUST support PKCE [RFC7636] 485 for public native app clients. Authorization servers SHOULD reject 486 authorization requests from native apps that don't use PKCE by 487 returning an error message as defined in Section 4.4.1 of PKCE 488 [RFC7636]. 490 8.3. Loopback Redirect Considerations 492 Loopback interface redirect URIs use the "http" scheme (i.e. without 493 TLS). This is acceptable for loopback interface redirect URIs as the 494 HTTP request never leaves the device. 496 Clients should open the loopback port only when starting the 497 authorization request, and close it once the response is returned. 499 While redirect URIs using localhost (i.e. "http://localhost:{port}/" 500 function similarly to loopback IP redirects described in Section 7.3, 501 the use of "localhost" is NOT RECOMMENDED. Opening a port on the 502 loopback interface is more secure as only apps on the local device 503 can connect to it. It is also less susceptible to misconfigured 504 routing, and interference by client side firewalls. 506 8.4. Registration of Native App Clients 508 Authorization Servers SHOULD have a way to distinguish public native 509 app clients from confidential web-clients, as the lack of client 510 authentication means they are often handled differently. A 511 configuration option to indicate a public native app client is one 512 such popular method for achieving this. 514 As recommended in Section 3.1.2.2 of OAuth 2.0 [RFC6749], the 515 authorization server SHOULD require the client to pre-register the 516 complete redirection URI. This applies and is RECOMMENDED for all 517 redirection URIs used by native apps. 519 For Custom URI scheme based redirects, authorization servers SHOULD 520 enforce the requirement in Section 7.1.1 that clients use reverse 521 domain name based schemes. 523 Authorization servers MAY request the inclusion of other platform- 524 specific information, such as the app package or bundle name, or 525 other information used to associate the app that may be useful for 526 verifying the calling app's identity, on operating systems that 527 support such functions. 529 8.5. OAuth Implicit Flow 531 The OAuth 2.0 Implicit Flow as defined in Section 4.2 of OAuth 2.0 532 [RFC6749] generally works with the practice of performing the 533 authorization request in the browser, and receiving the authorization 534 response via URI-based inter-app communication. However, as the 535 Implicit Flow cannot be protected by PKCE (which is a recommended in 536 Section 7.1.1), the use of the Implicit Flow with native apps is NOT 537 RECOMMENDED. 539 Tokens granted via the implicit flow also cannot be refreshed without 540 user interaction making the code flow, with refresh tokens the more 541 practical option for native app authorizations that require 542 refreshing. 544 8.6. Phishability of In-App Browser Tabs 546 While in-app browser tabs provide a secure authentication context, as 547 the user initiates the flow from a native app, it is possible for 548 that native app to completely fake an in-app browser tab. 550 This can't be prevented directly - once the user is in the native 551 app, that app is fully in control of what it can render, however 552 there are several mitigating factors. 554 Importantly, such an attack that uses a web-view to fake an in-app 555 browser tab will always start with no authentication state. If all 556 native apps use the techniques described in this best practice, users 557 will not need to sign-in frequently and thus should be suspicious of 558 any sign-in request when they should have already been signed-in. 560 This is the case even for authorization servers that require 561 occasional or frequent re-authentication, as such servers can 562 preserve some user identifiable information from the old session, 563 like the email address or profile picture and display that on the re- 564 authentication. 566 Users who are particularly concerned about their security may also 567 take the additional step of opening the request in the browser from 568 the in-app browser tab, and completing the authorization there, as 569 most implementations of the in-app browser tab pattern offer such 570 functionality. 572 8.7. Limitations of Non-verifiable Clients 574 As stated in Section 10.2 of OAuth 2.0 [RFC6749], the authorization 575 server SHOULD NOT process authorization requests automatically 576 without user consent or interaction, except when the identity of the 577 client can be assured. Measures such as claimed HTTPS redirects can 578 be used by native apps to prove their identity to the authorization 579 server, and some operating systems may offer alternative platform- 580 specific identity features which may be used, as appropriate. 582 8.8. Non-Browser External User-Agents 584 This best practice recommends a particular type of external user- 585 agent, the user's browser. Other external user-agent patterns may 586 also be viable for secure and usable OAuth. This document makes no 587 comment on those patterns. 589 8.9. Client Authentication 591 Secrets that are statically included as part of an app distributed to 592 multiple users should not be treated as confidential secrets, as one 593 user may inspect their copy and learn the shared secret. For this 594 reason, and those stated in Section 5.3.1 of [RFC6819], it is NOT 595 RECOMMENDED for authorization servers to require client 596 authentication of native apps using a shared secret, as this serves 597 little value beyond client identification which is already provided 598 by the "client_id" request parameter. 600 Authorization servers that still require a shared secret for native 601 app clients MUST treat the client as a public client, and not treat 602 the secret as proof of the client's identity. In those cases, it is 603 NOT RECOMMENDED to automatically issue tokens on the basis that the 604 user has previously granted access to the same client, as there is no 605 guarantee that the client is not counterfeit. 607 8.10. Cross-App Request Forgery Protections 609 Section 5.3.5 of [RFC6819] recommends using the 'state' parameter to 610 link client requests and responses to prevent CSRF attacks. 612 It is similarly RECOMMENDED for native apps to include a high entropy 613 secure random number in the 'state' parameter of the authorization 614 request, and reject any incoming authorization responses without a 615 state value that matches a pending outgoing authorization request. 617 8.11. Authorization Server Mix-Up Mitigation 619 To protect against a compromised or malicious authorization server 620 attacking another authorization server used by the same app, it is 621 RECOMMENDED that a unique redirect URI is used for each different 622 authorization server used by the app (for example, by varying the 623 path component), and that authorization responses are rejected if the 624 redirect URI they were received on doesn't match the redirect URI in 625 a pending outgoing authorization request. 627 Authorization servers SHOULD allow the registration of a specific 628 redirect URI, including path components, and reject authorization 629 requests that specify a redirect URI that doesn't exactly match the 630 one that was registered. 632 9. IANA Considerations 634 [RFC Editor: please do not remove this section.] 636 Section 7.1 specifies how private-use URI schemes are used for inter- 637 app communication in OAuth protocol flows. This document requires in 638 Section 7.1.1 that such schemes are based on domain names owned or 639 assigned to the app, as recommended in Section 3.8 of [RFC7595]. Per 640 section 6 of [RFC7595], registration of domain based URI schemes with 641 IANA is not required. Therefore, this document has no IANA actions. 643 10. References 645 10.1. Normative References 647 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 648 Requirement Levels", BCP 14, RFC 2119, 649 DOI 10.17487/RFC2119, March 1997, 650 . 652 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 653 Resource Identifier (URI): Generic Syntax", STD 66, 654 RFC 3986, DOI 10.17487/RFC3986, January 2005, 655 . 657 [RFC6749] Hardt, D., Ed., "The OAuth 2.0 Authorization Framework", 658 RFC 6749, DOI 10.17487/RFC6749, October 2012, 659 . 661 [RFC7595] Thaler, D., Ed., Hansen, T., and T. Hardie, "Guidelines 662 and Registration Procedures for URI Schemes", BCP 35, 663 RFC 7595, DOI 10.17487/RFC7595, June 2015, 664 . 666 [RFC7636] Sakimura, N., Ed., Bradley, J., and N. Agarwal, "Proof Key 667 for Code Exchange by OAuth Public Clients", RFC 7636, 668 DOI 10.17487/RFC7636, September 2015, 669 . 671 10.2. Informative References 673 [RFC6819] Lodderstedt, T., Ed., McGloin, M., and P. Hunt, "OAuth 2.0 674 Threat Model and Security Considerations", RFC 6819, 675 DOI 10.17487/RFC6819, January 2013, 676 . 678 [AppAuth.iOSmacOS] 679 Wright, S., Denniss, W., and others, "AppAuth for iOS and 680 macOS", February 2016, . 683 [AppAuth.Android] 684 McGinniss, I., Denniss, W., and others, "AppAuth for 685 Android", February 2016, . 688 [SamplesForWindows] 689 Denniss, W., "OAuth for Apps: Samples for Windows", July 690 2016, . 693 Appendix A. Server Support Checklist 695 OAuth servers that support native apps should: 697 1. Support custom URI-scheme redirect URIs. This is required to 698 support mobile operating systems. See Section 7.1. 700 2. Support HTTPS redirect URIs for use with public native app 701 clients. This is used by apps on advanced mobile operating 702 systems that allow app-claimed HTTPS URIs. See Section 7.2. 704 3. Support loopback IP redirect URIs. This is required to support 705 desktop operating systems. See Section 7.3. 707 4. Not assume native app clients can keep a secret. If secrets are 708 distributed to multiple installs of the same native app, they 709 should not be treated as confidential. See Section 8.9. 711 5. Support PKCE. Recommended to protect authorization code grants 712 transmitted to public clients over inter-app communication 713 channels. See Section 8.2 715 Appendix B. Operating System Specific Implementation Details 717 Most of this document defines best practices in an generic manner, 718 referencing techniques commonly available in a variety of 719 environments. This non-normative section contains OS-specific 720 implementation details for the generic pattern, that are considered 721 accurate at the time of publishing, but may change over time. 723 It is expected that this OS-specific information will change, but 724 that the overall principles described in this document for using 725 external user-agents will remain valid. 727 B.1. iOS Implementation Details 729 Apps can initiate an authorization request in the browser without the 730 user leaving the app, through the SFSafariViewController class which 731 implements the browser-view pattern. Safari can be used to handle 732 requests on old versions of iOS without SFSafariViewController. 734 To receive the authorization response, both custom URI scheme 735 redirects and claimed HTTPS links (known as Universal Links) are 736 viable choices, and function the same whether the request is loaded 737 in SFSafariViewController or the Safari app. Apps can claim Custom 738 URI schemes with the "CFBundleURLTypes" key in the application's 739 property list file "Info.plist", and HTTPS links using the Universal 740 Links feature with an entitlement file and an association file on the 741 domain. 743 Universal Links are the preferred choice on iOS 9 and above due to 744 the ownership proof that is provided by the operating system. 746 A complete open source sample is included in the AppAuth for iOS and 747 macOS [AppAuth.iOSmacOS] library. 749 B.2. Android Implementation Details 751 Apps can initiate an authorization request in the browser without the 752 user leaving the app, through the Android Custom Tab feature which 753 implements the browser-view pattern. The user's default browser can 754 be used to handle requests when no browser supports Custom Tabs. 756 Android browser vendors should support the Custom Tabs protocol (by 757 providing an implementation of the "CustomTabsService" class), to 758 provide the in-app browser tab user experience optimization to their 759 users. Chrome is one such browser that implements Custom Tabs. 761 To receive the authorization response, custom URI schemes are broadly 762 supported through Android Implicit Intends. Claimed HTTPS redirect 763 URIs through Android App Links are available on Android 6.0 and 764 above. Both types of redirect URIs are registered in the 765 application's manifest. 767 A complete open source sample is included in the AppAuth for Android 768 [AppAuth.Android] library. 770 B.3. Windows Implementation Details 772 Apps can initiate an authorization request in the user's default 773 browser using platform APIs for this purpose. 775 The custom URI scheme redirect is a good choice for Universal Windows 776 Platform (UWP) apps as it will open the app returning the user right 777 back where they were. Known on UWP as URI Activation, the scheme is 778 limited to 39 characters, but may include the "." character, making 779 short reverse domain name based schemes (as recommended in 780 Section 7.1.1) possible. 782 The loopback redirect is the common choice for traditional desktop 783 apps, listening on a loopback interface port is permitted by default 784 Windows firewall rules. 786 A complete open source sample is available [SamplesForWindows]. 788 B.4. macOS Implementation Details 790 Apps can initiate an authorization request in the user's default 791 browser using platform APIs for this purpose. 793 To receive the authorization response, custom URI schemes are are a 794 good redirect URI choice on macOS, as the user is returned right back 795 to the app they launched the request from. These are registered in 796 the application's bundle information property list using the 797 "CFBundleURLSchemes" key. Loopback IP redirects are another viable 798 option, and listening on the loopback interface is allowed by default 799 firewall rules. 801 A complete open source sample is included in the AppAuth for iOS and 802 macOS [AppAuth.iOSmacOS] library. 804 B.5. Linux Implementation Details 806 Opening the Authorization Request in the user's default browser 807 requires a distro-specific command, "xdg-open" is one such tool. 809 The loopback redirect is the recommended redirect choice for desktop 810 apps on Linux to receive the authorization response. 812 Appendix C. Acknowledgements 814 The author would like to acknowledge the work of Marius Scurtescu, 815 and Ben Wiley Sittler whose design for using custom URI schemes in 816 native OAuth 2.0 clients formed the basis of Section 7.1. 818 The following individuals contributed ideas, feedback, and wording 819 that shaped and formed the final specification: 821 Andy Zmolek, Steven E Wright, Brian Campbell, Paul Madsen, Nat 822 Sakimura, Iain McGinniss, Rahul Ravikumar, Eric Sachs, Breno de 823 Medeiros, Adam Dawes, Naveen Agarwal, Hannes Tschofenig, Ashish Jain, 824 Erik Wahlstrom, Bill Fisher, Sudhi Umarji, Michael B. Jones, Vittorio 825 Bertocci, Dick Hardt, David Waite, and Ignacio Fiorentino. 827 Authors' Addresses 829 William Denniss 830 Google 831 1600 Amphitheatre Pkwy 832 Mountain View, CA 94043 833 USA 835 Email: wdenniss@google.com 836 URI: http://wdenniss.com/appauth 838 John Bradley 839 Ping Identity 841 Phone: +1 202-630-5272 842 Email: ve7jtb@ve7jtb.com 843 URI: http://www.thread-safe.com/p/appauth.html