AppSetting.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. namespace SharedKernel;
  2. public sealed class AppSettings
  3. {
  4. public AppSection App { get; init; } = new();
  5. public ConnectionStringsSection ConnectionStrings { get; init; } = new();
  6. public RedisSection Redis { get; init; } = new();
  7. public SmtpSection SMTP { get; init; } = new();
  8. public JwtSection JWT { get; init; } = new();
  9. public ForwardedHeadersSection ForwardedHeaders { get; init; } = new();
  10. public CorsPolicySection CorsPolicy { get; init; } = new();
  11. public YouTubeSection YouTube { get; init; } = new();
  12. public BackgroundJobsSection BackgroundJobs { get; init; } = new();
  13. public EncryptionSection Encryption { get; init; } = new();
  14. public FeaturesSection Features { get; init; } = new();
  15. public StockDataSection StockData { get; init; } = new();
  16. public KRXCoKrSection KRXCoKr { get; init; } = new();
  17. public OAuthSection OAuth { get; init; } = new();
  18. public sealed class AppSection
  19. {
  20. public string Name { get; init; } = string.Empty;
  21. public string Company { get; init; } = string.Empty;
  22. public string BaseURL { get; init; } = string.Empty;
  23. public string ApiURL { get; init; } = string.Empty;
  24. public string FrontURL { get; init; } = string.Empty;
  25. }
  26. public sealed class ConnectionStringsSection
  27. {
  28. public string DefaultConnection { get; init; } = string.Empty;
  29. public int Timeout { get; init; }
  30. }
  31. public class RedisSection
  32. {
  33. public string DefaultConnection { get; init; } = string.Empty;
  34. public string CachePrefix { get; init; } = string.Empty;
  35. public string AuthTicketPrefix { get; init; } = string.Empty;
  36. public string DataProtectionKey { get; init; } = string.Empty;
  37. public TimeSpan DefaultKeyLifetime { get; init; }
  38. }
  39. public class SmtpSection
  40. {
  41. public string Host { get; init; } = default!;
  42. public int Port { get; init; } = 587;
  43. public string? User { get; init; }
  44. public string? Password { get; init; }
  45. public bool UseStartTls { get; init; } = true;
  46. public string FromEmail { get; init; } = default!;
  47. public string FromName { get; init; } = "no-reply";
  48. }
  49. public class JwtSection
  50. {
  51. public string SecretKey { get; init; } = string.Empty;
  52. public string Issuer { get; init; } = string.Empty;
  53. public string Audience { get; init; } = string.Empty;
  54. public int AccessTokenExpiration { get; init; }
  55. public int RefreshTokenExpiration { get; init; }
  56. }
  57. public class ForwardedHeadersSection
  58. {
  59. public int? ForwardLimit { get; init; } = default;
  60. public List<string> KnownProxies { get; init; } = [];
  61. public List<string> KnownNetworks { get; init; } = [];
  62. }
  63. public class CorsPolicySection
  64. {
  65. public string Name { get; init; } = string.Empty;
  66. public long PreflightMaxAgeSeconds { get; init; } = 0;
  67. public List<string> AllowedOrigins { get; init; } = [];
  68. }
  69. public class YouTubeSection
  70. {
  71. public string HubUrl { get; init; } = "https://pubsubhubbub.appspot.com/subscribe";
  72. public string CallbackUrl { get; init; } = string.Empty;
  73. public string HmacSecret { get; init; } = string.Empty;
  74. public int FeedPollingIntervalMinutes { get; init; } = 3;
  75. }
  76. public class BackgroundJobsSection
  77. {
  78. public bool LiveChat { get; init; } = true;
  79. public bool PubSubRenewal { get; init; } = true;
  80. public bool FeedPolling { get; init; } = true;
  81. public bool LiveViewerPoller { get; init; } = true;
  82. public bool ChannelCacheRefresh { get; init; } = true;
  83. public bool YouTubeDailyAggregator { get; init; } = true;
  84. public bool YouTubeStaleDataPurge { get; init; } = true;
  85. /// <summary>결제 자동 대사 배치 (Toss NeedsReconciliation 재확인 — PaymentReconcileService). Features:Channel 게이트와 무관.</summary>
  86. public bool PaymentReconcile { get; init; } = true;
  87. /// <summary>모의투자 체결·스냅샷 배치 (PaperFillService — d4 M2). Features:Channel 게이트와 무관, 기본 false (StockData 적재 가동 후 활성화).</summary>
  88. public bool PaperFill { get; init; } = false;
  89. /// <summary>예측 채점 배치 (PredictionSettlementService — d2 M4). Web.Api 전용, 기본 false (StockData T+1 종가 적재 가동 후 활성화).</summary>
  90. public bool PredictionSettlement { get; init; } = false;
  91. }
  92. /// <summary>
  93. /// 기능 단위 활성화 플래그. 코드/스키마는 보존하고 노출만 차단하는 soft-off 스위치.
  94. /// Channel=false 시 채널/스튜디오/YouTube 관련 API 와 백그라운드 서비스 전체 비활성 (기본 false).
  95. /// </summary>
  96. public class FeaturesSection
  97. {
  98. public bool Channel { get; init; } = false;
  99. }
  100. /// <summary>
  101. /// 회원 PII(주소/연락처 등) 필드 암호화에 사용하는 AES-GCM 키 묶음.
  102. /// Keys 딕셔너리는 KeyVersion -> Base64(32바이트) 매핑. CurrentKeyVersion 은 신규 암호화에 사용할 버전.
  103. /// 키 회전 시 Keys 에 새 버전 추가 + CurrentKeyVersion 갱신. 복호화는 row 의 KeyVersion 컬럼으로 매핑하여 과거 키 사용.
  104. /// </summary>
  105. public class EncryptionSection
  106. {
  107. public int CurrentKeyVersion { get; init; } = 1;
  108. public Dictionary<string, string> Keys { get; init; } = new();
  109. }
  110. /// <summary>
  111. /// 소셜 로그인 OAuth 설정 (개미투자 D5 — Naver/Kakao). 키는 각 개발자센터 발급 후 채움 (빈 값이면 해당 provider 로그인 비활성).
  112. /// Google 은 DB Config(External.GoogleClientId) 현행 유지 — 여기 포함하지 않는다.
  113. /// </summary>
  114. public class OAuthSection
  115. {
  116. public OAuthProviderSection Naver { get; init; } = new();
  117. public OAuthProviderSection Kakao { get; init; } = new();
  118. public class OAuthProviderSection
  119. {
  120. /// <summary>네이버: Client ID / 카카오: REST API 키</summary>
  121. public string ClientId { get; init; } = string.Empty;
  122. /// <summary>네이버: Client Secret(필수) / 카카오: 콘솔에서 활성화한 경우만 (빈 값이면 미전송)</summary>
  123. public string ClientSecret { get; init; } = string.Empty;
  124. /// <summary>기본 redirect URI — 요청에서 미전달 시 사용. 개발자센터에 등록한 값과 일치해야 함</summary>
  125. public string RedirectUri { get; init; } = string.Empty;
  126. /// <summary>
  127. /// 카카오 Admin 키 — "연결 끊기(unlink)" webhook 요청의 Authorization 헤더 대조에 사용.
  128. /// 카카오 개발자콘솔의 앱 Admin 키를 그대로 넣는다 (빈 값이면 disconnect 검증 비활성 → 항상 거부).
  129. /// 네이버는 사용하지 않음.
  130. /// </summary>
  131. public string AdminKey { get; init; } = string.Empty;
  132. }
  133. }
  134. /// <summary>
  135. /// 주식 데이터 수집 배치 설정 (개미투자 D1). 플래그 기본 false — API 키 발급/운영 결정 후 활성화.
  136. /// Features:Channel 게이트와 무관하게 별도 등록 (AddStockDataServices).
  137. /// </summary>
  138. public class StockDataSection
  139. {
  140. /// <summary>종목 마스터 동기화 배치 (StockMasterSyncService) 활성화</summary>
  141. public bool MasterSync { get; init; } = false;
  142. /// <summary>T+1 일별 시세 수집 배치 (DailyPriceSyncService) 활성화</summary>
  143. public bool DailyPriceSync { get; init; } = false;
  144. /// <summary>마스터 동기화 실행 시각 (KST, "HH:mm")</summary>
  145. public string MasterSyncTime { get; init; } = "07:30";
  146. /// <summary>일별 시세 수집 실행 시각 (KST, "HH:mm") — 금융위 API 는 영업일+1 13시 이후 반영</summary>
  147. public string DailyPriceSyncTime { get; init; } = "13:10";
  148. public DataGoKrSection DataGoKr { get; init; } = new();
  149. /// <summary>공공데이터포털 (data.go.kr) 금융위 API</summary>
  150. public class DataGoKrSection
  151. {
  152. /// <summary>서비스 키 (Decoding 원본 키 — 요청 시 URL 인코딩). 비어 있으면 배치는 로그만 남기고 skip.</summary>
  153. public string ServiceKey { get; init; } = string.Empty;
  154. public string BaseUrl { get; init; } = "https://apis.data.go.kr";
  155. /// <summary>페이지당 행 수 (numOfRows)</summary>
  156. public int PageSize { get; init; } = 1000;
  157. }
  158. }
  159. /// <summary>
  160. /// KRX 한국거래소 OpenAPI (data-dbg.krx.co.kr) 지수 데이터 수집 설정 (개미투자 D1).
  161. /// data.go.kr(StockDataSection)과는 별개 시스템 — 별도 API 키 + AUTH_KEY 헤더 인증.
  162. /// IndexSync 기본 false — API 키 발급/운영 결정 후 활성화. Features:Channel 게이트와 무관하게 AddStockDataServices 에서 등록.
  163. /// </summary>
  164. public class KRXCoKrSection
  165. {
  166. /// <summary>KRX OpenAPI 인증 키 (AUTH_KEY 헤더). 비어 있으면 배치는 로그만 남기고 skip. tracked 파일엔 빈 값만.</summary>
  167. public string ApiKey { get; init; } = string.Empty;
  168. public string BaseUrl { get; init; } = "https://data-dbg.krx.co.kr";
  169. /// <summary>지수 일별시세 수집 배치 (IndexPriceSyncService) 활성화</summary>
  170. public bool IndexSync { get; init; } = false;
  171. /// <summary>지수 수집 실행 시각 (KST, "HH:mm") — KRX 지수는 장 마감(15:30) 이후 확정, 여유 두고 18:30</summary>
  172. public string IndexSyncTime { get; init; } = "18:30";
  173. /// <summary>주식(종목) 마스터 + 일별매매 수집 배치 (KrxStockMasterSyncService/KrxDailyPriceSyncService) 활성화 — D1 KRX 주식 데이터 수집</summary>
  174. public bool StockSync { get; init; } = false;
  175. /// <summary>종목 마스터 동기화 실행 시각 (KST, "HH:mm") — 장 시작 전 07:40</summary>
  176. public string MasterSyncTime { get; init; } = "07:40";
  177. /// <summary>주식 일별매매 수집 실행 시각 (KST, "HH:mm") — KRX 일별매매는 장 마감(15:30) 이후 확정, 여유 두고 18:10</summary>
  178. public string StockSyncTime { get; init; } = "18:10";
  179. }
  180. }