using System.Collections.Generic; namespace StellaOps.Notify.WebService.Options; /// /// Strongly typed configuration for the Notify WebService host. /// public sealed class NotifyWebServiceOptions { public const string SectionName = "notify"; /// /// Schema version that downstream consumers can use to detect breaking changes. /// public int SchemaVersion { get; set; } = 1; /// /// Authority / authentication configuration. /// public AuthorityOptions Authority { get; set; } = new(); /// /// Mongo storage configuration for configuration state and audit logs. /// public StorageOptions Storage { get; set; } = new(); /// /// Plug-in loader configuration. /// public PluginOptions Plugins { get; set; } = new(); /// /// HTTP API behaviour. /// public ApiOptions Api { get; set; } = new(); /// /// Telemetry configuration toggles. /// public TelemetryOptions Telemetry { get; set; } = new(); public sealed class AuthorityOptions { public bool Enabled { get; set; } = true; public bool AllowAnonymousFallback { get; set; } public string Issuer { get; set; } = "https://authority.local"; public string? MetadataAddress { get; set; } public bool RequireHttpsMetadata { get; set; } = true; public int BackchannelTimeoutSeconds { get; set; } = 30; public int TokenClockSkewSeconds { get; set; } = 60; public IList Audiences { get; set; } = new List { "notify" }; public string ReadScope { get; set; } = "notify.read"; public string AdminScope { get; set; } = "notify.admin"; /// /// Optional development signing key for symmetric JWT validation when Authority is disabled. /// public string? DevelopmentSigningKey { get; set; } } public sealed class StorageOptions { public string Driver { get; set; } = "mongo"; public string ConnectionString { get; set; } = string.Empty; public string Database { get; set; } = "notify"; public int CommandTimeoutSeconds { get; set; } = 30; } public sealed class PluginOptions { public string? BaseDirectory { get; set; } public string? Directory { get; set; } public IList SearchPatterns { get; set; } = new List(); public IList OrderedPlugins { get; set; } = new List(); } public sealed class ApiOptions { public string BasePath { get; set; } = "/api/v1/notify"; public string InternalBasePath { get; set; } = "/internal/notify"; public string TenantHeader { get; set; } = "X-StellaOps-Tenant"; public RateLimitOptions RateLimits { get; set; } = new(); } public sealed class RateLimitOptions { public RateLimitPolicyOptions DeliveryHistory { get; set; } = RateLimitPolicyOptions.CreateDefault( tokenLimit: 60, tokensPerPeriod: 30, replenishmentPeriodSeconds: 60, queueLimit: 20); public RateLimitPolicyOptions TestSend { get; set; } = RateLimitPolicyOptions.CreateDefault( tokenLimit: 5, tokensPerPeriod: 5, replenishmentPeriodSeconds: 60, queueLimit: 2); } public sealed class RateLimitPolicyOptions { public bool Enabled { get; set; } = true; public int TokenLimit { get; set; } = 10; public int TokensPerPeriod { get; set; } = 10; public int ReplenishmentPeriodSeconds { get; set; } = 60; public int QueueLimit { get; set; } = 0; public static RateLimitPolicyOptions CreateDefault(int tokenLimit, int tokensPerPeriod, int replenishmentPeriodSeconds, int queueLimit) { return new RateLimitPolicyOptions { TokenLimit = tokenLimit, TokensPerPeriod = tokensPerPeriod, ReplenishmentPeriodSeconds = replenishmentPeriodSeconds, QueueLimit = queueLimit }; } } public sealed class TelemetryOptions { public bool EnableRequestLogging { get; set; } = true; public string MinimumLogLevel { get; set; } = "Information"; } }