Skip to content

Commit f4d0c6c

Browse files
authored
go azure kms (#708)
* go azure kms * fix indentation for tabs * fix indentation for note * pr feedback * fix typo Co-authored-by: Nathan Leniz <[email protected]>
1 parent 147fbcd commit f4d0c6c

File tree

1 file changed

+52
-4
lines changed

1 file changed

+52
-4
lines changed

source/includes/steps-fle-convert-to-a-remote-master-key-azure.yaml

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ content: |
2323
.. image:: /figures/CSFLE_Master_Key_KMS.png
2424
:alt: Diagram that describes creating a master key when using a KMS provider
2525
26-
1. To create a master key, follow Microsoft's official
26+
1. To create a master key, follow Microsoft's official
2727
`Secrets Guide <https://docs.microsoft.com/en-us/azure/key-vault/secrets/about-secrets>`__.
2828
Follow the instructions in one of the :guilabel:`Quickstarts` sections
2929
that corresponds to your preferred method to create and configure your
@@ -171,6 +171,31 @@ content: |
171171
To use the Azure KMS, you must use
172172
`libmongocrypt <https://github.com/mongodb/libmongocrypt#installing-libmongocrypt-on-windows>`__ version 1.1 or later in your application's environment.
173173
174+
.. tab::
175+
:tabid: go
176+
177+
In ``kms/provider.go``, update the variable declarations or define the expected environmental variables in
178+
``AzureProvider()``.
179+
180+
.. code-block:: go
181+
182+
azureTenantID := GetCheckedEnv("FLE_AZURE_TENANT_ID")
183+
azureClientID := GetCheckedEnv("FLE_AZURE_CLIENT_ID")
184+
azureClientSecret := GetCheckedEnv("FLE_AZURE_CLIENT_SECRET")
185+
186+
The expected KMS provider map is created with struct tags.
187+
188+
.. code-block:: go
189+
190+
func (a *Azure) Credentials() map[string]map[string]interface{} {
191+
return map[string]map[string]interface{}{"azure": structs.Map(a.credentials)}
192+
}
193+
194+
.. note::
195+
196+
To use the Azure KMS, you must use
197+
`libmongocrypt <https://github.com/mongodb/libmongocrypt>`__ version 1.1 or later in your application's environment.
198+
174199
---
175200
title: Create a New Data Encryption Key
176201
ref: create-a-new-data-key
@@ -273,9 +298,32 @@ content: |
273298
});
274299
275300
var dataKeyId = clientEncryption.CreateDataKey("azure", dataKeyOptions, CancellationToken.None);
276-
Console.WriteLine($"Azure DataKeyId [UUID]: {dataKeyId}");
277-
var dataKeyIdBase64 = Convert.ToBase64String(GuidConverter.ToBytes(dataKeyId, GuidRepresentation.Standard));
278-
Console.WriteLine($"Azure DataKeyId [base64]: {dataKeyIdBase64}");
301+
302+
.. tab::
303+
:tabid: go
304+
305+
In ``kms/provider.go``, update the variable declarations or define the expected environmental variables
306+
in ``AzureProvider()``.
307+
308+
.. code-block:: go
309+
310+
azureKeyVaultEndpoint := GetCheckedEnv("FLE_AZURE_KEYVAULT_ENDPOINT")
311+
azureKeyName := GetCheckedEnv("FLE_AZURE_KEY_NAME")
312+
313+
Struct tags are used to pass these values directly to the driver for use. In ``kms/provider.go``
314+
315+
.. code-block:: go
316+
317+
func (a *Azure) DataKeyOpts() interface{} {
318+
return a.dataKeyOpts
319+
}
320+
321+
In ``csfle/data_key.go``
322+
323+
.. code-block:: go
324+
325+
dataKeyOpts := options.DataKey().SetMasterKey(provider.DataKeyOpts())
326+
dataKeyID, err := clientEnc.CreateDataKey(context.TODO(), provider.Name(), dataKeyOpts)
279327
280328
---
281329
title: Update the Automatic Encryption JSON Schema

0 commit comments

Comments
 (0)