feat: add MetadataAddress support to ClientCredentialsClient for OIDC discovery - #358
Open
paulomorgado wants to merge 1 commit into
Open
feat: add MetadataAddress support to ClientCredentialsClient for OIDC discovery#358paulomorgado wants to merge 1 commit into
paulomorgado wants to merge 1 commit into
Conversation
Added MetadataAddress to ClientCredentialsClient for OIDC discovery. Validation now requires TokenEndpoint or MetadataAddress. ClientCredentialsTokenClient resolves token endpoint from metadata if needed, with improved error handling. Tests updated for new scenarios and API changes.
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.
Summary
This change adds
MetadataAddresssupport to client-credentials token acquisition so callers can rely on discovery metadata instead of always hardcodingTokenEndpoint.It aligns
ClientCredentialsClientwith established ASP.NET authentication configuration patterns while preserving full backward compatibility for existingTokenEndpoint-based setups.Motivation
Today,
ClientCredentialsClientrequiresTokenEndpointup front. That makes configuration less flexible in environments where endpoint details are discovered dynamically from OpenID Connect metadata.This PR enables that dynamic discovery flow by allowing
MetadataAddressas an alternative configuration source.What changed
Public API
Uri? MetadataAddresstoClientCredentialsClient.Validation rules
ClientId, andTokenEndpointorMetadataAddress.Runtime token endpoint resolution
ClientCredentialsTokenClient, ifTokenEndpointis missing andMetadataAddressis provided, the token endpoint is resolved via discovery (GetDiscoveryDocumentAsync).InvalidOperationExceptionis raised.TokenEndpointtakes precedence.Parallel with ASP.NET Core
MetadataAddresssemanticsThis implementation intentionally mirrors the concept used by:
OpenIdConnectOptions.MetadataAddressJwtBearerOptions.MetadataAddressIn both APIs,
MetadataAddressis the discovery endpoint for obtaining metadata.This PR brings the same model to client token management:
Behavioral notes
TokenEndpointcontinue to work unchanged.TokenEndpointis used directly (no discovery round-trip).Test coverage added/updated
TokenEndpointandMetadataAddressthrows.TokenEndpoint+ validMetadataAddressdiscovers and requests token successfully.TokenEndpointprecedence overMetadataAddress.token_endpointthrows expected exception.