1

IDP アプリとして IdentityServer3.AccessTokenValidation および Identity Server 4 で MVC クライアントを使用しています。

以下の場所に Cookie タイムアウトを追加しましたが、セッションが期限切れにならず、ユーザーを自動的にログアウトしないようです -

MVC クライアントで -

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = "Cookies",
    ExpireTimeSpan = new TimeSpan(0, 20, 0, 0)
});

20 時間未満の時間を設定すると、認可リクエストが無限ループで実行されます

IDP アプリでは、

services.AddIdentityServer(
    opt => new IdentityServer4.Configuration.IdentityServerOptions
    {
        Authentication = new IdentityServer4.Configuration.AuthenticationOptions()
        {
            CookieLifetime = TimeSpan.FromSeconds(60)
        }
    }

IDP アプリでは、

.AddCookie("Cookies", opt => {
    opt.ExpireTimeSpan = TimeSpan.FromSeconds(60);
    opt.Cookie = new CookieBuilder() { Expiration = new TimeSpan(0,0,0,60) };
    opt.Events.OnSigningIn = (context) =>
    {
        context.CookieOptions.Expires = DateTimeOffset.UtcNow.AddSeconds(60);
        return Task.CompletedTask;
    };
}) 
4

1 に答える 1