设置Azure AppFabric访问控制服务cookie过期时间

本文关键字:cookie 过期 时间 服务 访问控制 Azure AppFabric 设置 | 更新日期: 2023-09-27 18:19:42

我正在ASP.NET MVC 3应用程序中使用Azure的访问控制服务。我可以成功登录,读取我需要的所有索赔数据等。除了一件事,一切都很好。一段时间后(不到一个小时),身份验证cookie似乎过期了(至少它们不再出现在请求的cookie集合中)。

我仍然在使用开发模拟,没有SSL(除了身份验证服务本身)。

我正在使用以下操作过滤器来限制对某些控制器的访问:

public class PersonLoginFilter : ActionFilterAttribute, IActionFilter
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        base.OnActionExecuting(filterContext);
        // Check whether the user is logged in
        if (filterContext.HttpContext.Request.IsAuthenticated)
        {
             // ...
        }
    }
}

如何增加过期时间?或者手动续订我的操作过滤器中的cookie是否合适?

提前感谢!

设置Azure AppFabric访问控制服务cookie过期时间

ACS生成的令牌也有一个到期时间(您可以在管理门户中设置,最长约为24小时),但您也可以在web.config 中设置一个值

<securityTokenHandlers> 
<add type="Microsoft.IdentityModel.Tokens.SessionSecurityTokenHandler..."> 
<sessionTokenRequirement lifetime="0:02" /> 
</add> 
</securityTokenHandlers>

ASP.NET取两者中最小的值。

想了解更多信息,我建议发这篇博客:http://blogs.msdn.com/b/vbertocci/archive/2010/06/16/warning-sliding-sessions-are-closer-than-they-appear.aspx

它没有明确回答您的问题,但在讨论滑动会话安全令牌时,它涵盖了有关过期的概念。