Open Authentication Protocol | T. Lodderstedt, Ed. |
Internet-Draft | yes.com AG |
Intended status: Standards Track | V. Dzhuvinov |
Expires: March 22, 2020 | Connect2id Ltd. |
Sep 19, 2019 |
JWT Response for OAuth Token Introspection
draft-ietf-oauth-jwt-introspection-response-08
This specification proposes an additional JSON Web Token (JWT) secured response for OAuth 2.0 Token Introspection.
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."
This Internet-Draft will expire on March 22, 2020.
Copyright (c) 2019 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
OAuth 2.0 Token Introspection specifies a method for a protected resource to query an OAuth 2.0 authorization server to determine the state of an access token and obtain data associated with the access token. This enables deployments to implement opaque access tokens in an interoperable way.
The introspection response, as specified in OAuth 2.0 Token Introspection, is a plain JSON object. However, there are use cases where the resource server requires stronger assurance that the authorization server issued the token introspection response for an access token, including cases where the authorization server assumes liability for the content of the token introspection response. An example is a resource server using verified person data to create certificates, which in turn are used to create qualified electronic signatures.
In such use cases it may be useful or even required to return a signed JWT as the introspection response. This specification extends the token introspection endpoint with the capability to return responses as JWTs.
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 BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
The authorization server (AS) and the resource server (RS) maintain a strong two-way trust relationship. The resource server relies on the authorization server to obtain authorization, user and other data as input to its access control decisions and service delivery. The authorization server relies on the resource server to handle the provided data appropriately.
In the context of this specification, the Token Introspection Endpoint is used to convey such security data and potentially also privacy sensitive data related to an access token.
In order to process the introspection requests in a secure and privacy-preserving manner, the authorization server MUST be able to identify, authenticate and authorize resource servers.
To support encrypted token introspection response JWTs, the authorization server MUST also be provided with the respective resource server encryption keys and algorithms.
The authorization server MUST be able to determine whether an RS is the audience for a particular access token and what data it is entitled to receive, otherwise the RS is not authorized to obtain data for the access token. The AS has the discretion how to fulfil this requirement. The AS could, for example, maintain a mapping between scopes values and resource servers.
The requirements given above imply that the authorization server maintains credentials and other configuration data for each RS.
One way is by utilizing dynamic client registration [RFC7591] and treating every RS as an OAuth client. In this case, the authorization server is assumed to at least maintain "client_id" and "token_endpoint_auth_method" with complementary authentication method metadata, such as "jwks" or "client_secret". In cases where the AS needs to acquire consent to transmit data to a RS, the following client metadata fields are recommended: "client_name", "client_uri", "contacts", "tos_uri", "policy_uri".
The AS MUST restrict the use of client credentials by a RS to the calls it requires, e.g. the AS MAY restrict such a client to call the token introspection endpoint only. How the AS implements this restriction is beyond the scope of this specification.
This specification further introduces client metadata to manage the configuration options required to sign and encrypt token introspection response JWTs.
A resource server requests to receive a JWT introspection response by including an Accept header with content type "application/jwt" in the introspection request.
Authentication at the token introspection endpoint can utilize client authentication methods or a separate access token issued to the resource server. Whether a resource server is required to authenticate is determined by the respective RS-specific policy at the AS.
The following is a non-normative example request using client authentication:
POST /introspect HTTP/1.1 Host: server.example.com Accept: application/jwt Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW Content-Type: application/x-www-form-urlencoded token=2YotnFZFEjr1zCsicMWpAA
If required by its policy, the authorization server MUST authenticate the caller and check its authorization to use the token introspection endpoint.
The introspection endpoint responds with a JWT, setting the "Content-Type" header to "application/jwt". This JWT is a cryptographically protected representation of the token introspection response as specified in [RFC7662].
Note: Although the JWT format is widely used as an access token format, the JWT returned in the introspection response is not an alternative representation of the introspected access token and is not intended to be used as an access token.
JWT metadata values, such as iat, might differ between the token introspection response in JWT format and the introspected access token (see below).
This specification registers the "application/token-introspection+jwt" media type, which is used as value of the typ header parameter of the JWT to indicate that the payload is a token introspection response.
If the access token is invalid, expired, has been revoked, or is not intended to be consumed by the calling resource server (audience), the authorization server MUST set the value of the response claim active to false. Otherwise, this claim is set to true.
If the access token is considered active, it MUST contain the claims iss and aud in order to prevent misuse of the JWT as an ID or access token (see Section 8.1).
The iss MUST be set to the issuer URL of the AS.
The value of the aud claims MUST identify the resource server receiving the token introspection response.
If the AS adds the following claims to the token introspection response their meaning is defined as follows:
Further content of the introspection response is determined by the RS-specific policy at the AS.
If possible, the AS MUST narrow down the scope value to the scopes relevant to the particular RS.
The JWT formatted introspection response MAY contain further claims, especially the claims defined in the "OAuth Token Introspection Response" registry established by [RFC7662] and the "JSON Web Token Claims" registry established by [RFC7519].
This includes claims from the "JSON Web Token Claims" registry that are commonly used in [OpenID.Core] and can be applied to the resource owner. These claims can serve to identify the resource owner as a natural person or to provide a required contact detail, such as an e-Mail address or phone number. When transmitting such claims the AS acts as an identity provider in regard to the RS.
The AS determines based on the RS-specific policy what claims about the resource owner to return in the token introspection response. The AS MUST ensure that the release of any privacy-sensitive data is legally based.
The following is a non-normative example response (with line breaks for display purposes only):
HTTP/1.1 200 OK Content-Type: application/jwt eyJ0eXAiOiJ0b2tlbi1pbnRyb3NwZWN0aW9uK2p3dCIsImFsZyI6IlJTMjU2In0.eyJ pc3MiOiJodHRwczovL3NlcnZlci5leGFtcGxlLmNvbS8iLCJhdWQiOiJzNkJoZFJrcX QzIiwianRpIjoidDFGb0NDYVpkNFh2NE9SSlVXVlVlVFpmc0toVzMwQ1FDcldERGp3W Hk2dyIsImFjdGl2ZSI6dHJ1ZSwic2NvcGUiOiJyZWFkIHdyaXRlIGRvbHBoaW4iLCJl eHAiOjE1MTQ3OTc5NDIwMDAsImlhdCI6MTUxNDc5NzgyMjAwMCwiY2xpZW50X2lkIjo iczZCaGRSa3F0MyIsInN1YiI6Ilo1TzN1cFBDODhRckFqeDAwZGlzIiwiZ2l2ZW5fbm FtZSI6IkpvaG4iLCJmYW1pbHlfbmFtZSI6IkRvZSIsImJpcnRoZGF0ZSI6IjE5ODItM DItMDEifQ.mnGNVJJwMaMR-drVHIyjOd7S5mScHT5tYC_sLdeaS9C4pkmiOgwHNGah9 w_15kbotjDckotJNHpNTQCcE5nRC29L_jz5hSCNTMmK62fJdEcq0QVuCL_roeHzc-s1 bjU2V2Qme6_2468zqcuhf1fhcieWxx9bDwFFwk3su0qdoF9RBa0HobWzy1ENU6MjiKH vmrnd5PkJenn1rJEt0EQTUuVE0vh2tQGhxbaZkQ34mLLgES5TCuBK7ALDXhT4aGCzxg 3jLprs_jYTjCq2kugptseKaxsvti0TxOxmxLPcuy5xRxHDUzV2h9_VWVJRgM8y0vhLN v9XKDe4EQqaIFLA_YD4TBeyPV7Sm4xMQ-2OsSmAz0E2BY_b_s0WrFN2K8tspQhj2mnG v7Zz8O3zeE2gC59JR56aU_SNspGPbt8GvTwuL5ZZTCmiWKUzQ0ev4zVthUczQmK53dx Zl6ZxBfIRPV5k1GTPyEPbWehizbJT4JBSLlk-l8JvJcfL2USLtJgMLH1D01fww0IqN1 ofHeHFUmZWB_LR7kGaJ8Kx_a9z4CaaVesW8jzgSmwA8K_pv9yJqqjnUhsh51c49OAgn cqwAahGrUhrN0dIBrd6sRXU3AiRpaah0MMNcjR2UJbEZKwnMyHTkBQAeZAe9vO9pKV8 JOd0ziYBpAbEpYGE4p3wog4
The example response header contains the following JSON document:
{ "typ": "token-introspection+jwt", "alg": "RS256" }
The example response payload contains the following JSON document:
{ "iss":"https://server.example.com/", "aud":"s6BhdRkqt3", "jti": "t1FoCCaZd4Xv4ORJUWVUeTZfsKhW30CQCrWDDjwXy6w", "active":true, "scope":"read write dolphin", "exp":1514797942000, "iat":1514797822000, "client_id":"s6BhdRkqt3", "sub":"Z5O3upPC88QrAjx00dis", "given_name":"John", "family_name":"Doe", "birthdate":"1982-02-01" }
Depending on the specific resource server policy the JWT is either signed, or signed and encrypted. If the JWT is signed and encrypted it MUST be a Nested JWT, as defined in JWT.
Note: If the resource server policy requires a signed and encrypted response and the authorization server receives an unauthenticated request containing an Accept header with content type other than "application/jwt", it MUST refuse to serve the request and return an HTTP status code 400. This is done to prevent downgrading attacks to obtain token data intended for release to legitimate recipients only (see Section 8.2).
The authorization server determines what algorithm to employ to secure the JWT for a particular introspection response. This decision can be based on registered metadata parameters for the resource server, supplied via dynamic client registration [RFC7591] with the resource server acting as a client, as specified below.
The parameter names follow the pattern established by OpenID Connect Dynamic Client Registration for configuring signing and encryption algorithms for JWT responses at the UserInfo endpoint.
The following client metadata parameters are introduced by this specification:
Resource servers may register their public encryption keys using the jwks_uri or jwks metadata parameters.
Authorization servers SHOULD publish the supported algorithms for signing and encrypting the JWT of an introspection response by utilizing OAuth 2.0 Authorization Server Metadata parameters. Resource servers use this data to parametrize their client registration requests.
The following parameters are introduced by this specification:
Token introspection responses in JWT format, access tokens in JWT format, and OpenID Connect ID Tokens are syntactical similar. Attackers could try to utilize this fact and attempt to use a token introspection response as access token when invoking a resource server or as ID Token when logging into at a OpenID Connect RP.
Any relying party processing the typ JWT header element should detect the attack since token introspection responses in JWT format set this header to the value "token-introspection+jwt". Unfortunately, this is not a well established practice yet.
As an alternative approach, such an attack can be prevented like any other token substitution attack by restricting the audience of the JWT. As specified in Section 5, the authorization server includes the claims iss and aud in each JWT introspection response, with the iss value set to the authorization server's issuer URL and the aud value set to the resource server's identifier. Any recipient of an JWT MUST check these values in order to detect substitution attacks.
OpenID Connect RPs are additionally expected to use and check the nonce parameter and claim to prevent token and code replay.
Resource servers MUST additionally apply the countermeasures against replay as described in [I-D.ietf-oauth-security-topics], section 3.2.
JWT Confusion and other attacks involving JWTs are discussed in [I-D.ietf-oauth-jwt-bcp].
The authorization server MUST use Transport Layer Security (TLS) 1.2 (or higher) per BCP 195 [RFC7525] in order to prevent token data leakage.
To prevent introspection of leaked tokens and to present an additional security layer against token guessing attacks the authorization server MAY require all requests to the token introspection endpoint to be authenticated. As an alternative or as an addition to the authentication, the intended recipients MAY be set up for encrypted responses.
In the latter case, confidentiality is ensured by the fact that only the legitimate recipient is able to decrypt the response. An attacker could try to circumvent this measure by requesting a plain JSON response, using an Accept header with the content type set to, for example, "application/json" instead of "application/jwt". To prevent this attack the authorization server MUST NOT serve requests with a content type other than "application/jwt" if the resource server is set up to receive encrypted responses (see also Section 5).
Authorization servers with a policy that requires token data to be kept confidential from OAuth clients must require all requests to the token introspection endpoint to be authenticated. As an alternative or as an addition to the authentication, the intended recipients may be set up for encrypted responses.
Authorization servers with a policy that requires token introspection activity to be logged and audited must require all requests to the token introspection endpoint to be authenticated.
The token introspection response can be used to transfer personal identifiable information from the AS to the RS. The AS MUST ensure a legal basis exists for the data transfer before any data is released to a particular RS. The way the legal basis is established might vary among jurisdictions and MUST consider the legal entities involved.
For example, the classical way to establish the legal basis is by explicit user consent gathered from the resource owner by the AS during the authorization flow.
It is also possible that the legal basis is established out of band, e.g. in an explicit contract or by the client gathering the resource owner's consent.
If the AS and the RS belong to the same legal entity (1st party scenario), there is potentially no need for an explicit user consent but the terms of service and policy of the respective service provider MUST be enforced at all times.
In any case, the AS MUST ensure that the scope of the legal basis is enforced throughout the whole process. The AS MUST retain the scope of the legal basis with the access token, e.g. in the scope value, and the AS MUST determine the data a resource server is allowed to receive based on the resource server’s identity and suitable token data, e.g. the scope value.
We would like to thank Petteri Stenius, Neil Madden, Filip Skokan, Tony Nadalin, and Remco Schaar for their valuable feedback.
This specification requests registration of the following client metadata definitions in the IANA "OAuth Dynamic Client Registration Metadata" registry [IANA.OAuth.Parameters] established by [RFC7591]:
This specification requests registration of the following values in the IANA "OAuth Authorization Server Metadata" registry [IANA.OAuth.Parameters] established by [RFC8414].
This section registers the "application/token-introspection+jwt" media type in the "Media Types" registry [IANA.MediaTypes] in the manner described in [RFC6838], which can be used to indicate that the content is a token introspection response in JWT format.
[IANA.OAuth.Parameters] | IANA, "OAuth Parameters" |
[[ To be removed from the final specification ]]
-08
-07
-06
-05
-04
-03
-02
-01
-00
WG draft
-01
-00