mirror of
https://github.com/azaion/missions.git
synced 2026-06-21 11:01:07 +00:00
2840ccb9b6
ci/woodpecker/push/build-arm Pipeline was successful
This commit transitions the project from Azaion.Flights to Azaion.Missions, updating namespaces, DTOs, services, and database entities accordingly. The Docker configuration and entry points have been modified to reflect the new project structure. Additionally, the README and documentation have been updated to clarify the ongoing renaming process and its implications. All references to flights have been replaced with missions, ensuring consistency across the codebase.
42 lines
1.7 KiB
C#
42 lines
1.7 KiB
C#
namespace Azaion.Missions.Infrastructure;
|
|
|
|
public static class CorsConfigurationValidator
|
|
{
|
|
public const string MissingOriginsMessage =
|
|
"CORS is misconfigured: CorsConfig:AllowedOrigins is empty and CorsConfig:AllowAnyOrigin is not true. " +
|
|
"Refusing to start in Production with a permissive CORS policy. " +
|
|
"Set CorsConfig:AllowedOrigins to a non-empty array, or set CorsConfig:AllowAnyOrigin=true to opt in.";
|
|
|
|
public const string PermissiveDefaultWarning =
|
|
"CorsConfig:AllowedOrigins is empty and CorsConfig:AllowAnyOrigin is not true. " +
|
|
"Permissive CORS is being applied for environment {Environment}; do not run with this configuration in Production.";
|
|
|
|
public static void EnsureSafeForEnvironment(
|
|
string[] allowedOrigins,
|
|
bool allowAnyOrigin,
|
|
string environmentName)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(allowedOrigins);
|
|
ArgumentNullException.ThrowIfNull(environmentName);
|
|
|
|
if (allowedOrigins.Length == 0
|
|
&& !allowAnyOrigin
|
|
&& string.Equals(environmentName, "Production", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
throw new InvalidOperationException(MissingOriginsMessage);
|
|
}
|
|
}
|
|
|
|
public static bool ShouldUsePermissivePolicy(string[] allowedOrigins, bool allowAnyOrigin)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(allowedOrigins);
|
|
return allowAnyOrigin || allowedOrigins.Length == 0;
|
|
}
|
|
|
|
public static bool ShouldWarnAboutPermissiveDefault(string[] allowedOrigins, bool allowAnyOrigin)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(allowedOrigins);
|
|
return allowedOrigins.Length == 0 && !allowAnyOrigin;
|
|
}
|
|
}
|