5
ASP.NET Core 2.0のHttpContextからAuthenticationInfo
プロパティを取得するにはどうすればよいですか。私は、ASP.NET Core 2.0のセキュリティの再設計で、AuthenticationManager
は現在廃止されており、.Authentication
を削除する必要があることを理解しています。私は1.1.2ASP.NET Core 2.0でAuthenticationInfoを取得
var info = await httpContext.Authentication.GetAuthenticateInfoAsync("Automatic");
info.Properties.StoreTokens(new List<AuthenticationToken>
{
new AuthenticationToken
{
Name = OpenIdConnectParameterNames.AccessToken,
Value = accessToken
},
new AuthenticationToken
{
Name = OpenIdConnectParameterNames.RefreshToken,
Value = refreshToken
}
});
await httpContext.Authentication.SignInAsync("Automatic", info.Principal, info.Properties);
注「自動」はもはや重要な言葉ではありません。 '.AuthenticateAsync(); 'を呼び出してください。 – Tratcher
@Tratcher素敵なキャッチ、ありがとう。私は[スキーム]で自動を置き換える私の答えを編集したと確信していたが、私は私の編集を保存するのを忘れたように見えます。つまり、認証とサインインの両方にデフォルトのスキームを使用するほうが簡単かもしれないので、それに応じて私の回答を更新しました。 – Pinpoint