繁体   English   中英

如何防止在子域上共享 Cookie

[英]How can I prevent sharing Cookies on subdomains

从 2 天开始,我试图阻止子域之间的 cookie 共享。 当我登录 1 个特定的子(域)时,包括一级域,它也会将 cookie 直接设置为其他子(域)。

我想分离这些子(域)的登录过程。

我的 ConfigureServices 方法的 cookie 设置如下:

services.AddAuthentication(options =>
{
    options.DefaultSignInScheme = JwtBearerDefaults.AuthenticationScheme;
    options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
{
    options.LoginPath = "/token";
    options.Cookie.IsEssential = true;
    options.SlidingExpiration = true;
    options.ExpireTimeSpan = TimeSpan.FromDays(1);
    options.Cookie.HttpOnly = true; 
    options.Cookie.Name = "AuthCookie";
    options.Cookie.SameSite = SameSiteMode.Strict;
    options.Cookie.SecurePolicy = CookieSecurePolicy.None;
})

我尝试了几个选项,如options.Cookie.Domain = "mydomain.com"options.Cookie.Domain = ""没有前导. ,但我仍然没有成功。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM