The EncryptionService now loads a set of keys and uses the active one to encrypt and selects key based on keyid during decryption. Introduced EncryptedValue to hold keyId and encrypted data. (There are no intermeddiate keys yet)
22 lines
No EOL
638 B
C#
22 lines
No EOL
638 B
C#
using IdentityShroud.Core.Contracts;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace IdentityShroud.Core.Security;
|
|
|
|
/// <summary>
|
|
/// Secret provider that retrieves secrets from configuration.
|
|
/// </summary>
|
|
public class ConfigurationSecretProvider(IConfiguration configuration) : ISecretProvider
|
|
{
|
|
private readonly IConfigurationSection secrets = configuration.GetSection("secrets");
|
|
|
|
public string GetSecret(string name)
|
|
{
|
|
return secrets.GetValue<string>(name) ?? "";
|
|
}
|
|
|
|
public EncryptionKey[] GetKeys(string name)
|
|
{
|
|
return secrets.GetSection(name).Get<EncryptionKey[]>() ?? [];
|
|
}
|
|
} |