0
私のWebアプリケーションはMVC5です。私は、ログイン時にユーザーを認証するためにIdentityServer4アプリケーションのURLを呼んでいる。 ここでログインした後、私のアプリケーションでスタートアップクラスのメソッドConfigureAuthOwinを使用している場合、クッキーの有効期限は 'Session'です
public void ConfigureAuth(IAppBuilder app)
{
JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();
var authority = LayeredConfiguration.GetValue("HydraInsuranceWeb-UserManagement-Authority");
var redirectUri = LayeredConfiguration.GetValue("HydraInsuranceWeb-UserManagement-RedirectUri");
app.UseCookieAuthentication(new CookieAuthenticationOptions {
AuthenticationType = "Cookies",
SlidingExpiration = false,
ExpireTimeSpan = System.TimeSpan.FromMinutes(2),
CookieName = "MyTestCookie"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Authority = authority,
ClientId = AuthConstants.InsuranceWebClientId,
Scope = "openid profile user.management hydra.eventhistory.api",
RedirectUri = redirectUri,
ResponseType = "code id_token",
SignInAsAuthenticationType = "Cookies",
UseTokenLifetime = false,
Notifications = new OpenIdConnectAuthenticationNotifications
{
SecurityTokenValidated = n =>
{
try
{
var transformedHydraIdentity = new HydraIdentityBuilder(n.AuthenticationTicket.Identity)
.AllowSecurityAdmin()
.IncludeRoleProfiles()
.IncludeIdToken(n.ProtocolMessage.IdToken)
.IncludeStandardClaims()
.Build();
n.AuthenticationTicket = new Microsoft.Owin.Security.AuthenticationTicket(
transformedHydraIdentity,
n.AuthenticationTicket.Properties);
}
catch (Exception ex)
{
n.HandleResponse();
n.Response.Redirect("/Error/NoAuthorization");
DiagnosticService.Writer.AddError("Authentication Error", ex);
}
return Task.FromResult(0);
},
}
});
}
で、クッキーの有効期限は、常に「セッション」である、ではありません現在の時間+ 2分。
しかし、私の期待は特定の日時であり、現在の時間プラス2分である必要があります。ユーザーが2分以内に操作しない場合は、ログインページにジャンプします。
誰もこの問題を知っていますか? Cookieの有効期限が変更された理由を調査またはデバッグする方法を教えてください。
2つのクッキー:.AspNet.Cookies
とMyTestCookie
があります。ユーザーを認証するために使用されるCookieはどれですか?署名するとき
あなたが明示的にMyTestCookie' 'に認証クッキーの名前を設定し、それがあなたの認証クッキーですので。 –