【发布时间】:2019-10-31 14:24:49
【问题描述】:
我有一个使用最新的“create-react-app”模板构建的默认 ASP.NET Core 3 应用程序。也就是说,在 startup.cs 中,我有以下代码来实例化我假设使用 OpenID 的 JWT 令牌生成器。我已经创建了 React 模板,但我认为在这种情况下这并不重要。,
services.AddDefaultIdentity<ApplicationUser>()
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddIdentityServer()
.AddApiAuthorization<ApplicationUser, ApplicationDbContext>();
services.AddAuthentication()
.AddIdentityServerJwt();
登录后,我可以看到存储的 cookie 不是我的 JWT 令牌(这是我想要的)。 cookie 确实刮掉了 .AspNetCore.Identity.Application 属性,我认为它与 JWT 令牌有关,但我不知道如何。
我想将 JWT 令牌存储为 cookie 参数,以便在下一个请求时将其发送回服务器。如何将该 JWT 签名令牌作为 cookie 存储在我的 asp.net core 3 应用程序中?
【问题讨论】:
-
假设客户端是浏览器,不可以直接放到
sessionStorage吗? -
我需要在 cookie 中。
标签: asp.net-core asp.net-identity