- BaronSSO.SignOutAsync: id_token_hint 기반 end_session 로그아웃 + 로컬 세션 정리 - SsoClient.LogoutAsync: end_session_endpoint 이동 후 post_logout 복귀를 WebView에서 가로채기 - BaronSSOOption.PostLogoutRedirectUri 추가 - LoginWindow: 쿠키 삭제를 ClearBrowsingDataAsync(완료 대기)로 변경해 재로그인 자동 SSO 통과 방지 - UserInfo: IsFamily/IsCenter 대소문자 무시 비교를 StringComparer로 수정(빌드 오류 해소) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
80 lines
2.6 KiB
C#
80 lines
2.6 KiB
C#
using BaronSoftware;
|
|
using BaronSoftware.Auth;
|
|
using BaronSoftware.SSO;
|
|
using BaronSoftware.SSO.Sample;
|
|
using System;
|
|
using System.IO;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace BaronSoftware.Auth.Sample
|
|
{
|
|
/// <summary>
|
|
/// 실행 파일과 같은 폴더의 appsettings.json에서 접속 정보를 읽는다.
|
|
/// 파일이 없으면 내장 기본값을 사용하고, JSON 형식 오류는 예외로 알린다.
|
|
/// </summary>
|
|
public sealed class SampleSettings
|
|
{
|
|
public const string FileName = "appsettings.json";
|
|
|
|
public OidcSection Oidc { get; set; } = new();
|
|
|
|
public sealed class OidcSection
|
|
{
|
|
public string Authority { get; set; }
|
|
public string ClientId { get; set; }
|
|
public string RedirectUri { get; set; }
|
|
public string LogoutUri { get; set; }
|
|
public string Scope { get; set; }
|
|
}
|
|
|
|
private static readonly JsonSerializerOptions JsonOptions = new()
|
|
{
|
|
PropertyNameCaseInsensitive = true,
|
|
ReadCommentHandling = JsonCommentHandling.Skip,
|
|
AllowTrailingCommas = true,
|
|
};
|
|
|
|
/// <summary>실행 파일 옆 appsettings.json을 로드. 파일이 없으면 기본값.</summary>
|
|
public static SampleSettings Load()
|
|
{
|
|
var path = Path.Combine(AppContext.BaseDirectory, FileName);
|
|
if (!File.Exists(path))
|
|
return new SampleSettings();
|
|
|
|
try
|
|
{
|
|
var json = File.ReadAllText(path);
|
|
return JsonSerializer.Deserialize<SampleSettings>(json, JsonOptions) ?? new SampleSettings();
|
|
}
|
|
catch (JsonException ex)
|
|
{
|
|
throw new InvalidOperationException(
|
|
$"설정 파일({FileName}) 형식 오류: {ex.Message}", ex);
|
|
}
|
|
}
|
|
|
|
|
|
private static readonly JsonSerializerOptions SaveOptions = new()
|
|
{
|
|
WriteIndented = true,
|
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
|
};
|
|
|
|
/// <summary>현재 설정을 실행 파일 옆 appsettings.json에 저장한다.</summary>
|
|
public void Save()
|
|
{
|
|
var path = Path.Combine(AppContext.BaseDirectory, FileName);
|
|
File.WriteAllText(path, JsonSerializer.Serialize(this, SaveOptions));
|
|
}
|
|
|
|
public BaronSSOOption ToOidcOptions() => new()
|
|
{
|
|
Authority = Oidc.Authority,
|
|
ClientId = Oidc.ClientId,
|
|
RedirectUri = Oidc.RedirectUri,
|
|
Validator = new SimpleUserValidator()
|
|
};
|
|
}
|
|
}
|