From a31a7f53d0ca5b864f1528e0d58f1abc21d52c9e Mon Sep 17 00:00:00 2001 From: damienbod Date: Sat, 26 Oct 2024 09:47:31 +0200 Subject: [PATCH] code clean up --- BlazorAuth0Bff/Server/Program.cs | 5 ++--- MyApi/Program.cs | 3 +-- RazorMicrosoftEntraID/Program.cs | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/BlazorAuth0Bff/Server/Program.cs b/BlazorAuth0Bff/Server/Program.cs index cc62e25..e90db99 100644 --- a/BlazorAuth0Bff/Server/Program.cs +++ b/BlazorAuth0Bff/Server/Program.cs @@ -4,7 +4,6 @@ var services = builder.Services; var configuration = builder.Configuration; -var env = builder.Environment; services.AddAntiforgery(options => { @@ -102,7 +101,7 @@ var app = builder.Build(); -if (env.IsDevelopment()) +if (app.Environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebAssemblyDebugging(); @@ -115,7 +114,7 @@ var idp = $"https://{configuration["Auth0:Domain"]}"; app.UseSecurityHeaders( SecurityHeadersDefinitions - .GetHeaderPolicyCollection(env.IsDevelopment(), idp)); + .GetHeaderPolicyCollection(app.Environment.IsDevelopment(), idp)); app.UseHttpsRedirection(); app.UseBlazorFrameworkFiles(); diff --git a/MyApi/Program.cs b/MyApi/Program.cs index 6a5731e..84b0ff4 100644 --- a/MyApi/Program.cs +++ b/MyApi/Program.cs @@ -16,7 +16,6 @@ var services = builder.Services; var configuration = builder.Configuration; -var env = builder.Environment; // only needed for browser clients //services.AddCors(options => @@ -122,7 +121,7 @@ JsonWebTokenHandler.DefaultInboundClaimTypeMap.Clear(); app.UseSecurityHeaders( - SecurityHeadersDefinitions.GetHeaderPolicyCollection(env.IsDevelopment())); + SecurityHeadersDefinitions.GetHeaderPolicyCollection(app.Environment.IsDevelopment())); app.UseSwagger(); app.UseSwaggerUI(c => diff --git a/RazorMicrosoftEntraID/Program.cs b/RazorMicrosoftEntraID/Program.cs index 014aeb8..af20339 100644 --- a/RazorMicrosoftEntraID/Program.cs +++ b/RazorMicrosoftEntraID/Program.cs @@ -13,7 +13,6 @@ var services = builder.Services; var configuration = builder.Configuration; -var env = builder.Environment; services.AddTransient(); services.AddHttpClient(); @@ -36,7 +35,7 @@ var app = builder.Build(); -if (env.IsDevelopment()) +if (app.Environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); } @@ -46,7 +45,7 @@ } app.UseSecurityHeaders( - SecurityHeadersDefinitions.GetHeaderPolicyCollection(env.IsDevelopment())); + SecurityHeadersDefinitions.GetHeaderPolicyCollection(app.Environment.IsDevelopment())); app.UseHttpsRedirection(); app.UseStaticFiles();