제가 사용 중인 asp net frameworksms 4.8 mvc입니다
블록 인용문
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseKentorOwinCookieSaver();//멋대로 MS 토큰 사라지는 문제 해결 라이브러리
app.UseCookieAuthentication(new CookieAuthenticationOptions/());/
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString(“/Account/Login_New”),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromDays(7),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
},
CookieManager = new SystemWebCookieManager()
}) ;
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = redirectUri,
});
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications()
{
SecurityTokenValidated = (context) =>
{
string name = context.AuthenticationTicket.Identity.FindFirst("preferred_username").Value;
context.AuthenticationTicket.Identity.AddClaim(new Claim(ClaimTypes.Name, name, string.Empty));
return System.Threading.Tasks.Task.FromResult(0);
}
}
});
}
start.cs에서는 이렇게 처리되어 있고
마이크로소프트 로그인 후 돌아올 때 아이덴디티가 쿠키에서 값이 사라져서 user.identity.isAuthenticated가 false가 됩니다. 분명 구글링한데로 Kentorowinsaver를 적용하였음에도 불구하고 쿠키에서 ID 토큰이 사라지는 현상이 발생하는데 해당 현상을 해결할 줄 아시는 선배님들 계신다면 답변 부탁드립니다.