AppSetting.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 EncryptionSection Encryption { get; init; } = new();
  13. public sealed class AppSection
  14. {
  15. public string Name { get; init; } = string.Empty;
  16. public string Company { get; init; } = string.Empty;
  17. public string BaseURL { get; init; } = string.Empty;
  18. public string ApiURL { get; init; } = string.Empty;
  19. public string FrontURL { get; init; } = string.Empty;
  20. }
  21. public sealed class ConnectionStringsSection
  22. {
  23. public string DefaultConnection { get; init; } = string.Empty;
  24. public int Timeout { get; init; }
  25. }
  26. public class RedisSection
  27. {
  28. public string DefaultConnection { get; init; } = string.Empty;
  29. public string CachePrefix { get; init; } = string.Empty;
  30. public string AuthTicketPrefix { get; init; } = string.Empty;
  31. public string DataProtectionKey { get; init; } = string.Empty;
  32. public TimeSpan DefaultKeyLifetime { get; init; }
  33. }
  34. public class SmtpSection
  35. {
  36. public string Host { get; init; } = default!;
  37. public int Port { get; init; } = 587;
  38. public string? User { get; init; }
  39. public string? Password { get; init; }
  40. public bool UseStartTls { get; init; } = true;
  41. public string FromEmail { get; init; } = default!;
  42. public string FromName { get; init; } = "no-reply";
  43. }
  44. public class JwtSection
  45. {
  46. public string SecretKey { get; init; } = string.Empty;
  47. public string Issuer { get; init; } = string.Empty;
  48. public string Audience { get; init; } = string.Empty;
  49. public int AccessTokenExpiration { get; init; }
  50. public int RefreshTokenExpiration { get; init; }
  51. }
  52. public class ForwardedHeadersSection
  53. {
  54. public int? ForwardLimit { get; init; } = default;
  55. public List<string> KnownProxies { get; init; } = [];
  56. public List<string> KnownNetworks { get; init; } = [];
  57. }
  58. public class CorsPolicySection
  59. {
  60. public string Name { get; init; } = string.Empty;
  61. public long PreflightMaxAgeSeconds { get; init; } = 0;
  62. public List<string> AllowedOrigins { get; init; } = [];
  63. }
  64. /// <summary>
  65. /// 필드 단위 암호화(AES-256-GCM) 키 설정.
  66. /// Keys 딕셔너리는 "V{int}" -> Base64(32바이트) 매핑. CurrentKeyVersion 은 신규 암호화에 사용할 버전.
  67. /// 키 회전 시 Keys 에 새 버전 추가 + CurrentKeyVersion 갱신. 복호화는 저장된 KeyVersion 으로 과거 키 매핑.
  68. /// 실제 키 값은 커밋 금지 — user-secrets/환경변수/로컬 설정으로 주입.
  69. /// </summary>
  70. public class EncryptionSection
  71. {
  72. public int CurrentKeyVersion { get; init; } = 1;
  73. public Dictionary<string, string> Keys { get; init; } = new();
  74. }
  75. }
  76. }