사용자 검증기 구조 분리: 내부(Family) / 외부(Extra) 검증 구분
- IUserValidator.Validate: bool 반환 → void (인증 실패 시 예외로 처리) - BaronSSOOption: Validator → ExtraUserValidator로 명명, FamilyValidator(기본 DefaultFamilyUserValidator) 추가 - DefaultFamilyUserValidator 신규: Center/Family 테넌트 사용자 통과, 그 외 InvalidUserException - BaronSSO.SignInAsync: Family/Extra 검증기 적용 흐름 정리 - InvalidUserException: UserInfo 기반 생성자 - Sample(MainWindow/SampleSettings/SimpleUserValidator) 갱신 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
using BaronSoftware;
|
||||
using BaronSoftware.Auth;
|
||||
using BaronSoftware.Auth.Sample;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace BaronSoftware.SSO.Sample
|
||||
@@ -23,11 +19,22 @@ namespace BaronSoftware.SSO.Sample
|
||||
InitializeComponent();
|
||||
|
||||
_settings = SampleSettings.Load();
|
||||
ApplySettings();
|
||||
}
|
||||
|
||||
/// <summary>현재 설정으로 SSO 클라이언트를 (재)생성한다.</summary>
|
||||
private void ApplySettings() => _license = new BaronSSO(_settings.ToOidcOptions());
|
||||
var option = new BaronSSOOption()
|
||||
{
|
||||
Authority = _settings.Oidc.Authority,
|
||||
ClientId = _settings.Oidc.ClientId,
|
||||
RedirectUri = _settings.Oidc.RedirectUri,
|
||||
ExtraUserValidator = new SimpleUserValidator()
|
||||
};
|
||||
|
||||
_license = new BaronSSO(option);
|
||||
LoginButton.Click += async (s,e) => await RunLogin("웹뷰 로그인", () => _license.SignInAsync());
|
||||
TokenLoginBuggon.Click += async (s,e) => await RunLogin("토큰 로그인", () => _license.SignInAsync(_license.CurrentUser.RefreshToken));
|
||||
SettingsButton.Click += SettingsButton_Click;
|
||||
LogoutButton.Click += LogoutButton_Click;
|
||||
|
||||
}
|
||||
|
||||
private void SettingsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -41,10 +48,21 @@ namespace BaronSoftware.SSO.Sample
|
||||
_settings.Oidc.ClientId = dlg.ClientId;
|
||||
_settings.Oidc.RedirectUri = dlg.RedirectUri;
|
||||
_settings.Oidc.LogoutUri = dlg.LogoutUri;
|
||||
|
||||
try
|
||||
{
|
||||
_settings.Save();
|
||||
ApplySettings();
|
||||
|
||||
var option = new BaronSSOOption()
|
||||
{
|
||||
Authority = _settings.Oidc.Authority,
|
||||
ClientId = _settings.Oidc.ClientId,
|
||||
RedirectUri = _settings.Oidc.RedirectUri,
|
||||
ExtraUserValidator = new SimpleUserValidator()
|
||||
};
|
||||
|
||||
_license = new BaronSSO(option);
|
||||
|
||||
OutputBox.Text =
|
||||
"설정 저장 완료 ✔ (appsettings.json)\n\n" +
|
||||
$"Authority : {_settings.Oidc.Authority}\n" +
|
||||
@@ -59,8 +77,6 @@ namespace BaronSoftware.SSO.Sample
|
||||
}
|
||||
}
|
||||
|
||||
private async void LoginButton_Click(object sender, RoutedEventArgs e)
|
||||
=> await RunAsync("웹뷰 로그인", () => _license.SignInAsync());
|
||||
|
||||
private async void LogoutButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -80,7 +96,7 @@ namespace BaronSoftware.SSO.Sample
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RunAsync(string action, Func<Task> work)
|
||||
private async Task RunLogin(string action, Func<Task> work)
|
||||
{
|
||||
SetBusy(true);
|
||||
OutputBox.Text = $"{action} 진행 중...";
|
||||
@@ -88,7 +104,7 @@ namespace BaronSoftware.SSO.Sample
|
||||
{
|
||||
await work();
|
||||
OutputBox.Text = $"{action} 완료 ✔\n\n";
|
||||
OutputBox.Text += Format(_license.CurrentUser);
|
||||
OutputBox.Text += ShowLoginUserInfo(_license.CurrentUser);
|
||||
OutputBox.CaretIndex = 0; // 맨 위(요약)부터 보이도록
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
@@ -105,10 +121,10 @@ namespace BaronSoftware.SSO.Sample
|
||||
}
|
||||
}
|
||||
|
||||
private void SetBusy(bool busy)
|
||||
=> LoginButton.IsEnabled = LogoutButton.IsEnabled = !busy;
|
||||
private void SetBusy(bool busy)=> LoginButton.IsEnabled = LogoutButton.IsEnabled = !busy;
|
||||
|
||||
private string Format(UserInfo u)
|
||||
// For Display=============
|
||||
private string ShowLoginUserInfo(UserInfo u)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("로그인 성공 ✔");
|
||||
@@ -150,6 +166,9 @@ namespace BaronSoftware.SSO.Sample
|
||||
catch { return json; }
|
||||
}
|
||||
|
||||
private async void TokenLoginBuggon_Click(object sender, RoutedEventArgs e) => await RunAsync("토큰 로그인", () => _license.SignInAsync(_license.CurrentUser.RefreshToken));
|
||||
// ================
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user