You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.3 KiB
34 lines
1.3 KiB
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
|
|
namespace Microsoft.eShopWeb.Web.Configuration
|
|
{
|
|
public static class ConfigureCookieSettings
|
|
{
|
|
public static IServiceCollection AddCookieSettings(this IServiceCollection services)
|
|
{
|
|
services.Configure<CookiePolicyOptions>(options =>
|
|
{
|
|
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
|
|
//TODO need to check that.
|
|
//options.CheckConsentNeeded = context => true;
|
|
options.MinimumSameSitePolicy = SameSiteMode.Strict;
|
|
});
|
|
services.ConfigureApplicationCookie(options =>
|
|
{
|
|
options.Cookie.HttpOnly = true;
|
|
options.ExpireTimeSpan = TimeSpan.FromHours(1);
|
|
options.LoginPath = "/Account/Login";
|
|
options.LogoutPath = "/Account/Logout";
|
|
options.Cookie = new CookieBuilder
|
|
{
|
|
IsEssential = true // required for auth to work without explicit user consent; adjust to suit your privacy policy
|
|
};
|
|
});
|
|
|
|
return services;
|
|
}
|
|
}
|
|
}
|
|
|