Skip to main content

Definition

Assembly: Microsoft.OData.Mcp.Authentication.dll Namespace: Microsoft.OData.Mcp.Authentication.Outbound Inheritance: System.Object

Syntax

Summary

Runs steps 3 through 5 and 8b of the outbound OAuth discovery algorithm: parse the WWW-Authenticate challenge, fetch RFC 9728 protected resource metadata, select an authorization server from every candidate base the challenge and that metadata imply, and resolve the RFC 8707 resource indicator.

Remarks

Fail first, vendor neutral: Microsoft Graph is a trap this algorithm survives generically, never a special branch. Per AUTH-14 a 401, 403, 404, or failed parse on any well-known document is non-fatal and discovery continues; only a timeout, a repeated 5xx (surfaced by the metadata clients), a 401/403 with no challenge at all, or an exhausted candidate list is fatal. Per AUTH-13 the challenge client_id is logged as the <em>resource</em> application id and never promoted to a client id. Tokens and response bodies are never logged.

Examples

Constructors

.ctor

Initializes a new instance of the OAuthDiscovery class.

Syntax

Parameters

Exceptions

.ctor Inherited

Inherited from object

Syntax

Methods

AuthorizationServerBases

Collects the authorization server base URIs to probe, in order, per step 5 of the discovery algorithm.

Syntax

Parameters

Returns

Type: System.Collections.Generic.IReadOnlyList<System.Uri> Exactly authorizationServerOverride when it is set; otherwise the absolute authorization_servers entries of protectedResource in order, followed by every unique remainder of the challenge authorization_uri after stripping each ODataMcpAuthConstants.AuthorizeSuffixes entry, deduplicated preserving first occurrence. The list is empty when nothing implies a base.

Examples

Remarks

A single authorization_uri can imply more than one base because a suffix later in ODataMcpAuthConstants.AuthorizeSuffixes may also match; both remainders are probed so a server that publishes its metadata under either one is found. Non-absolute authorization_servers entries are skipped silently here; CancellationToken) logs them.

DiscoverAsync

Discovers the authorization server, grants, scope, and resource indicator for an OData service that answered with an authentication challenge.

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task<Microsoft.OData.Mcp.Authentication.Outbound.OAuthDiscoveryResult> The discovery result, always carrying a usable authorization server.

Exceptions

Examples

Remarks

Protected resource metadata candidates are probed in the order OAuthChallenge) returns them and probing stops at the first document, so the Graph trap costs exactly one GET when the challenge named a resource_metadata URL. Authorization server bases are probed the same way. An authorizationServerOverride also suppresses the “401 with no WWW-Authenticate” failure, because the operator has already supplied what that failure asks for.

Equals Inherited Virtual

Inherited from object

Syntax

Parameters

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

Returns

Type: object

PrmCandidates

Builds the RFC 9728 protected resource metadata URLs to probe, in order, per step 4 of the discovery algorithm.

Syntax

Parameters

Returns

Type: System.Collections.Generic.IReadOnlyList<System.Uri> Exactly the challenge resource_metadata URL when the challenge carries an absolute one; otherwise the origin well-known URL followed by the path-prefixed one, with the path-prefixed URL omitted when the service root’s path is /.

Exceptions

Examples

Remarks

A trailing / on the service root’s path is trimmed before the path is appended, so http://localhost/odata/ and http://localhost/odata produce the same candidates.

ReferenceEquals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

ToString Inherited Virtual

Inherited from object

Syntax

Returns

Type: string?