MicrosoftIdentityMessageHandler コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
オーバーロード
MicrosoftIdentityMessageHandler(IAuthorizationHeaderProvider, MicrosoftIdentityMessageHandlerOptions, ILogger<MicrosoftIdentityMessageHandler>)
MicrosoftIdentityMessageHandler クラスの新しいインスタンスを初期化します。
public MicrosoftIdentityMessageHandler(Microsoft.Identity.Abstractions.IAuthorizationHeaderProvider headerProvider, Microsoft.Identity.Web.MicrosoftIdentityMessageHandlerOptions? defaultOptions = default, Microsoft.Extensions.Logging.ILogger<Microsoft.Identity.Web.MicrosoftIdentityMessageHandler>? logger = default);
new Microsoft.Identity.Web.MicrosoftIdentityMessageHandler : Microsoft.Identity.Abstractions.IAuthorizationHeaderProvider * Microsoft.Identity.Web.MicrosoftIdentityMessageHandlerOptions * Microsoft.Extensions.Logging.ILogger<Microsoft.Identity.Web.MicrosoftIdentityMessageHandler> -> Microsoft.Identity.Web.MicrosoftIdentityMessageHandler
Public Sub New (headerProvider As IAuthorizationHeaderProvider, Optional defaultOptions As MicrosoftIdentityMessageHandlerOptions = Nothing, Optional logger As ILogger(Of MicrosoftIdentityMessageHandler) = Nothing)
パラメーター
- headerProvider
- IAuthorizationHeaderProvider
IAuthorizationHeaderProvider送信要求の承認ヘッダーを取得するために使用されます。 これは通常、依存関係挿入コンテナーから取得されます。
- defaultOptions
- MicrosoftIdentityMessageHandlerOptions
WithAuthenticationOptions(HttpRequestMessage, MicrosoftIdentityMessageHandlerOptions)を使用して要求ごとにオーバーライドされない限り、すべての要求に使用される既定の認証オプション。
null場合、各要求で独自の認証オプションを指定する必要があります。そうしないと、例外がスローされます。
認証操作をデバッグおよび監視するためのオプションのロガー。 指定した場合、ハンドラーはトークンの取得、チャレンジ、エラーに関する情報をログに記録します。
例外
headerProviderがnullされるとスローされます。
例
既定のオプションを使用した基本的な使用方法:
var handler = new MicrosoftIdentityMessageHandler(
headerProvider,
new MicrosoftIdentityMessageHandlerOptions
{
Scopes = { "https://api.example.com/.default" }
});
既定のオプションを使用しない使用法 (要求ごとの構成が必要):
var handler = new MicrosoftIdentityMessageHandler(headerProvider);
// Each request must specify options
var request = new HttpRequestMessage(HttpMethod.Get, "/api/data")
.WithAuthenticationOptions(options =>
options.Scopes.Add("custom.scope"));
ログ記録での使用法:
var logger = serviceProvider.GetService<ILogger<MicrosoftIdentityMessageHandler>>();
var handler = new MicrosoftIdentityMessageHandler(headerProvider, defaultOptions, logger);
注釈
defaultOptions パラメーターは、このハンドラー インスタンスを介して行われたすべての要求に適用される認証オプションを設定する便利な方法を提供します。 個々の要求でも、拡張メソッドを使用してこれらの既定値をオーバーライドできます。
loggerが指定されると、ハンドラーはさまざまなレベルでログを記録します。
- デバッグ: 承認ヘッダーの追加に成功しました
- 情報: WWW-Authenticate チャレンジの検出と処理
- 警告: チャレンジ処理の失敗
- エラー: トークン取得エラー
適用対象
MicrosoftIdentityMessageHandler(IAuthorizationHeaderProvider, MicrosoftIdentityMessageHandlerOptions, IMsalMtlsHttpClientFactory, ILogger<MicrosoftIdentityMessageHandler>)
mTLS PoP トークン バインドのサポートを使用して、 MicrosoftIdentityMessageHandler クラスの新しいインスタンスを初期化します。
public MicrosoftIdentityMessageHandler(Microsoft.Identity.Abstractions.IAuthorizationHeaderProvider headerProvider, Microsoft.Identity.Web.MicrosoftIdentityMessageHandlerOptions? defaultOptions, Microsoft.Identity.Client.IMsalMtlsHttpClientFactory? mtlsHttpClientFactory, Microsoft.Extensions.Logging.ILogger<Microsoft.Identity.Web.MicrosoftIdentityMessageHandler>? logger = default);
new Microsoft.Identity.Web.MicrosoftIdentityMessageHandler : Microsoft.Identity.Abstractions.IAuthorizationHeaderProvider * Microsoft.Identity.Web.MicrosoftIdentityMessageHandlerOptions * Microsoft.Identity.Client.IMsalMtlsHttpClientFactory * Microsoft.Extensions.Logging.ILogger<Microsoft.Identity.Web.MicrosoftIdentityMessageHandler> -> Microsoft.Identity.Web.MicrosoftIdentityMessageHandler
Public Sub New (headerProvider As IAuthorizationHeaderProvider, defaultOptions As MicrosoftIdentityMessageHandlerOptions, mtlsHttpClientFactory As IMsalMtlsHttpClientFactory, Optional logger As ILogger(Of MicrosoftIdentityMessageHandler) = Nothing)
パラメーター
- headerProvider
- IAuthorizationHeaderProvider
IAuthorizationHeaderProvider送信要求の承認ヘッダーを取得するために使用されます。 これは通常、依存関係挿入コンテナーから取得されます。
- defaultOptions
- MicrosoftIdentityMessageHandlerOptions
要求ごとにオーバーライドされない限り、すべての要求に使用される既定の認証オプション。
null場合、各要求で独自の認証オプションを指定する必要があります。そうしないと、例外がスローされます。
- mtlsHttpClientFactory
- IMsalMtlsHttpClientFactory
トークン バインディング (mTLS PoP) シナリオ用に mTLS クライアント証明書で構成された HTTP クライアントを作成するためのオプションのファクトリ。 指定され、 ProtocolScheme が "MTLS_POP" に設定されている場合、ハンドラーはこのファクトリを使用して、バインド証明書を使用して HTTP クライアントを作成し、それを介して要求を送信します。
認証操作をデバッグおよび監視するためのオプションのロガー。
例外
headerProviderがnullされるとスローされます。
注釈
RFC 8705 で説明されているように、mTLS PoP (相互 TLS 所有証明) トークン バインドは、アクセス トークンを特定の X.509 証明書に暗号でバインドします。 有効にすると、ハンドラーは、 cnf 要求で証明書の拇印を持つバインドされたトークンを取得し、バインド証明書を使用して mTLS HTTP クライアントを作成し、mTLS チャネルを介して要求を送信します。
トークン バインディングでは現在、アプリケーション (アプリ専用) トークンのみがサポートされています。
RequestAppToken を true に設定します。
MicrosoftIdentityHttpClientBuilderExtensions拡張メソッドを使用して、直接インスタンス化するのではなく、依存関係の挿入を使用してこのハンドラーを構成することを好みます。
適用対象
MicrosoftIdentityMessageHandler(IAuthorizationHeaderProvider, MicrosoftIdentityMessageHandlerOptions, IMsalMtlsHttpClientFactory, ICredentialsProvider, ILogger<MicrosoftIdentityMessageHandler>)
mTLS と mTLS_Pop サポートを使用して、 MicrosoftIdentityMessageHandler クラスの新しいインスタンスを初期化します。
public MicrosoftIdentityMessageHandler(Microsoft.Identity.Abstractions.IAuthorizationHeaderProvider headerProvider, Microsoft.Identity.Web.MicrosoftIdentityMessageHandlerOptions? defaultOptions, Microsoft.Identity.Client.IMsalMtlsHttpClientFactory? mtlsHttpClientFactory, Microsoft.Identity.Web.ICredentialsProvider? credentialsProvider, Microsoft.Extensions.Logging.ILogger<Microsoft.Identity.Web.MicrosoftIdentityMessageHandler>? logger = default);
new Microsoft.Identity.Web.MicrosoftIdentityMessageHandler : Microsoft.Identity.Abstractions.IAuthorizationHeaderProvider * Microsoft.Identity.Web.MicrosoftIdentityMessageHandlerOptions * Microsoft.Identity.Client.IMsalMtlsHttpClientFactory * Microsoft.Identity.Web.ICredentialsProvider * Microsoft.Extensions.Logging.ILogger<Microsoft.Identity.Web.MicrosoftIdentityMessageHandler> -> Microsoft.Identity.Web.MicrosoftIdentityMessageHandler
Public Sub New (headerProvider As IAuthorizationHeaderProvider, defaultOptions As MicrosoftIdentityMessageHandlerOptions, mtlsHttpClientFactory As IMsalMtlsHttpClientFactory, credentialsProvider As ICredentialsProvider, Optional logger As ILogger(Of MicrosoftIdentityMessageHandler) = Nothing)
パラメーター
- headerProvider
- IAuthorizationHeaderProvider
IAuthorizationHeaderProvider送信要求の承認ヘッダーを取得するために使用されます。 これは通常、依存関係挿入コンテナーから取得されます。
- defaultOptions
- MicrosoftIdentityMessageHandlerOptions
要求ごとにオーバーライドされない限り、すべての要求に使用される既定の認証オプション。
null場合、各要求で独自の認証オプションを指定する必要があります。そうしないと、例外がスローされます。
- mtlsHttpClientFactory
- IMsalMtlsHttpClientFactory
トークン バインディング (mTLS PoP) シナリオ用に mTLS クライアント証明書で構成された HTTP クライアントを作成するためのオプションのファクトリ。 指定され、 ProtocolScheme が "MTLS_POP" に設定されている場合、ハンドラーはこのファクトリを使用して、バインド証明書を使用して HTTP クライアントを作成し、それを介して要求を送信します。
- credentialsProvider
- ICredentialsProvider
証明書の省略可能なプロバイダー。 これは、mTLS のみの認証目的で必要です。
認証操作をデバッグおよび監視するためのオプションのロガー。
例外
headerProviderがnullされるとスローされます。
注釈
RFC 8705 で説明されているように、mTLS PoP (相互 TLS 所有証明) トークン バインドは、アクセス トークンを特定の X.509 証明書に暗号でバインドします。 有効にすると、ハンドラーは、 cnf 要求で証明書の拇印を持つバインドされたトークンを取得し、バインド証明書を使用して mTLS HTTP クライアントを作成し、mTLS チャネルを介して要求を送信します。
トークン バインディングでは現在、アプリケーション (アプリ専用) トークンのみがサポートされています。
RequestAppToken を true に設定します。
MicrosoftIdentityHttpClientBuilderExtensions拡張メソッドを使用して、直接インスタンス化するのではなく、依存関係の挿入を使用してこのハンドラーを構成することを好みます。