asp.net - SessionSecurityToken lifeTime 与 sessionTokenRequirement 生存期相同吗?

标签 asp.net asp.net-identity claims-based-identity

我正在将 Web 表单中的表单例份验证迁移到 Microsoft Identity。

使用 ClaimsPrincipal cp 对象创建 SessionSecurityToken 时,我有以下代码:

Dim token As New SessionSecurityToken(cp, TimeSpan.FromMinutes(30))

但是,在 web.config 中我也看到了这一点:

<configSections>
    <section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</configSections>
<system.identityModel>
    <identityConfiguration>
        <securityTokenHandlers>
            <add type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089">
                <sessionTokenRequirement lifetime="00:30:00" /><!-- 30 minutes -->  
            </add>
        </securityTokenHandlers>
    </identityConfiguration>
</system.identityModel>

这些是同一件事吗?为了证明我 RTFM,sessionTokenRequirement 生命周期 is defined as :

Specifies the lifetime of session tokens.

SessionSecurityToken 生命周期 is defined as :

The period from the current time during which the token is valid. The ValidFrom property will be set to UtcNow and the ValidTo property will be set to ValidFrom plus the period specified by this parameter.

前者似乎很模糊,所以我不确定。

最佳答案

在应用程序联合或基于声明的身份验证中,有两个实体 - 依赖方 (RP) 和身份提供商 (IdP)

在 Microsoft 世界中,ADFS 通常是 IdP,而依赖 ADFS 进行身份验证的应用程序将是 RP。

身份验证时,IdP 生成由 IdP 证书签名的声明 token 。 RP 接受此声明 token - 执行各种验证,包括使用 IdP 证书进行数字签名的验证。成功验证声明 token 后,RP 会以 cookie 的形式发出 session token 。此 cookie 的默认名称是 FedAuth。 SessionTokenRequirement 生命周期参数与 FedAuth token 的生命周期相关联。

SessionSucurityToken 生命周期与 IdP 颁发的声明 token 的生命周期相关联。

请引用: http://brockallen.com/2013/02/14/configuring-session-token-lifetime-in-wif-with-the-session-authentication-module-sam-and-thinktecture-identitymodel/

http://msdn.microsoft.com/en-us/library/hh568645(v=vs.110).aspx

关于asp.net - SessionSecurityToken lifeTime 与 sessionTokenRequirement 生存期相同吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27015996/

相关文章:

c# - 这是处理sql连接的好方法吗?

javascript - 关于使用href的问题

c# - 在运行时发送长进程的当前状态

asp.net - 从旧的 ASP.NET 成员身份切换到 ASP.NET 身份 (Visual Studio 2013)

c# - asp.net core 2.0 - 基于声明和策略的授权

asp.net - 有没有一种可靠的方法可以使标签与其控件顶部对齐?

c# - 在 ASP.Net Core Identity 中刷新用户 cookie 票证

c# - 设置 ClaimTypes.Name 不会导致 identity.name

azure - 如何将属性从 Azure AD 登录映射到 B2C 身份?

asp.net - 如何在asp.net mvc5中创建动态角色