Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2747

Use Either monad to back KMSProviders

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Field Level Encryption
    • 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[]>>

      Attachments

        Activity

          People

            Unassigned Unassigned
            vincent.kam@mongodb.com Vincent Kam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: