Compare commits

...
Author SHA1 Message Date
f316c4eb50
postit: ignore runtime status in settings json
All checks were successful
Dotnet build and test / build (pull_request) Successful in 5m17s
2026-09-06 16:24:46 +01:00
5fc99d73b0
postit: harden oidc settings defaults on startup 2026-09-06 16:20:17 +01:00

View file

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Text.Json;
using System.Text.Json.Serialization;
[assembly: InternalsVisibleTo("PostIt.Tests")]
@ -32,6 +33,7 @@ public partial class Settings : ViewModelBase
public partial string SearchText { get; set; } = string.Empty;
[ObservableProperty]
[JsonIgnore]
public partial StatusNotice ActionStatus { get; set; } = StatusNotice.Info("Pret.");
public void SetActionStatus(string message, StatusSeverity severity = StatusSeverity.Info)
@ -123,6 +125,8 @@ public partial class Settings : ViewModelBase
// build options from a torn read.
lock (_mutationGate)
{
EnsureAuthenticationDefaultsLocked();
var options = new OidcClientOptions
{
Authority = Authentication.Authority,
@ -151,6 +155,25 @@ public partial class Settings : ViewModelBase
}
}
private void EnsureAuthenticationDefaultsLocked()
{
Authentication ??= new AuthenticationSettings();
if (string.IsNullOrWhiteSpace(Authentication.Authority))
Authentication.Authority = AuthenticationSettings.DefaultAuthority;
if (string.IsNullOrWhiteSpace(Authentication.ClientId))
Authentication.ClientId = AuthenticationSettings.DefaultClientId;
if (string.IsNullOrWhiteSpace(Authentication.RedirectUri))
Authentication.RedirectUri = AuthenticationSettings.DesktopRedirectUri;
if (Authentication.Scopes is null || Authentication.Scopes.Length == 0)
Authentication.Scopes = AuthenticationSettings.DefaultScopes;
Authentication.RefreshScopeListText();
}
/// <summary>
/// Scopes the PostIt client always requires from the OIDC provider,
/// regardless of what the user has in their settings file.
@ -334,11 +357,13 @@ public partial class Settings : ViewModelBase
AuthenticationSettings.DesktopRedirectUri : settings.Authentication.RedirectUri;
if (settings.Authentication.Scopes is null || settings.Authentication.Scopes.Length == 0)
{
settings.Authentication.Scopes = AuthenticationSettings.DefaultScopes;
this.Authentication.Scopes = AuthenticationSettings.DefaultScopes;
}
else
this.Authentication.Scopes = settings.Authentication.Scopes;
}
EnsureAuthenticationDefaultsLocked();
}
// A disk load (or an embedded-resource fallback) is the
// baseline, not a user edit. Clear the dirty flag last