0
데이터베이스에서 쿼리 된 특정 데이터를 기반으로 초기 로그인 후에 Identity에 새 클레임을 추가하려고합니다. 내가 추가하고있는 새로운 주장은 후속 요청을 위해 지속되지 않습니다.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 비슷한 방법이되는 방법이다. 이에 대한 아이디어를 감사하십시오.