Implement alpha foundation workflow and GitHub sync
This commit is contained in:
parent
5d62ea2df4
commit
3fd655e1f2
37 changed files with 7352 additions and 365 deletions
|
|
@ -0,0 +1,56 @@
|
|||
using Bifrost.Web.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Bifrost.Web.Features.Shared;
|
||||
|
||||
public sealed class StartupConfigurationValidator(
|
||||
IConfiguration configuration,
|
||||
IHostEnvironment hostEnvironment,
|
||||
IOptions<GitHubOAuthOptions> gitHubOAuthOptions,
|
||||
IOptions<GitHubAppOptions> gitHubAppOptions,
|
||||
IOptions<BifrostHostOptions> hostOptions)
|
||||
{
|
||||
public void Validate()
|
||||
{
|
||||
if (hostEnvironment.IsDevelopment() || hostEnvironment.IsEnvironment("Testing"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var failures = new List<string>();
|
||||
|
||||
if (!gitHubOAuthOptions.Value.IsConfigured)
|
||||
{
|
||||
failures.Add("GitHub OAuth client configuration is required outside development.");
|
||||
}
|
||||
|
||||
if (gitHubAppOptions.Value.EnableWebhookSync && !gitHubAppOptions.Value.IsConfigured)
|
||||
{
|
||||
failures.Add("GitHub App configuration is required when webhook sync is enabled.");
|
||||
}
|
||||
|
||||
if (!hostOptions.Value.IsConfigured)
|
||||
{
|
||||
failures.Add("Host:PublicBaseUrl and Host:ExpectedHost must be configured.");
|
||||
}
|
||||
|
||||
var allowedHosts = configuration["AllowedHosts"] ?? string.Empty;
|
||||
if (hostOptions.Value.RequireStrictHostValidation &&
|
||||
(string.IsNullOrWhiteSpace(allowedHosts) || allowedHosts.Contains('*')))
|
||||
{
|
||||
failures.Add("AllowedHosts must be explicitly configured for production.");
|
||||
}
|
||||
|
||||
var connectionString = configuration.GetConnectionString("Bifrost");
|
||||
if (string.IsNullOrWhiteSpace(connectionString))
|
||||
{
|
||||
failures.Add("Connection string 'Bifrost' must be configured.");
|
||||
}
|
||||
|
||||
if (failures.Count > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Bifrost startup configuration is incomplete: " + string.Join(" ", failures));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue