mirror of
https://github.com/morbalint/kemkas.git
synced 2026-07-17 19:03:46 +00:00
59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using Microsoft.AspNetCore.Authentication;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Identity.UI;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Kemkas.Web.Data;
|
|
using Kemkas.Web.Models;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ??
|
|
throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
|
|
builder.Services.AddDbContext<ApplicationDbContext>(
|
|
options =>
|
|
options.UseSqlite(connectionString));
|
|
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
|
|
|
builder.Services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
|
.AddEntityFrameworkStores<ApplicationDbContext>();
|
|
|
|
builder.Services.AddIdentityServer()
|
|
.AddApiAuthorization<ApplicationUser, ApplicationDbContext>();
|
|
|
|
// builder.Services.AddAuthentication()
|
|
// .AddIdentityServerJwt();
|
|
|
|
builder.Services.AddControllersWithViews();
|
|
builder.Services.AddRazorPages();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseMigrationsEndPoint();
|
|
}
|
|
else
|
|
{
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
app.UseHsts();
|
|
}
|
|
|
|
// app.UseHttpsRedirection(); // reverse proxy should take care of that
|
|
app.UseStaticFiles();
|
|
app.UseRouting();
|
|
|
|
// app.UseAuthentication();
|
|
// app.UseIdentityServer();
|
|
// app.UseAuthorization();
|
|
|
|
app.MapControllerRoute(
|
|
name: "default",
|
|
pattern: "{controller}/{action=Index}/{id?}");
|
|
app.MapRazorPages();
|
|
|
|
app.MapFallbackToFile("index.html");
|
|
|
|
app.Run();
|