summaryrefslogtreecommitdiff
path: root/src/marlin.web/Program.cs
diff options
context:
space:
mode:
authorMelodi <62381002+Melodi17@users.noreply.github.com>2026-09-13 13:22:20 +1000
committerMelodi <62381002+Melodi17@users.noreply.github.com>2026-09-13 13:22:20 +1000
commitdf0737e55afeb5c01eb39909605970d1d3a73ffc (patch)
tree09823eaa310c60eefd2420dc305acae45c81900f /src/marlin.web/Program.cs
parentee69ce25b2fba871920260028bb10c2d6b62b26f (diff)
refactor: cleanup; feat: connection to agent
Diffstat (limited to 'src/marlin.web/Program.cs')
-rw-r--r--src/marlin.web/Program.cs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/marlin.web/Program.cs b/src/marlin.web/Program.cs
index f079a3c..700e696 100644
--- a/src/marlin.web/Program.cs
+++ b/src/marlin.web/Program.cs
@@ -13,6 +13,16 @@ builder.Services.AddDbContext<ApplicationDbContext>(options => options
builder.Services.AddScoped<ISourceSecretStore, DatabaseSourceSecretStore>();
+builder.Services
+ .AddAuthentication(AgentSchemeOptions.Name)
+ .AddScheme<AgentSchemeOptions, AgentAuthenticationHandler>(AgentSchemeOptions.Name, null);
+
+builder.Services.AddAuthorization(options =>
+{
+ options.AddPolicy("Agent", p => p.RequireClaim("agent_id"));
+ options.AddPolicy("JobScoped", p => p.RequireClaim("job_id"));
+});
+
builder.Services.AddHostedService<DatabaseUpgrader>();
builder.Services.AddSingleton<VersionControlSyncService>();
@@ -20,7 +30,8 @@ builder.Services.AddHostedService<VersionControlSyncService>(sp => sp
.GetRequiredService<VersionControlSyncService>());
// Add services to the container.
-builder.Services.AddControllersWithViews();
+builder.Services.AddControllersWithViews(options =>
+ options.OutputFormatters.RemoveType<Microsoft.AspNetCore.Mvc.Formatters.HttpNoContentOutputFormatter>());
var app = builder.Build();
@@ -35,6 +46,7 @@ if (!app.Environment.IsDevelopment())
app.UseHttpsRedirection();
app.UseRouting();
+app.UseAuthentication();
app.UseAuthorization();
app.MapStaticAssets();