Oakrey.Applications.Settings.Secure
8.0.0
dotnet add package Oakrey.Applications.Settings.Secure --version 8.0.0
NuGet\Install-Package Oakrey.Applications.Settings.Secure -Version 8.0.0
<PackageReference Include="Oakrey.Applications.Settings.Secure" Version="8.0.0" />
<PackageVersion Include="Oakrey.Applications.Settings.Secure" Version="8.0.0" />
<PackageReference Include="Oakrey.Applications.Settings.Secure" />
paket add Oakrey.Applications.Settings.Secure --version 8.0.0
#r "nuget: Oakrey.Applications.Settings.Secure, 8.0.0"
#:package Oakrey.Applications.Settings.Secure@8.0.0
#addin nuget:?package=Oakrey.Applications.Settings.Secure&version=8.0.0
#tool nuget:?package=Oakrey.Applications.Settings.Secure&version=8.0.0
Oakrey.Applications.Settings.Secure
Readable JSON settings support for critical application settings. It adds integrity protection, Windows-user authorization, and an audit history while keeping standard ISettingsService<T> available for regular Settings.json data.
Main features
- Separate secure file - secured settings are stored in
SecuredSettings.json; regular settings remain inSettings.json. - Readable JSON - secured values remain visible to users, but unnoticed external edits are detected.
- External change detection - the whole secured settings payload and history are signed with
HMACSHA256. - DPAPI-protected integrity key - the per-user HMAC key is encrypted at rest and legacy raw keys are migrated automatically.
- Bounded parser - secure documents are limited to 16 MiB and JSON depth 32.
- Authorized changes only - writes are allowed only when
ISecureSettingsChangeAuthorizerapproves the current Windows user. - Audit history - each persistent secured setting change stores the user, machine, application version, section, key, old value, and new value.
- Explicit API - critical settings use
ISecuredSettingsService<T>orSecuredSettingsBase; normal settings continue to useISettingsService<T>andSettingsBase.
Installation
dotnet add package Oakrey.Applications.Settings.Secure
Configuration
Register the standard and secured settings services side by side:
services
.ConfigureSettingUnderlyingServices()
.ConfigureSecureSettingService(options =>
{
options.AllowedUserNames.Add(@"DOMAIN\UserName");
options.AllowedRoles.Add(@"BUILTIN\Administrators");
});
ConfigureSettingUnderlyingServices() registers the regular ISettingsService<T> backed by Settings.json. ConfigureSecureSettingService() registers ISecuredSettingsService<T> backed by SecuredSettings.json and does not replace the regular service.
If no user or role is configured, any authenticated Windows user running the application is allowed to change secured settings.
Example usage
Regular settings can stay unchanged:
public sealed class UiSettings(ISettingsService<UiSettings> settingsService)
: SettingsBase(settingsService)
{
public string Theme
{
get => Get<string>() ?? "Dark";
set => Set(value);
}
}
Critical settings opt in to the secured service:
public sealed class CalibrationSettings(ISecuredSettingsService<CalibrationSettings> settingsService)
: SecuredSettingsBase(settingsService)
{
public double Gain
{
get => Get<double>();
set => Set(value);
}
}
File paths
By default, DefaultSecuredSettingsPathProvider stores SecuredSettings.json in the same directory as IApplicationInfo.UserSettingsPath. Applications with a different layout can replace ISecuredSettingsPathProvider.
JSON shape
The secured settings file stays readable:
{
"Version": 1,
"Settings": {
"My.Application.CalibrationSettings": {
"Gain": {
"Type": "System.Double",
"Value": 1.25
}
}
},
"History": [],
"Protection": {
"Algorithm": "HMACSHA256",
"KeyId": "LocalUserProfile:...",
"Signature": "...",
"SignedAtUtc": "2026-07-09T08:00:00+00:00"
}
}
Manual edits to Settings or History invalidate Protection.Signature; the next load throws SecureSettingsTamperException.
Integrity key
The default key provider stores the HMAC key in the current user profile protected by Windows DPAPI. Existing 64-byte raw keys are migrated in place without changing the signed settings. The legacy SecureSettings directory name is retained for storage compatibility. Applications can replace the integrity-key provider when they need a different lifecycle.
Security note
This project protects SecuredSettings.json from unnoticed external modification and enforces application-level authorization before writes. It does not make the JSON confidential; values and audit history remain readable. DPAPI protects only the HMAC integrity key.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0-windows7.0 is compatible. |
-
net11.0-windows7.0
- Microsoft.Extensions.DependencyInjection (>= 11.0.0)
- Oakrey.Applications.Abstractions (>= 8.0.0)
- Oakrey.Applications.Files (>= 8.0.0)
- Oakrey.Applications.Settings (>= 8.0.0)
- Oakrey.Log.Abstractions (>= 4.0.0)
- Oakrey.Telemetry (>= 3.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 8.0.0 | 66 | 11/30/2026 |