diff --git a/BaronSoftware.SSO/Features/LoginWindow/LoginWindow.xaml.cs b/BaronSoftware.SSO/Features/LoginWindow/LoginWindow.xaml.cs index a4667f4..0c50f94 100644 --- a/BaronSoftware.SSO/Features/LoginWindow/LoginWindow.xaml.cs +++ b/BaronSoftware.SSO/Features/LoginWindow/LoginWindow.xaml.cs @@ -1,4 +1,5 @@ using Microsoft.Web.WebView2.Core; +using System.IO; using System.Threading; using System.Windows; using System.Windows.Threading; @@ -29,7 +30,7 @@ namespace BaronSoftware.SSO { try { - await webview.EnsureCoreWebView2Async(); + await webview.EnsureCoreWebView2Async(await CreateWebView2EnvironmentAsync()); webview.CoreWebView2.NavigationStarting += OnNavigationStarting; webview.CoreWebView2.Navigate(_authorizeUrl); } @@ -95,7 +96,7 @@ namespace BaronSoftware.SSO holder.Show(); // WebView2 초기화에 필요한 HWND 확보(화면 밖) try { - await web.EnsureCoreWebView2Async(); + await web.EnsureCoreWebView2Async(await CreateWebView2EnvironmentAsync()); // DeleteAllCookies()는 즉시 반환이라, 디스크 반영 전에 Dispose되면 쿠키가 남아 // 다음 로그인이 SSO로 조용히 통과될 수 있다. 완료까지 await하는 ClearBrowsingDataAsync로 // SSO 세션 쿠키/사이트 데이터를 확실히 제거한다. @@ -148,7 +149,7 @@ namespace BaronSoftware.SSO try { - await web.EnsureCoreWebView2Async(); + await web.EnsureCoreWebView2Async(await CreateWebView2EnvironmentAsync()); web.CoreWebView2.NavigationStarting += OnNavStarting; web.CoreWebView2.Navigate(endSessionUrl); @@ -166,6 +167,12 @@ namespace BaronSoftware.SSO } }); + private static Task CreateWebView2EnvironmentAsync() + { + var userDataFolder = Path.Combine(Path.GetTempPath(), "BaronSSO", "WebView2"); + return CoreWebView2Environment.CreateAsync(userDataFolder: userDataFolder); + } + /// /// 호출 스레드(MTA/STA)와 무관하게, 전용 STA 스레드에서 자체 Dispatcher 메시지펌프를 돌려 /// WPF/WebView2 UI 작업을 실행하고 그 결과를 Task로 반환한다.