feat(op): support resource indicators (RFC 8707) at the authorization endpoint - #955
Open
amartya-dev wants to merge 1 commit into
Open
feat(op): support resource indicators (RFC 8707) at the authorization endpoint#955amartya-dev wants to merge 1 commit into
amartya-dev wants to merge 1 commit into
Conversation
… endpoint The `resource` parameter was silently dropped at the authorization endpoint, so a Storage implementation had no way to learn which resource a token was requested for and could not bind the token audience to it. Add `Resource` to `oidc.AuthRequest` so the parameter is parsed and handed to `Storage.CreateAuthRequest`, validate the values per RFC 8707 section 2 (absolute URI, no fragment) and reject invalid ones with `invalid_target`, copy the values from a Request Object like the other authorization parameters, and let an OP advertise `resource_indicators_supported` in its discovery document through the new `Config.ResourceIndicatorsSupported` option.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Which Problems Are Solved
oidc.AuthRequesthas no field for theresourceparameter of RFC 8707 (Resource Indicators for OAuth 2.0), so the parameter is silently dropped at the authorization endpoint. AStorageimplementation never learns which resource a token was requested for, and therefore cannot bind the audience of the issued token to it.resourceout of the rawhttp.Requestbefore it reachesop.Authorizeand thread it into the audience by hand. That is easy to get subtly wrong — the failure mode is a token with a wildcard or default audience, which defeats the point of asking for a resource in the first place.resourcevalues, and there is no way for an OP to advertise the capability in its discovery document.The motivation is audience binding for MCP servers. MCP revision 2026-07-28 makes every MCP server an OAuth 2.1 resource server: the server MUST validate that a token's audience is itself, and the client MUST send the RFC 8707
resourceparameter. Resource indicators are the mechanism that audience binding depends on.How the Problems Are Solved
oidc.AuthRequestgainsResource []stringwith theresourceschema tag, so repeatedresourceparameters are decoded at/authorizeand reachStorage.CreateAuthRequeston the*oidc.AuthRequestthat is already passed to it. An implementation can read the requested resources there and use them to determine the audience returned byAuthRequest.GetAudience(). No interface change is required, so this is fully backwards compatible — implementations that ignore the field keep their current behaviour.op.ValidateAuthReqResourcesvalidates the values per RFC 8707, section 2: each value must be an absolute URI and must not include a fragment component. A query component is explicitly allowed, as the RFC permits. Invalid values are rejected with theinvalid_targeterror code the RFC specifies (oidc.InvalidTargetalready exists in the package for token exchange). The function is called fromValidateAuthRequestClientafter the redirect URI has been validated, so the error can safely be returned to the client.Storageimplementation — that policy cannot live in the library.CopyRequestObjectToAuthRequestcopiesResourcefrom a Request Object, consistent with how every other authorization parameter is handled there.oidc.DiscoveryConfigurationgainsResourceIndicatorsSupported(resource_indicators_supported,omitempty), driven by a newop.Config.ResourceIndicatorsSupportedfield via theop.ResourceIndicatorsSupported(Configuration)helper. This follows the existingop.Scopes(Configuration)/Config.SupportedScopespattern, so it is an additive field on theConfigstruct rather than a new method on theConfigurationinterface. It defaults tofalseand is omitted from the discovery document, so nothing changes for existing providers until they opt in.Tests are added in the existing table-driven style:
TestValidateAuthReqResources,TestCopyRequestObjectToAuthRequest,Test_ResourceIndicatorsSupported, plus new cases inTestParseAuthorizeRequest,TestValidateAuthRequestandTestDiscover.Additional Changes
resourcevalue is now rejected withinvalid_targetwhere it was previously ignored. This is what the RFC requires, but it is a change in behaviour for a provider whose clients currently send malformed values. If you would rather have this gated behindConfig.ResourceIndicatorsSupportedas well, I am happy to change it.resource_indicators_supportedis not an IANA-registered authorization server metadata parameter — RFC 8707 does not define one. It is the name used by convention to advertise the capability, and this is noted in the field's doc comment. Happy to drop it if you would prefer not to emit an unregistered parameter.Deliberately Out of Scope
Kept out to keep this reviewable; happy to follow up on any of them:
resourceparameter at the token endpoint (RFC 8707, section 2.2) for down-scoping the audience on code exchange and refresh. This PR covers the authorization endpoint only.rp.WithResourceURLParamoption on the relying party side.rp.WithURLParamalready covers the single-resource case; a repeated-parameter option needs a small change towithURLParam.Additional Context
I am aware of #785 and that feature reviews are constrained at the moment — no rush at all on this one. It is written to be small and additive so it is cheap to review whenever there is time.