Mobile App Native SSO | March 2024 | |
Fletcher | Standards Track | [Page] |
OpenID Connect 1.0 is a simple identity layer on top of the OAuth 2.0 protocol. It enables Clients to verify the identity of the End-User based on the authentication performed by an Authorization Server, as well as to obtain basic profile information about the End-User in an interoperable and REST-like manner.¶
This document describes a mechanism that allows a mobile app to share the identity/authentication obtained by a different mobile app where both apps are written by the same vendor.¶
OpenID Connect 1.0 is a simple identity layer on top of the OAuth 2.0 [RFC6749] protocol. It enables Clients to verify the identity of the End-User based on the authentication performed by an Authorization Server, as well as to obtain basic profile information about the End-User in an interoperable and REST-like manner.¶
As the industry moves to a more mobile oriented environment, vendors need a way to share identity across the multiple mobile apps they deploy. While the current OAuth2 best practice allows for SSO across any mobile app by sharing the session cookies in the system browser, this has risks such as a user clearing their system browser of cookies (possibly as requested by a customer care agent) or using private browsing on iOS and Android. On most mobile platforms, mobile apps signed by the same vendor certs can share information via the system "keychain" (Account Manager on Android).¶
The purpose of this specification is to provide a single-sign-on (SSO) mechanism across mobile applications installed on the same device that addresses the risks highlighted above and that provides an equivalent SSO solution to that provided if using a web browser.¶
This document specifies a new scope, extends the token endpoint and profiles the OAuth2 Token Exchange [RFC8693] spec allowing mobile apps to share identity (SSO) between apps produced and signed by the same vendor (i.e. signed with the same vendor certificate).¶
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [RFC2119].¶
In the .txt version of this specification,
values are quoted to indicate that they are to be taken literally.
When using these values in protocol messages,
the quotes MUST NOT be used as part of the value.
In the HTML version of this specification,
values to be taken literally are indicated by
the use of this fixed-width font
.¶
This specification uses the terms "Authorization Server", "Client", "Client Identifier", and "Redirection URI" defined by OAuth 2.0 [RFC6749], the term "User Agent" defined by RFC 7230 [RFC7230], the term "native app" defined by RFC 8252 [RFC8252] and the terms defined by OpenID Connect Core 1.0 [OpenID.Core].¶
This specification also defines the following terms:¶
+----------+ +----------+ +-----------+ +------------+ | Native | | Native | | System | | | | App | | App | | Browser | | AS | | #1 | | #2 | | | | | +----+-----+ +----+-----+ +-----+-----+ +-----+------+ | | | | | [1] Start OpenID Connect AuthN | | +----------------+----------------> | | | | | [2] /authorize | | | +----------------> | | | | | | | | [3] authenticate | | | <----------------| | | | | | | | [4] user creds | | | +----------------> | | | | | | | | [5] callback | | | | <----------------+ | [6] callback with code | | | <--------------+------------------+ | | | | | | [7] exchange code for tokens | | +----------------+-----------------------------------> | | | | | | [8] tokens (including device_secret) | | <--------------+------------------+------------------+ | | | | | | | | | | | | + + + +¶
Steps [1] - [8] are the standard OpenID Connect authorization_code
flow with the following extensions. In step 2, the
device_sso
scope is specified signifying that the client is requesting a
device_secret
to be returned when
the code is exchanged for tokens.¶
After step 8, Native App #1 stores the device_secret and id_token in the protected device storage accessible only to Native App #2.¶
Native App #2 uses the stored data from the shared device storage to obtain tokens for the user thus enabling the app to access the user's resources (i.e. SSO)¶
+----------+ +----------+ +-----------+ +------------+ | Native | | Native | | System | | | | App | | App | | Browser | | AS | | #1 | | #2 | | | | | +----+-----+ +----+-----+ +-----+-----+ +-----+------+ | | | | | | | | | | [9] token exchange | | +------------------+----------------> | | | | | | | | | | | [10] refresh, access, [device_secret] | | <----------------+------------------| | | | | | | | | | | | | + + + +¶
Step [9] invokes the /token endpoint with the token exchange profile passing the id_token obtained from the shared device storage, the client_id and the device secret.¶
Step [10] returns the SSO generated refresh and access tokens for Native App #2.¶
The following sections describe the extensions required to the standard OpenID Connect Authentication flow which will enable a second mobile app to share the authentication of the first mobile app where both mobile applications are signed by the same vendor certificates.¶
This specification defines a new scope value that is used to convey
to the Authorization Server that when the code is exchanged for a
token, a new device_secret
will be
returned in addition to the other tokens identified as part of the
authorization request.¶
The new scope value is defined as device_sso
.
When this scope is present on the authorization request, when the
code is exchanged for tokens, a new device_secret will be returned.¶
The device secret contains relevant data to the device and the current users authenticated with the device. The device secret is completely opaque to the client and as such the AS MUST adequately protect the value such as using a JWE if the AS is not maintaining state on the backend.¶
In the context of this extension the device secret may be shared
between mobile apps that can obtain the value via the shared
security mechanism (e.g. keychain on iOS). If a mobile app
requests a device secret via the device_sso
scope and a device_secret
exists, then
the client MUST provide the device_secret
on the request to the /token endpoint to exchange
code for tokens. The client SHOULD provide the
device_secret
to the /token endpoint
during refresh token requests so that the AS may rotate the
device_secret as necessary.¶
The exact construction of the device_secret
is out of scope for this specification.¶
During a normal user authentication via the system browser, after the mobile app receives the code and state response from the Authorization Server, this spec defines the following additional parameters to the /token endpoint for the authorization_code grant_type.¶
device_sso
scope and the client
already has a device_secret
available. If no device_secret
is
specified and the refresh_token contains the
device_sso
scope, a new
device_secret
will be generated.¶
When the authorization server receives the
device_secret
value it MUST
process the authorization_code grant type per the OpenID Connect spec with the
following additions applying to the id_token.¶
Add a ds_hash
claim to the id_token to represent a function of
the device_secret.¶
Add a session id to the id_token that represents the user's current authentication session.¶
Note that the implementation of this spec and the specification of the ds_hash and sid value MUST NOT leak any data that would provide a security advantage to an attacker who gains access to the id_token.¶
When the authorization server receives the device_secret it must validate the token. If the token is invalid it must be discarded and the request processed as if no device_secret was specified.¶
If the authorization request included the device_sso scope then the authorization server MUST return a device_secret in the response. The device_secret is returned in the device_token claim of the returned JSON data.¶
If no devices_secret is specified, then the AS MUST generate the token. If a device_secret is specified and is valid, the AS MAY update the device_secret as necessary. Regardless a device_secret must be returned in the response.¶
This section profiles the OAuth2 Token Exchange [RFC8693] spec and describes the processing rules used to exchange a previous authentication for new refresh and access tokens requested by a mobile app created by the same vendor as the first mobile app and both apps signed by the same developer certificate.¶
The client authenticates using its registered token endpoint client authentication method. This could range from HTTP Basic Authentication, to OpenID Connect defined private_key_jwt. The AS must be able to obtain the client_id of the requesting mobile app (mobile app #2) from the client authentication method.¶
This profile defines the use of the following token exchange parameters.¶
This profile also defines the following token type identifiers.¶
When a mobile app wants to request native SSO (i.e. obtain refresh and access tokens for an already signed in user) it makes a standard OAuth2 /token endpoint request following the profile for Token Exchange defined above.¶
The following is a non-normative example¶
POST /token HTTP/1.1 Host: as.example.com Authorization: Basic ZGZhZGYyMzUyNDU0Og ... grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange &audience=https%3A%3F%3Flogin.example.net&subject_token=<id_token> &subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aid-token &actor_token=95twdf3w4y6wvftw35634t &actor_token_type=urn%3Ax-oath%3Aparams%3Aoauth%3Atoken-type%3Adevice-secret¶
The client_id in this request is sent via the HTTP Basic Authentication method using the HTTP Authorization header.¶
When the authorization server receives a request at the token endpoint conforming to this profile it MUST perform the following checks before issuing any tokens.¶
Validate the device_secret to ensure the token is still valid. The format of this secret is defined by the Authorization server and is out of scope for this specification.¶
Verify the id_token for integrity protection by validating the signature of the id_token JWT.¶
Verify the binding between the id_token and the device_secret
by validating the ds_hash
value obtained
from the id_token
matches the
device_secret
provided in the
actor_token
parameter.¶
Verify that the session id in the id_token (sid claim) is still valid. If the session is no longer valid, the AS MUST return an error of invalid_grant. Note that in the case of a refresh_tokens issued with an offline_scope the 'sid' value SHOULD represent the offline "session" such that if the original refresh_token is revoked the 'ds_hash' value in the id_token is no longer valid.¶
Validate that the client requesting native SSO is authorized to do so. The AS SHOULD maintain a list of client_ids that can share user authentications. For example, the AS MAY take the 'aud' claim from the id_token and the client_id from the token request and ensures that both client_ids are allowed to share user authentications.¶
The AS SHOULD verify that the scopes requested by the client in the token request (either default scopes or explicitly specified in the optional scope parameter) do NOT require explicit user consent. If any requested scopes require explicit user consent the AS SHOULD fail the request and return an error of invalid_scope.¶
Based on the AS definition of the device_secret, the AS may perform additional checks to ensure the security of the request. Provided the above criteria is met, the AS will issue a normal Token Response object containing a refresh_token, access_token and id_token issued to the client_id of the mobile app making the request. The session associated with the new refresh_token SHOULD be the same as that used to verify the validity of the SSO exchange. If that session expires, all refresh_tokens associated with it MUST be invalidated.¶
The Token Exchange response for this profile has the following characteristics:¶
bearer
.¶
In the case of any errors, the AS MUST return a valid OAuth2 Error response as described in Section 2.2.2 of the Token Exchange spec.¶
The following is a non-normative example¶
HTTP/1.1 200 OK Content-Type: application/json Cache-Control: no-store { "access_token":"2YotnFZFEjr1zCsicMWpAA", "issued_token_type": "urn:ietf:params:oauth:token-type:access_token", "token_type":"Bearer", "expires_in":3600, "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA", "id_token":"<id_token>", "device_secret":"casdfgarfgasdfg" }¶
This specification extends the OpenID Connect Discovery Metadata Section 3 [OpenID.Discovery] and defines the following:¶
true
identifying that the AS
supports this OpenID Connect specification.¶
This metadata parameter is OPTIONAL in the context of the OpenID Provider
not supporting the Native SSO for Mobile Apps specification. If omitted,
the Relying Party SHOULD assume that this specification is not
supported. The OpenID Provider MAY provide this metadata parameter even
if it doesn't support the Native SSO for Mobile Apps specification by
including the native_sso_support
parameter with a
value of false
.¶
Sufficient care must be made to protect the device_secret
.
The device secret SHOULD be encrypted by the Authorization Service and periodically
refreshed via the mechanisms described in this specification.¶
If it is possible to move correctly bound device_secret
and id_token
to a separate device, that device can obtain
the user's authentication state on the new device. An implementation of this
specification SHOULD use best efforts to bind the device_secret to the device instance
to prevent exfiltration of the device_secret
and
id_token
from the device.¶
Use of the id_token in this specification takes some liberties with id_token validation.
For instance, the aud
claim normally identifies the client
receiving the id_token and not the authorization server that issued the id_token.
Additionally, the id_token may have expired at the time of use designated by this specification.¶
This specification does not ensure that the user (human) who logs into mobile app 1 is the same user who is SSO'd into mobile app 2. This is equivalent to web based SSO where once the browser instance is logged in, the SSO event to a new endpoint assumes the user identity is the same. For this specification, if the destination mobile app requires a user identity check due to risk or some other reason, how that mobile app verifies the user is out of scope for this specification.¶
This specification registers the following parameter in the IANA "OAuth Parameters" registry [IANA.OAuth.Parameters] established by RFC 6749 [RFC6749].¶
Parameter name: device_secret
¶
Parameter usage location: Authorization Response, Access Token Request, Access Token Response¶
Change controller: OpenID Foundation Artifact Binding Working Group - openid-specs-ab@lists.openid.net¶
Specification document(s): Section 3.3 of this document¶
Related information: None¶
This specification registers the following metadata name in the IANA "OAuth Authorization Server Metadata" registry [IANA.OAuth.Parameters] established by [RFC8414].¶
The OpenID Community would like to thank the following people for their contributions to this specification:¶
Copyright (c) 2024 The OpenID Foundation.¶
The OpenID Foundation (OIDF) grants to any Contributor, developer, implementer, or other interested party a non-exclusive, royalty free, worldwide copyright license to reproduce, prepare derivative works from, distribute, perform and display, this Implementers Draft or Final Specification solely for the purposes of (i) developing specifications, and (ii) implementing Implementers Drafts and Final Specifications based on such documents, provided that attribution be made to the OIDF as the source of the material, but that such attribution does not indicate an endorsement by the OIDF.¶
The technology described in this specification was made available from contributions from various sources, including members of the OpenID Foundation and others. Although the OpenID Foundation has taken steps to help ensure that the technology is available for distribution, it takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this specification or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any independent effort to identify any such rights. The OpenID Foundation and the contributors to this specification make no (and hereby expressly disclaim any) warranties (express, implied, or otherwise), including implied warranties of merchantability, non-infringement, fitness for a particular purpose, or title, related to this specification, and the entire risk as to implementing this specification is assumed by the implementer. The OpenID Intellectual Property Rights policy requires contributors to offer a patent promise not to assert certain patent claims against other contributors and against implementers. The OpenID Foundation invites any interested party to bring to its attention any copyrights, patents, patent applications, or other proprietary rights that may cover technology that may be required to practice this specification.¶
[[ To be removed from the final specification ]]¶
-06¶
Updated the draft version and tweaked some language based on updates from Vivek Shankar.¶
Added Notices section.¶
-05¶
Updated the draft version and tweaked some language based on updates from Naveen CM.¶
-04¶
Normative change to verify the id_token plus other edits based on feedback from Joseph Heenan.¶
Also updated Security Considerations section and general cleanup.¶
-03¶
-00¶
Initial Draft.¶