diff --git a/src/Indexer/Program.cs b/src/Indexer/Program.cs index 4af1b88..415ad0b 100644 --- a/src/Indexer/Program.cs +++ b/src/Indexer/Program.cs @@ -32,7 +32,22 @@ builder.Services.AddElmah(Options => }); var app = builder.Build(); -app.UseElmah(); +app.Map("/elmah", builder => // Add a middleware before Elmah that authorizes only the development environment +{ + builder.Use(async (context, next) => + { + if (!app.Environment.IsDevelopment()) // TODO add configuration option to allow for elmah (i.e. opt-in) + { + context.Response.StatusCode = 403; + await context.Response.WriteAsync("Forbidden"); + return; + } + + await next(); + }); + + builder.UseElmah(); +}); app.MapHealthChecks("/healthz"); // Configure the HTTP request pipeline.