From e2d40d596bf897c784960b2b40a5ffb6ff43597b Mon Sep 17 00:00:00 2001 From: joelhulen Date: Tue, 27 Feb 2024 19:09:39 -0500 Subject: [PATCH] Move production parameter setting before first use --- src/dotnet/AgentFactoryAPI/Program.cs | 4 ++-- src/dotnet/CoreAPI/Program.cs | 4 ++-- src/dotnet/CoreWorker/Program.cs | 2 ++ src/dotnet/GatekeeperAPI/Program.cs | 4 ++-- src/dotnet/ManagementAPI/Program.cs | 4 ++-- src/dotnet/SemanticKernelAPI/Program.cs | 4 ++-- src/dotnet/VectorizationAPI/Program.cs | 4 ++-- src/dotnet/VectorizationWorker/Program.cs | 4 ++-- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/dotnet/AgentFactoryAPI/Program.cs b/src/dotnet/AgentFactoryAPI/Program.cs index b01462dad6..d210083a2a 100644 --- a/src/dotnet/AgentFactoryAPI/Program.cs +++ b/src/dotnet/AgentFactoryAPI/Program.cs @@ -43,6 +43,8 @@ public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); + DefaultAuthentication.Production = builder.Environment.IsProduction(); + builder.Configuration.Sources.Clear(); builder.Configuration.AddJsonFile("appsettings.json", false, true); builder.Configuration.AddEnvironmentVariables(); @@ -61,8 +63,6 @@ public static void Main(string[] args) if (builder.Environment.IsDevelopment()) builder.Configuration.AddJsonFile("appsettings.development.json", true, true); - DefaultAuthentication.Production = builder.Environment.IsProduction(); - // Add services to the container. // Add the OpenTelemetry telemetry service and send telemetry data to Azure Monitor. builder.Services.AddOpenTelemetry().UseAzureMonitor(options => diff --git a/src/dotnet/CoreAPI/Program.cs b/src/dotnet/CoreAPI/Program.cs index 399ebc9cfc..bf460c0c26 100644 --- a/src/dotnet/CoreAPI/Program.cs +++ b/src/dotnet/CoreAPI/Program.cs @@ -39,6 +39,8 @@ public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); + DefaultAuthentication.Production = builder.Environment.IsProduction(); + builder.Configuration.Sources.Clear(); builder.Configuration.AddJsonFile("appsettings.json", false, true); builder.Configuration.AddEnvironmentVariables(); @@ -59,8 +61,6 @@ public static void Main(string[] args) if (builder.Environment.IsDevelopment()) builder.Configuration.AddJsonFile("appsettings.development.json", true, true); - DefaultAuthentication.Production = builder.Environment.IsProduction(); - var allowAllCorsOrigins = "AllowAllOrigins"; builder.Services.AddCors(policyBuilder => { diff --git a/src/dotnet/CoreWorker/Program.cs b/src/dotnet/CoreWorker/Program.cs index a38b47237d..99b29409b2 100644 --- a/src/dotnet/CoreWorker/Program.cs +++ b/src/dotnet/CoreWorker/Program.cs @@ -8,6 +8,8 @@ var builder = Host.CreateApplicationBuilder(args); +DefaultAuthentication.Production = builder.Environment.IsProduction(); + builder.Configuration.Sources.Clear(); builder.Configuration.AddJsonFile("appsettings.json", false, true); builder.Configuration.AddEnvironmentVariables(); diff --git a/src/dotnet/GatekeeperAPI/Program.cs b/src/dotnet/GatekeeperAPI/Program.cs index bbcf392c1d..a021af408f 100644 --- a/src/dotnet/GatekeeperAPI/Program.cs +++ b/src/dotnet/GatekeeperAPI/Program.cs @@ -38,6 +38,8 @@ public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); + DefaultAuthentication.Production = builder.Environment.IsProduction(); + builder.Configuration.Sources.Clear(); builder.Configuration.AddJsonFile("appsettings.json", false, true); builder.Configuration.AddEnvironmentVariables(); @@ -55,8 +57,6 @@ public static void Main(string[] args) if (builder.Environment.IsDevelopment()) builder.Configuration.AddJsonFile("appsettings.development.json", true, true); - DefaultAuthentication.Production = builder.Environment.IsProduction(); - // Add services to the container. // Add the OpenTelemetry telemetry service and send telemetry data to Azure Monitor. builder.Services.AddOpenTelemetry().UseAzureMonitor(options => diff --git a/src/dotnet/ManagementAPI/Program.cs b/src/dotnet/ManagementAPI/Program.cs index faa7a319ef..0602ff51fa 100644 --- a/src/dotnet/ManagementAPI/Program.cs +++ b/src/dotnet/ManagementAPI/Program.cs @@ -45,6 +45,8 @@ public static async Task Main(string[] args) { var builder = WebApplication.CreateBuilder(args); + DefaultAuthentication.Production = builder.Environment.IsProduction(); + builder.Configuration.Sources.Clear(); builder.Configuration.AddJsonFile("appsettings.json", false, true); builder.Configuration.AddEnvironmentVariables(); @@ -67,8 +69,6 @@ public static async Task Main(string[] args) if (builder.Environment.IsDevelopment()) builder.Configuration.AddJsonFile("appsettings.development.json", true, true); - DefaultAuthentication.Production = builder.Environment.IsProduction(); - // Add the Configuration resource provider builder.AddConfigurationResourceProvider(); diff --git a/src/dotnet/SemanticKernelAPI/Program.cs b/src/dotnet/SemanticKernelAPI/Program.cs index 9ff47cdafe..c729c83f03 100644 --- a/src/dotnet/SemanticKernelAPI/Program.cs +++ b/src/dotnet/SemanticKernelAPI/Program.cs @@ -30,6 +30,8 @@ public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); + DefaultAuthentication.Production = builder.Environment.IsProduction(); + builder.Configuration.Sources.Clear(); builder.Configuration.AddJsonFile("appsettings.json", false, true); builder.Configuration.AddEnvironmentVariables(); @@ -53,8 +55,6 @@ public static void Main(string[] args) if (builder.Environment.IsDevelopment()) builder.Configuration.AddJsonFile("appsettings.development.json", true, true); - DefaultAuthentication.Production = builder.Environment.IsProduction(); - // Add services to the container. //builder.Services.AddApplicationInsightsTelemetry(); builder.Services.AddAuthorization(); diff --git a/src/dotnet/VectorizationAPI/Program.cs b/src/dotnet/VectorizationAPI/Program.cs index 204ff2b812..01048458f9 100644 --- a/src/dotnet/VectorizationAPI/Program.cs +++ b/src/dotnet/VectorizationAPI/Program.cs @@ -25,6 +25,8 @@ var builder = WebApplication.CreateBuilder(args); +DefaultAuthentication.Production = builder.Environment.IsProduction(); + builder.Configuration.Sources.Clear(); builder.Configuration.AddJsonFile("appsettings.json", false, true); builder.Configuration.AddEnvironmentVariables(); @@ -44,8 +46,6 @@ if (builder.Environment.IsDevelopment()) builder.Configuration.AddJsonFile("appsettings.development.json", true, true); -DefaultAuthentication.Production = builder.Environment.IsProduction(); - // Add the Configuration resource provider builder.AddConfigurationResourceProvider(); diff --git a/src/dotnet/VectorizationWorker/Program.cs b/src/dotnet/VectorizationWorker/Program.cs index 9b6629f349..3c098fd4dd 100644 --- a/src/dotnet/VectorizationWorker/Program.cs +++ b/src/dotnet/VectorizationWorker/Program.cs @@ -26,6 +26,8 @@ var builder = WebApplication.CreateBuilder(args); +DefaultAuthentication.Production = builder.Environment.IsProduction(); + builder.Configuration.Sources.Clear(); builder.Configuration.AddJsonFile("appsettings.json", false, true); builder.Configuration.AddEnvironmentVariables(); @@ -46,8 +48,6 @@ if (builder.Environment.IsDevelopment()) builder.Configuration.AddJsonFile("appsettings.development.json", true, true); -DefaultAuthentication.Production = builder.Environment.IsProduction(); - // Add the Configuration resource provider builder.AddConfigurationResourceProvider();