AppSetting.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. namespace SharedKernel
  2. {
  3. public sealed class AppSettings
  4. {
  5. public AppSection App { get; init; } = new();
  6. public ConnectionStringsSection ConnectionStrings { get; init; } = new();
  7. public RedisSection Redis { get; init; } = new();
  8. public SmtpSection SMTP { get; init; } = new();
  9. public JwtSection JWT { get; init; } = new();
  10. public ForwardedHeadersSection ForwardedHeaders { get; init; } = new();
  11. public CorsPolicySection CorsPolicy { get; init; } = new();
  12. public sealed class AppSection
  13. {
  14. public string Name { get; init; } = string.Empty;
  15. public string Company { get; init; } = string.Empty;
  16. public string BaseURL { get; init; } = string.Empty;
  17. public string ApiURL { get; init; } = string.Empty;
  18. public string FrontURL { get; init; } = string.Empty;
  19. }
  20. public sealed class ConnectionStringsSection
  21. {
  22. public string DefaultConnection { get; init; } = string.Empty;
  23. public int Timeout { get; init; }
  24. }
  25. public class RedisSection
  26. {
  27. public string DefaultConnection { get; init; } = string.Empty;
  28. public string CachePrefix { get; init; } = string.Empty;
  29. public string AuthTicketPrefix { get; init; } = string.Empty;
  30. public string DataProtectionKey { get; init; } = string.Empty;
  31. public TimeSpan DefaultKeyLifetime { get; init; }
  32. }
  33. public class SmtpSection
  34. {
  35. public string Host { get; init; } = default!;
  36. public int Port { get; init; } = 587;
  37. public string? User { get; init; }
  38. public string? Password { get; init; }
  39. public bool UseStartTls { get; init; } = true;
  40. public string FromEmail { get; init; } = default!;
  41. public string FromName { get; init; } = "no-reply";
  42. }
  43. public class JwtSection
  44. {
  45. public string SecretKey { get; init; } = string.Empty;
  46. public string Issuer { get; init; } = string.Empty;
  47. public string Audience { get; init; } = string.Empty;
  48. public int AccessTokenExpiration { get; init; }
  49. public int RefreshTokenExpiration { get; init; }
  50. }
  51. public class ForwardedHeadersSection
  52. {
  53. public int? ForwardLimit { get; init; } = default;
  54. public List<string> KnownProxies { get; init; } = [];
  55. public List<string> KnownNetworks { get; init; } = [];
  56. }
  57. public class CorsPolicySection
  58. {
  59. public string Name { get; init; } = string.Empty;
  60. public long PreflightMaxAgeSeconds { get; init; } = 0;
  61. public List<string> AllowedOrigins { get; init; } = [];
  62. }
  63. }
  64. }