diff --git a/src/TrackApi/.idea/.idea.TrackQrApi/.idea/db-forest-config.xml b/src/TrackApi/.idea/.idea.TrackQrApi/.idea/db-forest-config.xml new file mode 100644 index 0000000..68dad9b --- /dev/null +++ b/src/TrackApi/.idea/.idea.TrackQrApi/.idea/db-forest-config.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/src/TrackApi/TrackQrApi.slnx.DotSettings.user b/src/TrackApi/TrackQrApi.slnx.DotSettings.user index 26a287d..9abe233 100644 --- a/src/TrackApi/TrackQrApi.slnx.DotSettings.user +++ b/src/TrackApi/TrackQrApi.slnx.DotSettings.user @@ -1,4 +1,6 @@  + ForceIncluded + ForceIncluded ForceIncluded <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from &lt;api.Tests&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> <Project Location="/home/jbourdon/repos/trakqr/src/api.Tests" Presentation="&lt;api.Tests&gt;" /> diff --git a/src/TrackApi/TrackQrApi/Features/Events/Services/EventTrackingService.cs b/src/TrackApi/TrackQrApi/Features/Events/Services/EventTrackingService.cs index 7b70cb2..ea2dd48 100644 --- a/src/TrackApi/TrackQrApi/Features/Events/Services/EventTrackingService.cs +++ b/src/TrackApi/TrackQrApi/Features/Events/Services/EventTrackingService.cs @@ -65,6 +65,8 @@ public class EventTrackingService( EventType eventType, HttpContext context) { + logger.LogInformation("About to track something"); + // Create a new scope for database access (since we're in a background task) using var scope = scopeFactory.CreateScope(); var db = scope.ServiceProvider.GetRequiredService(); @@ -165,4 +167,4 @@ public class EventTrackingService( return value.Length <= maxLength ? value : value[..maxLength]; } -} \ No newline at end of file +} diff --git a/src/TrackApi/TrackQrApi/Program.cs b/src/TrackApi/TrackQrApi/Program.cs index ebd989e..3031871 100644 --- a/src/TrackApi/TrackQrApi/Program.cs +++ b/src/TrackApi/TrackQrApi/Program.cs @@ -1,9 +1,8 @@ -using System.Text; using System.Threading.RateLimiting; using FastEndpoints; -using Microsoft.AspNetCore.Authentication.JwtBearer; +using FastEndpoints.Security; +using FastEndpoints.Swagger; using Microsoft.EntityFrameworkCore; -using Microsoft.IdentityModel.Tokens; using Serilog; using Serilog.Events; using TrackQrApi.Data; @@ -149,24 +148,16 @@ try var jwtSettings = builder.Configuration.GetSection("Jwt").Get()!; // Configure authentication - builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) - .AddJwtBearer(options => - { - options.TokenValidationParameters = new TokenValidationParameters + builder.Services.AddAuthenticationJwtBearer( + signing => signing.SigningKey = jwtSettings.Secret, + bearer => { - ValidateIssuer = true, - ValidateAudience = true, - ValidateLifetime = true, - ValidateIssuerSigningKey = true, - ValidIssuer = jwtSettings.Issuer, - ValidAudience = jwtSettings.Audience, - IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings.Secret)) - }; - }); - + bearer.TokenValidationParameters.ValidIssuer = jwtSettings.Issuer; + bearer.TokenValidationParameters.ValidAudience = jwtSettings.Audience; + }); builder.Services.AddAuthorization(); builder.Services.AddFastEndpoints(); - builder.Services.AddOpenApi(); + builder.Services.SwaggerDocument(); var app = builder.Build(); @@ -187,19 +178,15 @@ try app.UseCors(); app.UseRateLimiter(); - - // Configure the HTTP request pipeline - if (app.Environment.IsDevelopment()) - { - app.MapOpenApi().CacheOutput(); - app.UseSwaggerUI(options => { options.SwaggerEndpoint("/openapi/v1.json", "v1"); }); - } - app.UseHttpsRedirection(); app.UseAuthentication(); app.UseAuthorization(); app.UseFastEndpoints(); + if (app.Environment.IsDevelopment()) + { + app.UseSwaggerGen(); + } app.Run(); } diff --git a/src/TrackApi/TrackQrApi/TrackQrApi.csproj b/src/TrackApi/TrackQrApi/TrackQrApi.csproj index 49b5ab1..e5699c7 100644 --- a/src/TrackApi/TrackQrApi/TrackQrApi.csproj +++ b/src/TrackApi/TrackQrApi/TrackQrApi.csproj @@ -11,24 +11,23 @@ - + + + + + + - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - - - - diff --git a/src/TrackApi/TrackQrApi/uploads/71f9eaf6-2f66-4c74-a5eb-196345e13c36.png b/src/TrackApi/TrackQrApi/uploads/71f9eaf6-2f66-4c74-a5eb-196345e13c36.png new file mode 100644 index 0000000..7161719 Binary files /dev/null and b/src/TrackApi/TrackQrApi/uploads/71f9eaf6-2f66-4c74-a5eb-196345e13c36.png differ