Add resource_owner field to AuthorizationCode and AccessToken classes #1517
+7
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a
resource_ownerfield to bothAuthorizationCodeandAccessTokenclasses, bonding the identity of the resource owner to the issued access tokens through the authorization flow.Motivation and Context
This PR solves #1038 (request to add a
subjecttoAccessToken)OAuth 2.1 §7.4 (https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-14) notes that resource servers may make access control decisions based on the identity of the resource owner (for user-delegated flows) or the client (for client credentials flows). In other words, tool calls and resource fetches often need to depend on who the token is on behalf of, not just its scopes.
Therefore, it is likely that the behavior of calling a tool / fetching a resource needs to depend on the identity of the resource owner.
There was an initial attempt to solve this (#1165), but it has been closed for inactivity. That thread mentioned there was no JWT payload to build from; this change avoids that dependency entirely. The feature is token-format agnostic: it does not require JWTs and works equally with opaque tokens.
What Has Been Changed?
AuthorizationCodeclass: addresource_owner.AccessTokenclass : addresource_owner.Token Issuance & Introspection Path (in the
simple-authexample):How Has This Been Tested?
Tested with the
simple-authexample to issue codes, tokens and introspect withresource_owner.Breaking Changes
No breaking changes.
Types of changes
Checklist
Additional context
Naming alternatives
Issue #1038 asked for
subject. In JWT ecosystems, subject (sub) is commonly the canonical identifier. This PR uses resource_owner to mirror OAuth terminology in user-delegated flows. If maintainers prefersubject, this can be trivially renamed.