-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Enhancing specification to describe token presentation mechanisms for OAuth 2.0 #3612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@LasneF @lornajane Based on feedback and aiming for flexibility in specifying authentication schemes, I propose the following adjustment to the
This revision aims to maintain the required status for Would this approach be preferable, or should we consider adding a new optional field specifically for I'm looking forward to the community's input to refine this proposal further. If this approach meets the community's approval, I will proceed to create a new PR targeting the 3.2 branch to incorporate these changes. |
I'm sorry it's been a while since we discussed this, but I'd like to pick it up again as we prepare for 3.2. I am of the opinion that a field can only be required or optional, so we'd have to have it required in both situations, or choose a different option. @alex-feel can you suggest some alternatives that would make sense for the expected use cases? |
@lornajane, thank you for getting back to the discussion and for your feedback on this issue. My apologies for the delayed response — I was offline for the past day. I understand your point that a field can only be required or optional, and I will explore alternative approaches that might address the expected use cases. I'll update this thread as soon as I have a potential solution to share. |
I’d like to propose a new optional object. This proposal aims to:
Proposal:
|
Requirement | How it’s satisfied |
---|---|
All RFC 6750 Bearer delivery modes | The accessToken oneOf construct allows specifying: 1. scheme: bearer for Authorization: Bearer <token> . 2. in: query, name: access_token for query parameters. 3. in: body, name: access_token for form body parameters. |
Support for Refresh Tokens | Dedicated refreshToken object with in and name allows clear description of its presentation. |
Future-proof PoP schemes | proofTokens as an array of objects (each defined either by scheme or by in and name ) allows describing multiple, varied PoP elements. |
Clear structure for Access Token | accessToken.oneOf clearly distinguishes between using a formal HTTP Authentication Scheme and placing a token directly in a specific location. |
Consistent Naming (where applicable) | Uses scheme for the HTTP Authentication Scheme concept. Uses in and name consistent with parameter descriptions. |
No duplication with type: http, scheme: dpop |
tokenPresentation is specific to type: oauth2 and describes how tokens obtained via OAuth2 flows are used. type: http with scheme: dpop can still be used for non-OAuth2 scenarios or simpler DPoP descriptions if preferred. |
JSON Schema friendly (with oneOf ) |
While oneOf adds some complexity, it accurately models the "either/or" requirement for accessToken presentation, providing a choice between definition via scheme or via explicit in and name . |
Backward compatible | As a new optional field within type: oauth2 security schemes, existing OpenAPI documents that omit tokenPresentation remain valid. |
Open questions for the SIG
- Given the
oneOf
structure foraccessToken
, are the descriptions for each branch clear enough to guide usage (i.e., when to usescheme
vs.in
/name
)? Or is it enough to have justin
andname
? - Should
cookie
be added as an option totokenPresentation.accessToken.oneOf.properties.in
(the "Specific Location" branch) to describe access tokens passed via cookies? If so, what shouldname
typically be forin: cookie
?
Issue Description
During a recent discussion in #2867, it became apparent that the OpenAPI Specification lacks explicit guidelines on how clients should present access tokens to resource servers, especially considering the OAuth 2.0 authorization framework. This issue was highlighted in the context of OAuth 2.0's defined grant flows and the need for specifying how access tokens, once obtained, are used for resource access.
Relevant Discussion Points
OAuth 2.0 Grant Flows: The specification allows defining OAuth 2.0 flows, like the implicit flow, requiring the
authorizationUrl
. However, it stops short of detailing how the obtained access tokens should be presented to the resource server.Access Token Presentation: The OAuth 2.0 specification mentions the use of the HTTP "Authorization" request header field with an authentication scheme for the access token type. Yet, "typically" does not encompass all possible scenarios, like the requirement for the Demonstration of Proof-of-Possession at the Application Layer (DPoP), which requires additional headers.
OpenAPI Specification Limitation: The current OpenAPI Specification does not support specifying the method of presenting an access token to a resource server. This limitation was acknowledged in a community call discussion.
Proposal for Enhancement
Given the diversity in access token types and presentation methods (e.g., Bearer tokens, DPoP), there is a clear need for the OpenAPI Specification to allow documenting the exact mechanism of access token presentation for a secured endpoint.
Suggested Improvements:
Extend the
securitySchemes
Object: Introduce new fields within thesecuritySchemes
object to specify the required headers or methods for presenting access tokens, including non-standard approaches.Community Engagement: Invite contributions and discussions from the OpenAPI community, through TDC calls, workflows sig, or security sig, to refine and agree upon the proposed enhancements.
Conclusion
Enhancing the OpenAPI Specification to include explicit guidelines on access token presentation mechanisms would greatly aid in the accurate and comprehensive documentation of APIs, fostering better interoperability and understanding of secured API endpoints. I look forward to contributing to this discussion and helping drive the necessary changes.
The text was updated successfully, but these errors were encountered: