Details
-
Improvement
-
Resolution: Won't Do
-
Major - P3
-
None
-
None
-
None
Description
Currently our KMS providers are backed with a IReadOnlyDictionary<string, IReadOnlyDictionary<string, object>>
We use the following method to ensure that the values in the subdictionaries are strings or byte arrays.
public static void EnsureKmsProvidersAreValid(IReadOnlyDictionary<string, IReadOnlyDictionary<string, object>> kmsProviders) |
{
|
foreach (var kmsProvider in kmsProviders) |
{
|
foreach (var option in Ensure.IsNotNull(kmsProvider.Value, nameof(kmsProvider))) |
{
|
var optionValue = Ensure.IsNotNull(option.Value, "kmsProviderOption"); |
var isValid = optionValue is byte[] || optionValue is string; |
if (!isValid) |
{
|
throw new ArgumentException($"Invalid kms provider option type: {optionValue.GetType().Name}."); |
}
|
}
|
}
|
}
|
We could make this restriction more explicit by using the Either monadto back the KMS providers internally:
IReadOnlyDictionary<string, IReadOnlyDictionary<string, Either<string, byte[]>>