【问题标题】:IdentityServer and Asp.net MVCIdentityServer 和 Asp.net MVC
【发布时间】:2017-02-04 07:32:12
【问题描述】:

我正在构建一个应用程序,它是一个 Javascript SPA,后端带有 Asp.net mvc 控制器。我正在尝试使用 IdentityServer 进行身份验证。我在我的控制器上有授权属性。我的要求之一是用户的会话应该在一定时间内过期(如果没有活动,应该提示用户登录)。由于安全限制,隐式流程对我不起作用。我抓住了 Identity4 样本https://github.com/IdentityServer/IdentityServer4.Samples 并尝试使用 cookieauthentication 中间件,设置 ExpireTimeSpan 以查看是否使 cookie 过期。不知何故,即使在指定的时间跨度到期后,我仍然可以调用控制器。如何使用 Identity Server 和 Asp.net mvc 完成类似于 asp.net 会话超时的操作?

【问题讨论】:

    标签: asp.net-core identityserver4


    【解决方案1】:

    已知问题参见https://github.com/aspnet/Security/pull/893,已针对 1.1.0 修复。

    等待1.1.0版本或使用OnTokenValidated设置过期属性:

    OnTokenValidated = async (context) =>
    {
         context.Properties.ExpiresUtc = <expire>;
         await Task.FromResult(0);
    }
    

    另请参阅:https://github.com/aspnet/Security/issues/855#issuecomment-229495399

    【讨论】:

      猜你喜欢
      • 2021-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-13
      • 1970-01-01
      • 2017-02-02
      • 2020-07-07
      相关资源
      最近更新 更多