简体   繁体   English

为什么 ASP.NET Core Identity Cookie 不能跨域工作?

[英]Why ASP.NET Core Identity Cookie is not working across domains?

I set some cookie options in my ASP.NET Core Identity, to include a couple of subdomains:我在 ASP.NET Core Identity 中设置了一些 cookie 选项,以包含几个子域:

        services.ConfigureApplicationCookie(identityOptionsCookies =>
        {
            identityOptionsCookies.Cookie.Domain = ".example.com";
            identityOptionsCookies.Cookie.Name = "ExampleToken";
        });

Based on this configuration, I login via this subdomain:基于此配置,我通过此子域登录:

api.accounts.example.com

And I check that I am authenticated, using this API call:我使用此 API 调用检查我是否已通过身份验证:

api.accounts.example.com/identity/isAuthenticated => returns true

Now I go to another subdomain, using the same configuration for Startup.cs, and I'm not authenticated anymore:现在我转到另一个子域,对 Startup.cs 使用相同的配置,但我不再进行身份验证:

api.user.example.com/teacher/list => redirects me to /Accounts/Login

Why is it so?为什么会这样?

identityOptionsCookies.Cookie.Domain = "*.example.com";

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

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