59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using Hcs.WebApp.Components;
|
|
using Hcs.WebApp.Data;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Radzen;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services
|
|
.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddRadzenComponents();
|
|
|
|
builder.Services.AddHttpClient("Hcs.WebApp").AddHeaderPropagation(x => x.Headers.Add("Cookie"));
|
|
builder.Services.AddHeaderPropagation(x => x.Headers.Add("Cookie"));
|
|
builder.Services.AddAuthentication();
|
|
builder.Services.AddAuthorization();
|
|
|
|
var connectionString = builder.Configuration.GetConnectionString("IdentityConnection") ?? throw new InvalidOperationException("Íå óäàëîñü ïîëó÷èòü çíà÷åíèå èç 'IdentityConnection'");
|
|
builder.Services.AddDbContext<AppIdentityDbContext>(options => options.UseSqlServer(connectionString));
|
|
|
|
builder.Services
|
|
.AddIdentity<AppUser, AppRole>(options =>
|
|
{
|
|
options.Password.RequiredLength = 6;
|
|
options.Password.RequireNonAlphanumeric = false;
|
|
options.Password.RequireDigit = false;
|
|
options.Password.RequireLowercase = false;
|
|
options.Password.RequireUppercase = false;
|
|
options.Password.RequiredUniqueChars = 1;
|
|
})
|
|
.AddEntityFrameworkStores<AppIdentityDbContext>()
|
|
.AddDefaultTokenProviders();
|
|
|
|
var app = builder.Build();
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/error", createScopeForErrors: true);
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
app.UseHeaderPropagation();
|
|
app.UseRouting();
|
|
app.UseAntiforgery();
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
app.MapControllers();
|
|
|
|
app
|
|
.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
app.Run();
|