65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
using ConstructorApp.BusinessLayer.Abstract;
|
|
using ConstructorApp.BusinessLayer.Concrete;
|
|
using ConstructorApp.DataAccessLayer.Abstract;
|
|
using ConstructorApp.DataAccessLayer.Concrete;
|
|
using ConstructorApp.DataAccessLayer.EntityFramework;
|
|
using ConstructorApp.EntityLayer.Entities;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Mvc.Authorization;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
//Proje seviyesinde Authentication saðlamasý
|
|
var requireAuthorizePolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddDbContext<ConstructorContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("mssql")));
|
|
|
|
// IFooterService ve FooterService servisini ekleyin
|
|
builder.Services.AddScoped<IFooterService, FooterManager>();
|
|
builder.Services.AddScoped<IFooterDal, EfFooterDal>();
|
|
|
|
builder.Services.AddIdentity<AppUser, AppRole>()
|
|
.AddEntityFrameworkStores<ConstructorContext>()
|
|
.AddDefaultTokenProviders();
|
|
builder.Services.AddHttpClient();
|
|
|
|
//Tüm projede kullanýcýlarý login olmaya zorla
|
|
builder.Services.AddControllersWithViews(opt =>
|
|
{
|
|
opt.Filters.Add(new AuthorizeFilter(requireAuthorizePolicy));
|
|
});
|
|
|
|
//Login sayfasýný default olan Account/Login yerine kendi login sayfama yönlendir
|
|
builder.Services.ConfigureApplicationCookie(opts =>
|
|
{
|
|
opts.LoginPath = "/Login/Index/";
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Home/Error");
|
|
|
|
app.UseHsts();
|
|
}
|
|
|
|
//app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.UseAuthentication();
|
|
|
|
app.MapControllerRoute(
|
|
name: "default",
|
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
|
|
|
app.Run();
|