0
データベースから照会された特定のデータに基づいて最初のログイン後にアイデンティティに新しいクレームを追加しようとしています。私が追加している新たな主張は、後続の要求に対して永続的ではない。ASP.NETコアID - 初期ログイン後に新しいクレームを追加する方法
これは私がASP.NET MVCでの請求を追加/設定してい
public static void UpdateClaim(IPrincipal principal, string key, string value)
{
var identity = principal.Identity as ClaimsIdentity;
if (identity == null)
return;
// check for existing claim and remove it
var existingClaim = identity.FindFirst(key);
if (existingClaim != null)
identity.RemoveClaim(existingClaim);
// add new claim
identity.AddClaim(new Claim(key, value));
var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
authenticationManager.AuthenticationResponseGrant = new AuthenticationResponseGrant(new ClaimsPrincipal(identity), new AuthenticationProperties() { IsPersistent = true });
}
が新しく追加された主張を永続化するASP.NETコア2.0で同様の方法がある方法です。これについて何か考えてみてください。