Skip to content

Commit ab04b38

Browse files
RUBY-2405 Add Azure KMS support (#2372)
1 parent 3629d92 commit ab04b38

File tree

1 file changed

+38
-16
lines changed

1 file changed

+38
-16
lines changed

source/reference/client-side-encryption.txt

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ in order to perform automatic encryption.
199199
# => <BSON::Binary... type=ciphertext...>
200200

201201
The example above demonstrates using automatic encryption with a local master key.
202-
For more information about using the AWS Key Management Service to create a
202+
For more information about using other key management services to create a
203203
master key and create data keys, see the following sections of this tutorial:
204204

205205
- `Creating A Master Key`_
@@ -293,7 +293,7 @@ in order to perform explicit encryption.
293293
# => "sensitive data"
294294

295295
The example above demonstrates using explicit encryption with a local master key.
296-
For more information about using the AWS Key Management Service to create a
296+
For more information about using other key management services to create a
297297
master key and create data keys, see the following sections of this tutorial:
298298

299299
- `Creating A Master Key`_,
@@ -304,8 +304,8 @@ Creating a Master Key
304304
Both automatic encryption and explicit encryption require an encryption master key.
305305
This master key is used to encrypt data keys, which are in turn used to encrypt
306306
user data. The master key can be generated in one of two ways: by creating a
307-
local key, or by creating a key in the Amazon Web Services Key Management
308-
Service (AWS KMS).
307+
local key, or by creating a key in a key management service. Currently
308+
Ruby driver supports AWS Key Management Service (KMS) and Azure Key Vault.
309309

310310
Local Master Key
311311
~~~~~~~~~~~~~~~~
@@ -324,15 +324,15 @@ Run the following code to generate a local master key using Ruby:
324324
local_master_key = SecureRandom.random_bytes(96)
325325
# => "\xB2\xBE\x8EN\xD4\x14\xC2\x13\xC3..." (a binary blob)
326326

327-
AWS Master Key
328-
~~~~~~~~~~~~~~
329-
It is recommended that you use Amazon's Key Management Service to create and
330-
store your master key. To do so, follow steps 1 and 2 of the
331-
:drivers:`"Convert to a Remote Master Key" section</security/client-side-field-level-encryption-local-key-to-kms/#convert-to-a-remote-master-key>`
327+
Remote Master Key
328+
~~~~~~~~~~~~~~~~~
329+
It is recommended that you use a remote Key Management Service to create and
330+
store your master key. To do so, follow steps of the
331+
:drivers:`"Set up a Remote Master Key" section</security/client-side-field-level-encryption-local-key-to-kms/#set-up-a-remote-master-key>`
332332
in the MongoDB Client-Side Encryption documentation.
333333

334334
For more information about creating a master key, see the
335-
:drivers:`Create a Master Key </security/client-side-field-level-encryption-guide/#a-create-a-master-key>`
335+
:drivers:`Create a Master Key </security/client-side-field-level-encryption-guide/#a.-create-a-master-key>`
336336
section of the MongoDB manual.
337337

338338
Creating a Data Key
@@ -379,14 +379,19 @@ key with the following code snippet:
379379
See the `Local Master Key`_ section for more information about generating a new
380380
local master key.
381381

382-
Create a Data Key Using an AWS Master Key
382+
Create a Data Key Using a Remote Master Key
383383
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384384

385-
If you have created an AWS master key, note the access key ID and the secret access
385+
If you have created an AWS KMS master key, note the access key ID and the secret access
386386
key of the IAM user that has permissions to use the key. Additionally, note
387387
the AWS region and the Amazon Resource Number (ARN) of your master key. You will
388388
use that information to generate a data key.
389389

390+
If you have created an Azure master key, note the tenant id, the client id, and
391+
the client secret of the application that has permissions to use the key.
392+
Additionally, note the key name, key version (id any), and key vault endpoint
393+
for your master key. You will use that information to generate a data key.
394+
390395
.. code-block:: ruby
391396

392397
# A Mongo::Client instance that will be used to connect to the key vault
@@ -402,11 +407,16 @@ use that information to generate a data key.
402407
aws: {
403408
access_key_id: 'IAM-ACCESS-KEY-ID',
404409
secret_access_key: 'IAM-SECRET-ACCESS-KEY'
410+
},
411+
azure: {
412+
tenant_id: 'AZURE-TENANT-ID',
413+
client_id: 'AZURE-CLIENT-ID',
414+
client_secret: 'AZURE-CLIENT-SECRET'
405415
}
406416
}
407417
)
408418

409-
data_key_id = client_encryption.create_data_key(
419+
aws_data_key_id = client_encryption.create_data_key(
410420
'aws',
411421
{
412422
master_key: {
@@ -418,12 +428,24 @@ use that information to generate a data key.
418428
)
419429
# => <BSON::Binary... type=ciphertext...>
420430

421-
See the `AWS Master Key`_ section of this tutorial for more information about
422-
generating a new master key on AWS and finding the information you need to
431+
azure_data_key_id = client_encryption.create_data_key(
432+
'azure',
433+
{
434+
master_key: {
435+
key_vault_endpoint: 'AZURE-KEY-VAULT-ENDPOINT',
436+
key_name: 'AZURE-KEY-NAME'
437+
}
438+
439+
}
440+
)
441+
# => <BSON::Binary... type=ciphertext...>
442+
443+
See the `Remote Master Key`_ section of this tutorial for more information about
444+
generating a new remote master key and finding the information you need to
423445
create data keys.
424446

425447
For more information about creating a data key, see the
426-
:drivers:`Create a Data Encryption Key </security/client-side-field-level-encryption-guide/#b-create-a-data-encryption-key>`
448+
:drivers:`Create a Data Encryption Key </security/client-side-field-level-encryption-guide/#b.-create-a-data-encryption-key>`
427449
section of the MongoDB manual.
428450

429451
Auto-Encryption Options

0 commit comments

Comments
 (0)