Authenticated encryption for enterprise secrets (#1078)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-10-17 20:36:34 +02:00
1 parent 031874cebf
commit 274d718314
26 files changed
+740 -89

No files matched your search

@@ -73,7 +73,7 @@ public sealed partial class ToolSettingsService
continue;
var values = await this.GetSettingsAsync(tool.Definition);
var issue = CollectSettings(tool.Definition, areasOfTool, values, options, PluginFactory.EnterpriseEncryption, lockedValues, defaultValues);
var issue = CollectSettings(tool.Definition, areasOfTool, values, options, PluginFactory.EnterpriseEncryption, settingsManager.ConfigurationData.App.EnterpriseEncryptionExportFormat, lockedValues, defaultValues);
if (issue is not null)
return new(ErrorMessage: issue);
}
@@ -98,7 +98,7 @@ public sealed partial class ToolSettingsService
/// Adds the selected settings of one tool to the values to export, by their managed key.
/// </summary>
/// <returns>Why the export failed, or null when it may go on.</returns>
private static string? CollectSettings(ToolDefinition definition, IEnumerable<ExportableSettings> selectedAreas, IReadOnlyDictionary<string, string> values, ToolSettingsExportOptions options, EnterpriseEncryption? encryption, Dictionary<string, string> lockedValues, Dictionary<string, string> defaultValues)
private static string? CollectSettings(ToolDefinition definition, IEnumerable<ExportableSettings> selectedAreas, IReadOnlyDictionary<string, string> values, ToolSettingsExportOptions options, EnterpriseEncryption? encryption, EnterpriseEncryptionFormat encryptionFormat, Dictionary<string, string> lockedValues, Dictionary<string, string> defaultValues)
{
foreach (var fieldName in GetSelectedFieldNames(definition, selectedAreas))
{
@@ -114,7 +114,7 @@ public sealed partial class ToolSettingsService
if (encryption?.IsAvailable is not true)
return TB("Cannot export encrypted tool secrets: No enterprise encryption secret is configured.");
if (!encryption.TryEncrypt(value, out var encrypted))
if (!encryption.TryEncrypt(value, encryptionFormat, out var encrypted))
return TB("The tool secrets could not be encrypted. Nothing was exported.");
lockedValues[key] = encrypted;
@@ -182,7 +182,7 @@ public sealed partial class ToolSettingsService(SettingsManager settingsManager,
if (!EnterpriseEncryption.IsEncrypted(encryptedSecret))
{
logger.LogWarning("The managed tool setting '{ManagedKey}' holds a plaintext secret. Only encrypted secrets, starting with 'ENC:v1:', are supported.", managedKey);
logger.LogWarning("The managed tool setting '{ManagedKey}' holds a plaintext secret. Only encrypted secrets, starting with 'ENC:', are supported.", managedKey);
return false;
}