Blazor 身份验证适用于 Azure,但适用于 VPS 中的 IIS

时间:2021-06-06 11:04:40

标签: identityserver4 blazor-webassembly

我正在使用 Blazor webassembly 开发网站(我喜欢它)。但是,我有一个问题:当我在 azure 上部署我的网站时,身份验证和授权似乎无缝地工作,当我将它部署到我自己的 VPS 时,不知何故声称似乎无法通过,或者 JWT 令牌,我不能告诉。

有没有人有类似的经历(如果有,他们是否找到了解决方案)?

非常感谢。

1 个答案:

答案 0 :(得分:0)

我确实找到了解决方案,这确实与时差有关。 我把它放在我的 Startup 的 ConfigureServices 方法中

services.AddIdentityServer()
          .AddApiAuthorization<ApplicationUser, ApplicationDbContext>(options =>
            {
                options.IdentityResources["openid"].UserClaims.Add("role");
                options.ApiResources.Single().UserClaims.Add("role");
                options.Clients.First().AccessTokenLifetime = 86400;
                options.Clients.First().IdentityTokenLifetime = 86400;

            });