Anhaenge laufen bewusst NICHT ueber den JSON-Ereigniskanal (wuerde ihn
fuer Fotos/Scans stark aufblaehen), sondern ueber einen eigenen
verschluesselten Binaerkanal - analog zum bereits bestehenden Muster
in SnapshotService.
- Neue Endpunkte POST/GET /api/sync/attachments/{storageId} in
LehrerApp.Api (AttachmentStore, dateibasiert je Nutzer)
- EventQueue: neue, vom JSON-Ereignis getrennte Warteliste fuer
ausstehende Uploads (SyncEventPublisher traegt Anhaenge einer
gespeicherten Documentation dort ein)
- AttachmentSyncer laedt ausstehende Anhaenge hoch (in
SyncEngine.SyncNowAsync nach dem Event-Push)
- EventApplier laedt fehlende Anhaenge nach dem Anwenden eines
Documentation-Ereignisses nach - ueber die rohe Collection statt
IAttachmentStorage.Upload, da dieses immer eine neue Id vergaebe und
hier die Original-StorageId erhalten bleiben muss
Round-Trip-Tests belegen byteidentische Uebertragung.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
51 lines
1.8 KiB
C#
51 lines
1.8 KiB
C#
using System.Text;
|
|
using LehrerApp.Api;
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.WebHost.UseKestrel(o =>
|
|
{
|
|
var port = builder.Configuration.GetValue<int>("Api:Port", 5000);
|
|
o.ListenAnyIP(port);
|
|
});
|
|
|
|
var data = builder.Configuration["Api:DataPath"] ?? "./data";
|
|
|
|
if (args.Length > 0 && args[0] == "create-user")
|
|
return await Cli.RunCreateUserAsync(data, args);
|
|
|
|
var secret = builder.Configuration["JWT_SECRET"]
|
|
?? throw new InvalidOperationException("JWT_SECRET nicht konfiguriert.");
|
|
|
|
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
.AddJwtBearer(o => o.TokenValidationParameters = new()
|
|
{
|
|
ValidateIssuerSigningKey = true,
|
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secret)),
|
|
ValidateIssuer = false, ValidateAudience = false,
|
|
ClockSkew = TimeSpan.FromMinutes(5),
|
|
});
|
|
builder.Services.AddAuthorization();
|
|
|
|
builder.Services.AddSingleton<UserStore>(_ => new UserStore(data));
|
|
builder.Services.AddSingleton<AttachmentStore>(_ => new AttachmentStore(data));
|
|
builder.Services.AddSingleton<EventStore>(_ => new EventStore(data));
|
|
builder.Services.AddSingleton<SnapshotStore>(_ => new SnapshotStore(data));
|
|
builder.Services.AddSingleton<ReadableSnapshotStore>(_ => new ReadableSnapshotStore(data));
|
|
builder.Services.AddSingleton<PlainEventStore>(sp =>
|
|
new PlainEventStore(sp.GetRequiredService<EventStore>()));
|
|
|
|
var app = builder.Build();
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
app.MapAuthEndpoints(secret);
|
|
app.MapSyncEndpoints();
|
|
app.MapAttachmentEndpoints();
|
|
app.MapSnapshotEndpoints();
|
|
app.MapReadableSnapshotEndpoints();
|
|
app.MapPlainSyncEndpoints();
|
|
app.Run();
|
|
return 0;
|