Reworked encryption to use less heap allocated buffers for secrets.
Also some work on plugin system.
This commit is contained in:
parent
8782ef39c6
commit
054754f553
42 changed files with 1452 additions and 242 deletions
15
IdentityShroud.SecretProviders/ISecretProvider.cs
Normal file
15
IdentityShroud.SecretProviders/ISecretProvider.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
namespace IdentityShroud.SecretProviders;
|
||||
|
||||
/// <summary>
|
||||
/// Required interface of a SecretProvider.
|
||||
/// </summary>
|
||||
public interface ISecretProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Used as a key in the registry. This same value should be used for the type field
|
||||
/// when configuring a secret.
|
||||
/// </summary>
|
||||
string Key { get; }
|
||||
|
||||
Task<PlainSecret> GetSecret(string configurationValue, CancellationToken ct = default);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\IdentityShroud.PluginSupport\IdentityShroud.PluginSupport.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
18
IdentityShroud.SecretProviders/PlainSecret.cs
Normal file
18
IdentityShroud.SecretProviders/PlainSecret.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System.Security.Cryptography;
|
||||
|
||||
namespace IdentityShroud.SecretProviders;
|
||||
|
||||
public sealed class PlainSecret(byte[] secret) : IDisposable
|
||||
{
|
||||
private bool _disposed;
|
||||
|
||||
public ReadOnlySpan<byte> Secret => secret;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
_disposed = true;
|
||||
CryptographicOperations.ZeroMemory(secret);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue