我在方法中有以下代码ConfigureServices
:
var federationSettings = new FederationSettings();
this.Configuration.GetSection(nameof(FederationSettings)).Bind(federationSettings);
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
CryptoProviderFactory.Default.CustomCryptoProvider = new Sha1Provider();
services.AddAuthentication(sharedOptions =>
{
sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme;
sharedOptions.DefaultSignOutScheme = WsFederationDefaults.AuthenticationScheme;
})
.AddWsFederation(options =>
{
options.UseTokenLifetime = false;
options.SecurityTokenHandlers.Clear();
options.SecurityTokenHandlers.Add(new CustomSamlSecurityTokenHandler());
options.SecurityTokenHandlers.Add(new Saml2SecurityTokenHandler());
options.SecurityTokenHandlers.Add(new JwtSecurityTokenHandler());
options.RequireHttpsMetadata = false;
options.Wtrealm = federationSettings.Realm;
options.MetadataAddress = federationSettings.AdfsMetadataUrl;
})
.AddCookie(options =>
{
options.Cookie.Name = "AuthenticationCookie";
options.ExpireTimeSpan = TimeSpan.FromDays(10);
options.SlidingExpiration = true;
});
如果我设置ExpireTimeSpan
为 10 秒,则身份验证票证将在 10 秒后过期,但如果我将其设置为超过 30 分钟,它将不起作用。我怎样才能增加ExpireTimeSpan
?