안녕하세요.
오랜만에 Asp.net Core를 이용해서 코딩을 해 보고 있습니다.
아직 유저가 많지 않은 몇개의 Site를 한개의 linux 서버에서 운영 할려구 합니다.
아직 Asp.net core가 낮설어서 인터넷을 뒤지다 보니 ClaimsIdentity 를 이용한 인증이 나오길래
이 방식을 사용해서 코딩을 했습니다.
< 로그인 >
ClaimsIdentity identity = null;
HttpContext.Session.SetString("username", userLogin.UserId);
identity = new ClaimsIdentity(new[] {
new Claim(ClaimTypes.Name, userLogin.UserId),
new Claim(ClaimTypes.Role, "User")
}, CookieAuthenticationDefaults.AuthenticationScheme);
var principal = new ClaimsPrincipal(identity);
var login = HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal);
return RedirectToAction("Index", "Home");
<로그아웃>
HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return RedirectToAction(“Login”);
문제는 로그인시 ( ClaimsIdentity identity = null; ) 이 부분을 지날때 와 로그아웃을 할때 로그인된 모든 사이트가 로그아웃이 되더군요. 이걸 개별 사이트가 영향을 안 받게 하나의 사이트에서만 로그인/로그아웃이 되게 하려면 어떻게 해야 될까요?