// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddHttpContextAccessor(); var connectionString = Configuration.GetConnectionString("LampShade"); ShopManagementBootstrapper.Configuration(services, connectionString); DiscountManagementBootstrapper.Configuration(services, connectionString); InventoryManagementBootstrapper.Configuration(services, connectionString); BlogManagementBootstrapper.Configuration(services, connectionString); CommentManagementBootstrapper.Configuration(services, connectionString); AccountManagementBootstrapper.Configuration(services, connectionString); services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.BasicLatin, UnicodeRanges.Arabic)); services.AddSingleton <IPasswordHasher, PasswordHasher>(); services.AddTransient <IAuthHelper, AuthHelper>(); services.AddTransient <IZarinPalFactory, ZarinPalFactory>(); services.AddTransient <ISmsService, SmsService>(); services.AddTransient <IEmailService, EmailService>(); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, o => { o.LoginPath = "/Account"; o.LogoutPath = "/Account/Logout"; o.AccessDeniedPath = new PathString("/AccessDenied"); o.ExpireTimeSpan = TimeSpan.FromMinutes(43200); }); services.AddRazorPages(). AddApplicationPart(typeof(InventoryController).Assembly); // AddNewtonsoftJson(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var connectionString = Configuration.GetConnectionString("HomeShopDb"); ShopManagementBootstrapper.Configure(services, connectionString); DiscountManagementBootstrapper.Configure(services, connectionString); InventoryManagementBootstrapper.Configure(services, connectionString); services.AddRazorPages(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //services.Configure<CookiePolicyOptions>(options => //{ // options.CheckConsentNeeded = context => true; // options.MinimumSameSitePolicy = SameSiteMode.Lax; //}); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, o => { o.LoginPath = new PathString("/Account"); o.LogoutPath = new PathString("/Account"); o.AccessDeniedPath = new PathString("/AccessDenied"); }); services.AddHttpContextAccessor(); var ConnectionString = Configuration.GetConnectionString("EShopDB"); #region IOC ShopManagementBootstrapper.Configure(services, ConnectionString); DiscountManagemantBootstrapper.Configure(services, ConnectionString); InventoryManagemantBootstrapper.Configure(services, ConnectionString); blogManagementBootstrapper.Configure(services, ConnectionString); AccountManagementBootstrapper.Configure(services, ConnectionString); services.AddTransient <IFileUploader, FileUploade>(); services.AddTransient <IAuthHelper, AuthHelper>(); #endregion services.AddSingleton( HtmlEncoder.Create(UnicodeRanges.BasicLatin, UnicodeRanges.Arabic)); services.AddRazorPages(); }
public void ConfigureServices(IServiceCollection services) { services.AddHttpContextAccessor(); var connectionString = Configuration.GetConnectionString("LampshadeDb"); ShopManagementBootstrapper.Configure(services, connectionString); DiscountManagementBootstrapper.Configure(services, connectionString); InventoryManagementBootstrapper.Configure(services, connectionString); BlogManagementBootstrapper.Configure(services, connectionString); CommentManagementBootstrapper.Configure(services, connectionString); AccountManagementBootstrapper.Configure(services, connectionString); services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.BasicLatin, UnicodeRanges.Arabic)); services.AddSingleton <IPasswordHasher, PasswordHasher>(); services.AddTransient <IFileUploader, FileUploader>(); services.AddTransient <IAuthHelper, AuthHelper>(); services.AddTransient <IZarinPalFactory, ZarinPalFactory>(); services.AddTransient <ISmsService, SmsService>(); services.AddTransient <IEmailService, EmailService>(); services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.Lax; }); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, o => { o.LoginPath = new PathString("/Account"); o.LogoutPath = new PathString("/Account"); o.AccessDeniedPath = new PathString("/AccessDenied"); }); services.AddAuthorization(options => { options.AddPolicy("AdminArea", builder => builder.RequireRole(new List <string> { Roles.Administrator, Roles.ContentUploader })); options.AddPolicy("Shop", builder => builder.RequireRole(new List <string> { Roles.Administrator })); options.AddPolicy("Discount", builder => builder.RequireRole(new List <string> { Roles.Administrator })); options.AddPolicy("Account", builder => builder.RequireRole(new List <string> { Roles.Administrator })); }); services.AddCors(options => options.AddPolicy("MyPolicy", builder => builder .WithOrigins("https://localhost:5002") .AllowAnyHeader() .AllowAnyMethod())); services.AddRazorPages() .AddMvcOptions(options => options.Filters.Add <SecurityPageFilter>()) .AddRazorPagesOptions(options => { options.Conventions.AuthorizeAreaFolder("Administration", "/", "AdminArea"); options.Conventions.AuthorizeAreaFolder("Administration", "/Shop", "Shop"); options.Conventions.AuthorizeAreaFolder("Administration", "/Discounts", "Discount"); options.Conventions.AuthorizeAreaFolder("Administration", "/Accounts", "Account"); }) .AddApplicationPart(typeof(ProductController).Assembly) .AddApplicationPart(typeof(InventoryController).Assembly) .AddNewtonsoftJson(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddHttpContextAccessor(); var connectionString = Configuration.GetConnectionString("LampshadeDB"); ShopManagementBootstrapper.Configure(services, connectionString); DiscountManagementBootstrapper.Configure(services, connectionString); InventoryManagementBootstrapper.Configure(services, connectionString); BlogManagementBootstrapper.Configure(services, connectionString); CommentManagementBootstrapper.Configure(services, connectionString); AccountManagementBootstrapper.Configure(services, connectionString); services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.BasicLatin, UnicodeRanges.Arabic)); services.AddSingleton <IPasswordHasher, PasswordHasher>(); services.AddTransient <IFileUploader, FileUploader>(); services.AddTransient <IAuthHelper, AuthHelper>(); services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => false; options.MinimumSameSitePolicy = SameSiteMode.Lax; }); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, o => { o.LoginPath = new PathString("/Account"); o.LogoutPath = new PathString("/Account"); o.AccessDeniedPath = new PathString("/AccessDenied"); }); services.AddAuthorization(options => { options.AddPolicy("AdminArea", builder => builder.RequireRole(new List <string> { Roles.Administrator, Roles.ContextUploader })); options.AddPolicy("Shop", builder => builder.RequireRole(new List <string> { Roles.Administrator })); options.AddPolicy("Discount", builder => builder.RequireRole(new List <string> { Roles.Administrator })); options.AddPolicy("Account", builder => builder.RequireRole(new List <string> { Roles.Administrator })); options.AddPolicy("Inventory", builder => builder.RequireRole(new List <string> { Roles.Administrator })); }); services.AddRazorPages() .AddMvcOptions(options => options.Filters.Add <SecurityPageFilter>()) .AddRazorPagesOptions(options => { options.Conventions.AuthorizeAreaFolder("Administration", "/", "AdminArea"); options.Conventions.AuthorizeAreaFolder("Administration", "/Shop", "Shop"); options.Conventions.AuthorizeAreaFolder("Administration", "/Discounts", "Discount"); options.Conventions.AuthorizeAreaFolder("Administration", "/Accounts", "Account"); options.Conventions.AuthorizeAreaFolder("Administration", "/Inventory", "Inventory"); }); }