I have the following code in ConfigureServices
method:
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;
});
If I set ExpireTimeSpan
to 10 seconds the authentication ticket expires after 10 seconds, but it doesn't work if I set it to more than 30 minutes. How can I increase ExpireTimeSpan
?