有人可以解释如何使用新的实现滑动过期吗欧文WS-联合会 plugin?
在客户端,在 WS-Federation配置我看到有一些events like :
Notifications = new WsFederationAuthenticationNotifications
{
SecurityTokenReceived = ...,
AuthenticationFailed = ...,
RedirectToIdentityProvider = ...,
MessageReceived = ...,
SecurityTokenValidated = ....
},
但因为缺乏文档我真的不知道在哪里以及如何?
此刻我的STS正在发行绝对过期的代币:
protected override Lifetime GetTokenLifetime(Lifetime requestLifetime)
{
// 5 Minutes for token lifetime
var lifetime = new Lifetime(DateTime.UtcNow, DateTime.UtcNow.AddMinutes(5));
return lifetime;
}
非常感谢任何帮助。
TL;DR: set WsFederationAuthenticationOptions.UseTokenLifetime
to false
, 重新启用滑动过期.
在 OWIN/Katana 中,滑动过期概念仅限于cookies中间件 and is 默认启用(您可以通过设置将其关闭CookieAuthenticationOptions.SlidingExpiration
to false
: https://katanaproject.codeplex.com/SourceControl/latest#src/Microsoft.Owin.Security.Cookies/CookieAuthenticationOptions.cs https://katanaproject.codeplex.com/SourceControl/latest#src/Microsoft.Owin.Security.Cookies/CookieAuthenticationOptions.cs).
当你使用app.UseWsFederationAuthentication
(or app.UseOpenIdConnectAuthentication
),它实际上依赖于另一个中间件来持久化ClaimsIdentity
当您完成身份验证流程时。这种“持久性委托”可以通过以下方式配置SignInAsAuthenticationType
or via app.SetDefaultSignInAsAuthenticationType
.
通常,这SignInAsAuthenticationType
property 对应于 cookie 中间件:这样,滑动过期不是在 WS-Federation 中间件级别进行管理,而是由 cookies 中间件进行管理,当满足滑动过期条件时,将自动更新身份验证 cookie。在这种情况下,您的身份提供商颁发的身份验证令牌将不会更新。为此,您需要设置WsFederationAuthenticationOptions.UseTokenLifetime
to false
,因为当您使用默认值时,滑动过期被禁用,并且 cookie 生存期与令牌生存期匹配。
如果您使用 WS-Fed 进行身份验证(即您只想知道您的用户是谁),那么使用滑动过期可能是一个好主意。但是,如果您需要在远程服务器上进行一些 API 调用,您的用户最终可能会在安全令牌过期后很长一段时间内进行身份验证。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)