Skip to content

Commit 7dfd8bc

Browse files
committed
Add OAuth 2.0 Token Exchange (RFC 8693) to the supported OAuth flows
Adds a tokenExchange fixed field to the OAuth Flows Object, mirroring the deviceAuthorization pattern: tokenUrl required, scopes as for all flows. Includes the validation schema addition and test fixtures. Refs discussion #4807.
1 parent 132dfb0 commit 7dfd8bc

4 files changed

Lines changed: 33 additions & 2 deletions

File tree

src/oas.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4577,7 +4577,7 @@ and `./examples/productNoNulls.xml` would be:
45774577

45784578
Defines a security scheme that can be used by the operations.
45794579

4580-
Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter), mutual TLS (use of a client certificate), OAuth2's common flows (implicit, password, client credentials and authorization code) as defined in [RFC6749](https://tools.ietf.org/html/rfc6749), OAuth2 device authorization flow as defined in [RFC8628](https://tools.ietf.org/html/rfc8628), and [[OpenID-Connect-Core]].
4580+
Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter), mutual TLS (use of a client certificate), OAuth2's common flows (implicit, password, client credentials and authorization code) as defined in [RFC6749](https://tools.ietf.org/html/rfc6749), OAuth2 device authorization flow as defined in [RFC8628](https://tools.ietf.org/html/rfc8628), OAuth2 token exchange as defined in [RFC8693](https://tools.ietf.org/html/rfc8693), and [[OpenID-Connect-Core]].
45814581
Please note that as of 2020, the implicit flow is about to be deprecated by [OAuth 2.0 Security Best Current Practice](https://tools.ietf.org/html/draft-ietf-oauth-security-topics). Recommended for most use cases is Authorization Code Grant flow with PKCE.
45824582

45834583
#### Fixed Fields
@@ -4654,6 +4654,7 @@ Allows configuration of the supported OAuth Flows.
46544654
| <a name="oauth-flows-client-credentials"></a>clientCredentials | [OAuth Flow Object](#oauth-flow-object) | Configuration for the OAuth Client Credentials flow. Previously called `application` in OpenAPI 2.0. |
46554655
| <a name="oauth-flows-authorization-code"></a>authorizationCode | [OAuth Flow Object](#oauth-flow-object) | Configuration for the OAuth Authorization Code flow. Previously called `accessCode` in OpenAPI 2.0. |
46564656
| <a name="oauth-flows-device-authorization"></a>deviceAuthorization | [OAuth Flow Object](#oauth-flow-object) | Configuration for the OAuth Device Authorization flow. |
4657+
| <a name="oauth-flows-token-exchange"></a>tokenExchange | [OAuth Flow Object](#oauth-flow-object) | Configuration for the OAuth Token Exchange flow. |
46574658

46584659
This object MAY be extended with [Specification Extensions](#specification-extensions).
46594660

@@ -4667,7 +4668,7 @@ Configuration details for a supported OAuth Flow
46674668
| ---- | :----: | ---- | ---- |
46684669
| <a name="oauth-flow-authorization-url"></a>authorizationUrl | `string` | `oauth2` (`"implicit"`, `"authorizationCode"`) | **REQUIRED**. The authorization URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. |
46694670
| <a name="oauth-flow-device-authorization-url"></a>deviceAuthorizationUrl | `string` | `oauth2` (`"deviceAuthorization"`) | **REQUIRED**. The device authorization URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. |
4670-
| <a name="oauth-flow-token-url"></a>tokenUrl | `string` | `oauth2` (`"password"`, `"clientCredentials"`, `"authorizationCode"`, `"deviceAuthorization"`) | **REQUIRED**. The token URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. |
4671+
| <a name="oauth-flow-token-url"></a>tokenUrl | `string` | `oauth2` (`"password"`, `"clientCredentials"`, `"authorizationCode"`, `"deviceAuthorization"`, `"tokenExchange"`) | **REQUIRED**. The token URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. |
46714672
| <a name="oauth-flow-refresh-url"></a>refreshUrl | `string` | `oauth2` | The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. |
46724673
| <a name="oauth-flow-scopes"></a>scopes | Map[`string`, `string`] | `oauth2` | **REQUIRED**. The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. The map MAY be empty. |
46734674

src/schemas/validation/schema.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,8 @@ $defs:
10391039
$ref: '#/$defs/oauth-flows/$defs/authorization-code'
10401040
deviceAuthorization:
10411041
$ref: '#/$defs/oauth-flows/$defs/device-authorization'
1042+
tokenExchange:
1043+
$ref: '#/$defs/oauth-flows/$defs/token-exchange'
10421044
$ref: '#/$defs/specification-extensions'
10431045
unevaluatedProperties: false
10441046

@@ -1136,6 +1138,23 @@ $defs:
11361138
$ref: '#/$defs/specification-extensions'
11371139
unevaluatedProperties: false
11381140

1141+
token-exchange:
1142+
type: object
1143+
properties:
1144+
tokenUrl:
1145+
type: string
1146+
format: uri-reference
1147+
refreshUrl:
1148+
type: string
1149+
format: uri-reference
1150+
scopes:
1151+
$ref: '#/$defs/map-of-strings'
1152+
required:
1153+
- tokenUrl
1154+
- scopes
1155+
$ref: '#/$defs/specification-extensions'
1156+
unevaluatedProperties: false
1157+
11391158
security-requirement:
11401159
$comment: https://spec.openapis.org/oas/v3.3#security-requirement-object
11411160
type: object

tests/schema/minimal-objects.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,10 @@
155155
tokenUrl: https://example.com/auth
156156
scopes: {}
157157

158+
- objectName: OAuth Flow Object (tokenExchange)
159+
subSchemaPath: /$defs/oauth-flows/$defs/token-exchange
160+
minimalInstance:
161+
tokenUrl: https://example.com/token
162+
scopes: {}
163+
158164
# Security Requirement Object allows additional properties

tests/schema/pass/security-scheme-object-examples.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ components:
5353
scopes:
5454
read:pets: read your pets
5555
refreshUrl: https://example.com/api/oauth/refresh
56+
tokenExchange:
57+
tokenUrl: https://example.com/api/oauth/token
58+
scopes:
59+
read:pets: read your pets
60+
refreshUrl: https://example.com/api/oauth/refresh
5661
OAuth2Old:
5762
deprecated: true
5863
type: oauth2

0 commit comments

Comments
 (0)