Skip to main content

Definition

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

Syntax

Summary

Parses WWW-Authenticate response header values into OAuthChallenge instances using the RFC 9110 section 11.6.1 challenge grammar and the RFC 6750 / RFC 9728 OAuth auth-params.

Remarks

The grammar implemented is challenge = auth-scheme [ 1*SP ( token68 / #auth-param ) ] with auth-param = token BWS "=" BWS ( token / quoted-string ). A hand written tokenizer is used rather than a regular expression so that a comma inside a quoted-string never splits a challenge, and so that the scheme of a following challenge (a token that is not followed by =) is recognized correctly. A token68 credential is consumed so that it cannot masquerade as an extra challenge, but it is not surfaced: OAuth challenges always use auth-params.

Methods

Parse

Parses a single WWW-Authenticate header value and returns its first challenge.

Syntax

Parameters

Returns

Type: Microsoft.OData.Mcp.Authentication.Outbound.OAuthChallenge The first OAuthChallenge in headerValue.

Exceptions

Examples

Remarks

Use String) when a header value may advertise more than one scheme; this method deliberately keeps only the first challenge.

ParseAll

Parses a sequence of WWW-Authenticate header values, in order, into a flat challenge list.

Syntax

Parameters

Returns

Type: System.Collections.Generic.IReadOnlyList<Microsoft.OData.Mcp.Authentication.Outbound.OAuthChallenge> Every challenge advertised across values, in the order encountered.

Exceptions

Remarks

A response may repeat the header instead of comma joining it, and each value may itself carry more than one challenge. Entries that are null, empty, or white space carry no challenge and are skipped, so a response with no usable challenge yields an empty list rather than an exception; callers apply the “401 with no WWW-Authenticate” rule themselves.

ParseAll

Parses a single WWW-Authenticate header value that may advertise several challenges.

Syntax

Parameters

Returns

Type: System.Collections.Generic.IReadOnlyList<Microsoft.OData.Mcp.Authentication.Outbound.OAuthChallenge> Every challenge in headerValue, in the order encountered.

Exceptions

SelectBearer

Selects the first Bearer challenge from a parsed challenge list.

Syntax

Parameters

Returns

Type: Microsoft.OData.Mcp.Authentication.Outbound.OAuthChallenge? The first challenge whose scheme is Bearer, or null when none is.

Exceptions

Remarks

Authentication schemes are case-insensitive, so bearer and Bearer both match.