[英]Share Cookie between application and sub application in ASP.NET Core
我正在尋找一種在ASP.NET Core中的根應用程序和子應用程序(配置為應用程序的虛擬目錄)之間共享登錄屏幕的方法。 子應用程序的LoginPath將指向根登錄頁面(然后returnUrl將其指向子應用程序)。 基本上,我需要子應用程序來識別由根應用程序設置的憑據。 我正在使用cookie身份驗證。
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationScheme = "Cookie",
LoginPath = new PathString("./signin/"),
AccessDeniedPath = new PathString("/unauthorized/"),
AutomaticAuthenticate = true,
AutomaticChallenge = true
});
這是我發出證明的代碼。
var issuer = SettingBusiness.GetSettingValueAsString("MembersSiteUrl");
var claims = new List<Claim> {new Claim(ClaimTypes.Name, user.UserId.ToString(), ClaimValueTypes.Integer32, issuer)};
var userIdentity = new ClaimsIdentity("MembersUser");
userIdentity.AddClaims(claims);
var userPrincipal = new ClaimsPrincipal(userIdentity);
var authenticationProperties = new AuthenticationProperties
{`enter code here`
ExpiresUtc = DateTime.UtcNow.AddMinutes(60),
IsPersistent = false,
AllowRefresh = true
};
await HttpContext.Authentication.SignInAsync("Cookie", userPrincipal, authenticationProperties);
很難找到有關此特定方案的信息。 任何幫助將不勝感激。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.