Skip to content

Commit

Permalink
Client Encryption : Fixes query support on encrypted parameters and f…
Browse files Browse the repository at this point in the history
…ixes samples (Azure#2445)

This PR add fix to support non primitive type value as parameter value for Query support on Encrypted parameters.
The changes also allows for creating documents when a client/user has no access to a Key provided Null is passed as property value.
  • Loading branch information
kr-santosh authored May 13, 2021
1 parent 282c1c1 commit a110a70
Show file tree
Hide file tree
Showing 5 changed files with 297 additions and 318 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public static async Task<ClientEncryptionKeyResponse> CreateClientEncryptionKeyA

EncryptionKeyStoreProvider encryptionKeyStoreProvider = encryptionCosmosClient.EncryptionKeyStoreProvider;

if (!string.Equals(encryptionKeyWrapMetadata.Type, encryptionKeyStoreProvider.ProviderName))
{
throw new ArgumentException("The EncryptionKeyWrapMetadata Type value does not match with the ProviderName of EncryptionKeyStoreProvider configured on the Client. Please refer to https://aka.ms/CosmosClientEncryption for more details. ");
}

KeyEncryptionKey keyEncryptionKey = KeyEncryptionKey.GetOrCreate(
encryptionKeyWrapMetadata.Name,
encryptionKeyWrapMetadata.Value,
Expand Down Expand Up @@ -156,6 +161,11 @@ public static async Task<ClientEncryptionKeyResponse> RewrapClientEncryptionKeyA

EncryptionKeyStoreProvider encryptionKeyStoreProvider = encryptionCosmosClient.EncryptionKeyStoreProvider;

if (!string.Equals(newEncryptionKeyWrapMetadata.Type, encryptionKeyStoreProvider.ProviderName))
{
throw new ArgumentException("The EncryptionKeyWrapMetadata Type value does not match with the ProviderName of EncryptionKeyStoreProvider configured on the Client. Please refer to https://aka.ms/CosmosClientEncryption for more details. ");
}

ClientEncryptionKeyProperties clientEncryptionKeyProperties = await clientEncryptionKey.ReadAsync(cancellationToken: cancellationToken);

RequestOptions requestOptions = new RequestOptions
Expand Down
Loading

0 comments on commit a110a70

Please sign in to comment.