SlidingExpiration using authentication mode="None"?

SlidingExpiration using authentication mode="None"?

我正在使用 ASP.NET MVC 应用程序会话,尝试使用“UseCookieAuthentication”和“UseWsFederationAuthentication”通过 OWIN 实现 ADFS 身份验证。

只有当我在 web.config

中设置 身份验证模式="None" 时,ADFS 身份验证才有效

问题是,当我设置身份验证模式=“None”时,例如会话超时= 2 分钟,会话在 2 分钟后结束登录。滑动过期不起作用,用户甚至在使用网站时也会被注销。

当我设置身份验证模式=“Forms”时,会话表现完美,只有在上次请求后 2 分钟后用户才会注销,但 ADFS 身份验证停止工作.

有人知道这个问题吗?

ADFS 服务来自外部合作伙伴,我不知道配置。

这是我的代码:

<sessionState timeout="2" cookieName="MB_SEID"></sessionState>

<authentication mode="None">
<forms loginUrl="~/Home/Index" defaultUrl="/" path="/" name="UID" timeout="2" protection="All" slidingExpiration="true" enableCrossAppRedirects="true" />
</authentication>

public void ConfigureAuth(IAppBuilder app)
{
    app.SetDefaultSignInAsAuthenticationType(DefaultAuthenticationTypes.ApplicationCookie);
    app.UseCookieAuthentication(new CookieAuthenticationOptions {
        CookieManager = new SystemWebCookieManager(),
        SlidingExpiration = true,
        ExpireTimeSpan = TimeSpan.FromMinutes((double)sessionTimeout),
        AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
        CookieName = CookieAuthenticationDefaults.CookiePrefix + DefaultAuthenticationTypes.ApplicationCookie,
        Provider = new CookieAuthenticationProvider
        {
            OnResponseSignIn = ctx =>
            {
                ctx.Options.ExpireTimeSpan = TimeSpan.FromMinutes((double)sessionTimeout);
                ctx.Options.SlidingExpiration = true;
            }
        }
    });

    app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
    {
        Wtrealm = realm,
        MetadataAddress = adfsMetadata,
        Wreply = replay,
        AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Passive,
        SignInAsAuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
        UseTokenLifetime = false // set to false to manage session with the cookie middleware
    });
}

我的配置没问题。问题是我不知道的内部会话管理。 谢谢大家的帮助。