Fix admin api service resolution stuff

This commit is contained in:
Rory&
2026-09-02 22:22:37 +02:00
parent 528deeff9a
commit 03667812a4
2 changed files with 4 additions and 2 deletions
@@ -7,7 +7,6 @@ namespace Spacebar.AdminApi.Middleware;
public class AuthenticationMiddleware(
ILogger<AuthenticationMiddleware> logger,
SpacebarAspNetAuthenticationService authService,
SpacebarAuthenticationConfiguration config,
RequestDelegate next) {
public async Task InvokeAsync(HttpContext context, IServiceProvider sp) {
@@ -16,6 +15,9 @@ public class AuthenticationMiddleware(
return;
}
await using var spScope = sp.CreateAsyncScope();
var authService = spScope.ServiceProvider.GetRequiredService<SpacebarAspNetAuthenticationService>();
TokenValidationResult? res = null;
try {
await authService.ValidateTokenAsync(context.Request);
+1 -1
View File
@@ -30,7 +30,7 @@ builder.Services.AddDbContextPool<SpacebarDbContext>(options => {
.UseNpgsql(builder.Configuration.GetConnectionString("Spacebar"))
.EnableDetailedErrors();
});
builder.Services.AddScoped<SpacebarAuthenticationConfiguration>();
builder.Services.AddSingleton<SpacebarAuthenticationConfiguration>();
builder.Services.AddScoped<SpacebarAuthenticationService>();
builder.Services.AddScoped<SpacebarAspNetAuthenticationService>();
// builder.Services.AddSingleton<RabbitMQConfiguration>();