a039bb53a4
- AuthService로 JWT 토큰 생성 및 검증 - CustomAuthenticationStateProvider를 통한 Blazor 인증 통합 - LocalStorageService로 토큰 관리 - Login.razor 완전 재작성 (실제 DB 검증, 토큰 발급) - BCrypt 기반 비밀번호 검증 - admin/admin123으로 테스트 가능 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
75 lines
2.5 KiB
C#
75 lines
2.5 KiB
C#
using System.Text.Encodings.Web;
|
|
using System.Text.Unicode;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using MudBlazor.Services;
|
|
using TaxBaik.Admin.Services;
|
|
using TaxBaik.Application;
|
|
using TaxBaik.Infrastructure;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddScoped<AuthService>();
|
|
builder.Services.AddScoped<CustomAuthenticationStateProvider>();
|
|
builder.Services.AddScoped<AuthenticationStateProvider>(sp => sp.GetRequiredService<CustomAuthenticationStateProvider>());
|
|
builder.Services.AddScoped<ILocalStorageService, LocalStorageService>();
|
|
builder.Services.AddCascadingAuthenticationState();
|
|
builder.Services.AddAuthorizationCore();
|
|
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
builder.Services.AddMudServices();
|
|
builder.Services.AddMemoryCache();
|
|
|
|
// 한글 포함 다국어 문자를 유니코드 엔티티로 변환하지 않도록 설정
|
|
builder.Services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All));
|
|
|
|
builder.Services.AddInfrastructure();
|
|
builder.Services.AddApplication();
|
|
|
|
// Register version info
|
|
var versionInfo = new VersionInfo();
|
|
var versionFilePath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "version.txt");
|
|
if (File.Exists(versionFilePath))
|
|
{
|
|
var lines = File.ReadAllLines(versionFilePath);
|
|
foreach (var line in lines)
|
|
{
|
|
if (line.StartsWith("Version:"))
|
|
versionInfo.Version = line.Substring("Version:".Length).Trim();
|
|
else if (line.StartsWith("Built:"))
|
|
versionInfo.Built = line.Substring("Built:".Length).Trim();
|
|
}
|
|
}
|
|
builder.Services.AddSingleton(versionInfo);
|
|
|
|
var app = builder.Build();
|
|
|
|
// Run migrations on startup
|
|
using (var scope = app.Services.CreateScope())
|
|
{
|
|
var connectionFactory = scope.ServiceProvider.GetRequiredService<TaxBaik.Domain.Interfaces.IDbConnectionFactory>();
|
|
var cs = builder.Configuration.GetConnectionString("Default")
|
|
?? throw new InvalidOperationException("Missing connection string");
|
|
var migrationRunner = new TaxBaik.Infrastructure.Data.MigrationRunner(cs, connectionFactory);
|
|
await migrationRunner.RunAsync();
|
|
}
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UsePathBase("/taxbaik/admin");
|
|
app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
app.UseRouting();
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
app.UseAntiforgery();
|
|
|
|
app.MapRazorComponents<TaxBaik.Admin.Components.App>()
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
app.Run();
|