c# - 为什么 ASP.NET Core Identity Cookie 不能跨域工作?
问题描述
我在我的 ASP.NET Core Identity 中设置了一些 cookie 选项,包括几个子域:
services.ConfigureApplicationCookie(identityOptionsCookies =>
{
identityOptionsCookies.Cookie.Domain = ".example.com";
identityOptionsCookies.Cookie.Name = "ExampleToken";
});
基于此配置,我通过此子域登录:
api.accounts.example.com
我使用此 API 调用检查我是否已通过身份验证:
api.accounts.example.com/identity/isAuthenticated => returns true
现在我转到另一个子域,对 Startup.cs 使用相同的配置,我不再经过身份验证:
api.user.example.com/teacher/list => redirects me to /Accounts/Login
为什么会这样?
解决方案
identityOptionsCookies.Cookie.Domain = "*.example.com";
推荐阅读
- r - 如何计算 r 中每组的平均变化?
- laravel - 如何验证来自 Laravel 中父控制器的相关对象请求数据?
- xml - 如何处理 XPath 和 XSL 中的层次关系和比较?
- weblogic12c - Weblogic 缓慢的服务器启动和发布
- scala - 如何在 Scala 中使用模式匹配与函数值
- html - 如何检索与在Django中单击的链接对应的数据
- reactjs - 如何在 react js 中检查材质 ui 主题的类型?(亮或暗)
- android - 如何使用 Glide/Picasso 等库从 Web 加载 Vector Drawable 资源?
- python - 尝试使用 Kafka 和 pyspark 在 postgreSQL 中从 spark 编写流数据帧
- python - python itertools组合消失