【问题标题】:What is the correct method of setting the expiry of an access token in the Implicit Flow in IdentityServer4?在 IdentityServer4 的隐式流中设置访问令牌到期的正确方法是什么?
【发布时间】:2018-08-15 21:05:58
【问题描述】:

我尝试将我的隐式客户端的 AccessTokenLifetime 属性设置为 90 秒。客户端是一个javascript应用程序。

但是,在令牌应该过期后大约 5 分钟,客户端仍然能够访问 api 范围“api1”。

这是 IdentityServer4 中客户端配置的代码:

// JavaScript Client
            new Client
            {
                ClientId = "js",
                ClientName = "JavaScript Client",
                AllowedGrantTypes = GrantTypes.Implicit,
                AllowAccessTokensViaBrowser = true,

                RedirectUris = { "http://localhost:5003/callback.html" },
                PostLogoutRedirectUris = { "http://localhost:5003/index.html" },
                AllowedCorsOrigins = { "http://localhost:5003" },

                AllowedScopes =
                {
                    IdentityServerConstants.StandardScopes.OpenId,
                    IdentityServerConstants.StandardScopes.Profile,
                    "api1"
                },
                AccessTokenLifetime = 90
            }

我正在使用来自 IdentityServer github repo 的 Javascript 快速入门解决方案 https://github.com/IdentityServer/IdentityServer4.Samples/tree/release/Quickstarts/7_JavaScriptClient

【问题讨论】:

    标签: identityserver4


    【解决方案1】:

    Microsoft JWT 验证中间件存在时钟偏差。默认设置为 5 分钟,不能更短。否则 - 访问令牌的建议生命周期为 as short as possible。特别是在客户端客户端中,您将其暴露给浏览器。因此,您最好的解决方案 - 将其保留为默认值(300 秒/5 分钟)。

    检查this topic - 有一个很好的讨论。

    【讨论】:

      猜你喜欢
      • 2020-01-07
      • 2020-11-16
      • 2015-06-07
      • 1970-01-01
      • 2021-02-19
      • 2018-10-26
      • 1970-01-01
      • 2021-09-25
      • 1970-01-01
      相关资源
      最近更新 更多