Základní backend: migrace, autentizace JWT, role, Swagger

- Helpdesk.Migrator (DbUp) aplikuje db/migrations, evidence v schema_version
- Domain/Application/Infrastructure/Api podle Clean Architecture
- registrace, ověření e-mailu, login, refresh s rotací, logout, reset hesla
- JWT podle RFC 7519 evidované jen podle jti v auth_token
- správa uživatelů a rolí, číselníky, ProblemDetails, Swagger UI
- Docker Compose (db, migrator, api), oddělené DB účty
- notifikace mají cizí klíče na issue a proposal
- unit testy domény a zabezpečení

Closes #1, closes #2, closes #3, closes #4, closes #5, closes #9
This commit is contained in:
PatTheEvil committed 2026-10-28 21:43:17 +01:00
1 parent fc76be7d69
commit a51d386278
64 files changed
+4394 -1

No files matched your search

@@ -0,0 +1,41 @@
using Helpdesk.Application.Abstractions;
using Helpdesk.Infrastructure.Background;
using Helpdesk.Infrastructure.Email;
using Helpdesk.Infrastructure.Persistence;
using Helpdesk.Infrastructure.Security;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace Helpdesk.Infrastructure;
public static class DependencyInjection
{
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
{
var connectionString = configuration.GetConnectionString("Helpdesk")
?? throw new InvalidOperationException("Chybí připojovací řetězec ConnectionStrings:Helpdesk.");
services.AddSingleton(TimeProvider.System);
services.Configure<JwtOptions>(configuration.GetSection(JwtOptions.Section));
services.Configure<EncryptionOptions>(configuration.GetSection(EncryptionOptions.Section));
services.AddSingleton<FieldEncryptor>();
services.AddSingleton<CreatedAtInterceptor>();
services.AddDbContext<HelpdeskDbContext>((sp, options) => options
.UseMySql(connectionString, new MariaDbServerVersion(new Version(11, 4)))
.UseSnakeCaseNamingConvention()
.AddInterceptors(sp.GetRequiredService<CreatedAtInterceptor>()));
services.AddScoped<IAppDbContext>(sp => sp.GetRequiredService<HelpdeskDbContext>());
services.AddSingleton<IPasswordHasher, BCryptPasswordHasher>();
services.AddSingleton<ITokenService, JwtTokenService>();
services.AddSingleton<IRevokedTokenStore, RevokedTokenStore>();
services.AddSingleton<IEmailSender, LoggingEmailSender>();
services.AddHostedService<RevokedTokenStoreLoader>();
services.AddHostedService<AdminSeeder>();
services.AddHostedService<AuthTokenCleanupService>();
return services;
}
}