diff --git a/srcs/GameChannel/Controllers/HealthController.cs b/srcs/GameChannel/Controllers/HealthController.cs index b221930..de574a1 100644 --- a/srcs/GameChannel/Controllers/HealthController.cs +++ b/srcs/GameChannel/Controllers/HealthController.cs @@ -65,7 +65,7 @@ namespace GameChannel.Controllers public class HealthCheckApiKey : Attribute, IAsyncActionFilter { private const string APIKEYNAME = "HEALTHCHECK_API_KEY"; - private static string HEALTHCHECK_API_KEY = Environment.GetEnvironmentVariable(APIKEYNAME) ?? "123456789"; + private static readonly string HEALTHCHECK_API_KEY = Environment.GetEnvironmentVariable(APIKEYNAME); public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { @@ -79,7 +79,7 @@ namespace GameChannel.Controllers return; } - if (!extractedApiKey.Equals(extractedApiKey)) + if (string.IsNullOrWhiteSpace(HEALTHCHECK_API_KEY) || !string.Equals(extractedApiKey.ToString(), HEALTHCHECK_API_KEY, StringComparison.Ordinal)) { context.Result = new ContentResult { diff --git a/srcs/PhoenixLib.Auth.JWT/DependencyInjectionExtensions.cs b/srcs/PhoenixLib.Auth.JWT/DependencyInjectionExtensions.cs index 5e70d6a..8cc8990 100644 --- a/srcs/PhoenixLib.Auth.JWT/DependencyInjectionExtensions.cs +++ b/srcs/PhoenixLib.Auth.JWT/DependencyInjectionExtensions.cs @@ -8,7 +8,13 @@ namespace PhoenixLib.Auth.JWT { public static void AddJwtFactoryFromEnv(this IServiceCollection services) { - services.TryAddSingleton(new JwtTokenFactory(Environment.GetEnvironmentVariable("JWT_PRIVATE_KEY"))); + string jwtPrivateKey = Environment.GetEnvironmentVariable("JWT_PRIVATE_KEY"); + if (string.IsNullOrWhiteSpace(jwtPrivateKey)) + { + throw new InvalidOperationException("JWT_PRIVATE_KEY environment variable is required"); + } + + services.TryAddSingleton(new JwtTokenFactory(jwtPrivateKey)); } } } \ No newline at end of file diff --git a/srcs/PhoenixLib.DAL.EFCore.PGSQL/PgSqlDatabaseConfiguration.cs b/srcs/PhoenixLib.DAL.EFCore.PGSQL/PgSqlDatabaseConfiguration.cs index a0288f8..759b25a 100644 --- a/srcs/PhoenixLib.DAL.EFCore.PGSQL/PgSqlDatabaseConfiguration.cs +++ b/srcs/PhoenixLib.DAL.EFCore.PGSQL/PgSqlDatabaseConfiguration.cs @@ -29,7 +29,7 @@ namespace PhoenixLib.DAL.EFCore.PGSQL string ip = Environment.GetEnvironmentVariable("POSTGRES_DATABASE_IP") ?? "localhost"; string username = Environment.GetEnvironmentVariable("POSTGRES_DATABASE_USER") ?? "postgres"; string password = Environment.GetEnvironmentVariable("POSTGRES_DATABASE_PASSWORD") ?? "postgres"; - string database = Environment.GetEnvironmentVariable("POSTGRES_DATABASE_NAME") ?? "posgtres"; + string database = Environment.GetEnvironmentVariable("POSTGRES_DATABASE_NAME") ?? "postgres"; if (!ushort.TryParse(Environment.GetEnvironmentVariable("POSTGRES_DATABASE_PORT") ?? "5432", out ushort port)) { port = 5432; diff --git a/srcs/_plugins/Plugin.DB.EF/DB/DatabaseConfiguration.cs b/srcs/_plugins/Plugin.DB.EF/DB/DatabaseConfiguration.cs index 2bacf0d..075469d 100644 --- a/srcs/_plugins/Plugin.DB.EF/DB/DatabaseConfiguration.cs +++ b/srcs/_plugins/Plugin.DB.EF/DB/DatabaseConfiguration.cs @@ -12,7 +12,8 @@ namespace Plugin.Database.DB { Ip = Environment.GetEnvironmentVariable("DATABASE_IP") ?? "localhost"; Username = Environment.GetEnvironmentVariable("DATABASE_USER") ?? "postgres"; - Password = Environment.GetEnvironmentVariable("DATABASE_PASSWORD") ?? "VaNOSilla2022"; + Password = Environment.GetEnvironmentVariable("DATABASE_PASSWORD") + ?? throw new InvalidOperationException("DATABASE_PASSWORD environment variable is required"); Database = Environment.GetEnvironmentVariable("DATABASE_NAME") ?? "game"; WriteBufferSize = Convert.ToInt32(Environment.GetEnvironmentVariable("DATABASE_WRITE_BUFFER_SIZE") ?? "8192"); ReadBufferSize = Convert.ToInt32(Environment.GetEnvironmentVariable("DATABASE_READ_BUFFER_SIZE") ?? "8192");