@azure/keyvault-admin 4.2.1-alpha.20220707.3 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -145
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist-esm/keyvault-admin/src/constants.js +1 -1
- package/dist-esm/keyvault-admin/src/constants.js.map +1 -1
- package/dist-esm/keyvault-admin/src/generated/keyVaultClientContext.js +1 -1
- package/dist-esm/keyvault-admin/src/generated/keyVaultClientContext.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -26,110 +26,6 @@ Install the Azure Key Vault administration client library for JavaScript and Typ
|
|
|
26
26
|
npm install @azure/keyvault-admin
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
### Currently supported environments
|
|
30
|
-
|
|
31
|
-
- [LTS versions of Node.js](https://nodejs.org/about/releases/)
|
|
32
|
-
|
|
33
|
-
### Prerequisites
|
|
34
|
-
|
|
35
|
-
- An [Azure subscription](https://azure.microsoft.com/free/)
|
|
36
|
-
- A [Key Vault resource](https://docs.microsoft.com/azure/key-vault/quick-create-portal)
|
|
37
|
-
|
|
38
|
-
#### Getting Azure credentials
|
|
39
|
-
|
|
40
|
-
Use the [Azure CLI][azure-cli] snippet below to create/get client secret credentials.
|
|
41
|
-
|
|
42
|
-
- Create a service principal and configure its access to Azure resources:
|
|
43
|
-
```PowerShell
|
|
44
|
-
az ad sp create-for-rbac -n <your-application-name> --skip-assignment
|
|
45
|
-
```
|
|
46
|
-
Output:
|
|
47
|
-
```json
|
|
48
|
-
{
|
|
49
|
-
"appId": "generated-app-ID",
|
|
50
|
-
"displayName": "some-app-name",
|
|
51
|
-
"name": "http://some-app-name",
|
|
52
|
-
"password": "random-password",
|
|
53
|
-
"tenant": "tenant-ID"
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
- Take note of the service principal objectId
|
|
57
|
-
```PowerShell
|
|
58
|
-
az ad sp show --id <appId> --query objectId
|
|
59
|
-
```
|
|
60
|
-
Output:
|
|
61
|
-
```
|
|
62
|
-
"<your-service-principal-object-id>"
|
|
63
|
-
```
|
|
64
|
-
- Use the returned credentials above to set **AZURE_CLIENT_ID** (appId), **AZURE_CLIENT_SECRET** (password), and **AZURE_TENANT_ID** (tenant) environment variables.
|
|
65
|
-
|
|
66
|
-
#### Get or create an Azure Managed HSM with the Azure CLI
|
|
67
|
-
|
|
68
|
-
- Create the Managed HSM and grant the above mentioned service principal authorization to perform administrative operations on the Azure Key Vault (replace `<your-resource-group-name>` and `<your-key-vault-name>` with your own, unique names and `<your-service-principal-object-id>` with the value from above):
|
|
69
|
-
|
|
70
|
-
```PowerShell
|
|
71
|
-
az keyvault create --hsm-name <your-key-vault-name> --resource-group <your-resource-group-name> --administrators <your-service-principal-object-id> --location <your-azure-location>
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
This service principal is automatically added to the "Managed HSM Administrators" [built-in role][built_in_roles].
|
|
75
|
-
|
|
76
|
-
- Use the above mentioned Azure Key Vault name to retrieve details of your Vault which also contains your Azure Key Vault URL:
|
|
77
|
-
```PowerShell
|
|
78
|
-
az keyvault show --hsm-name <your-key-vault-name>
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
#### Activate your managed HSM
|
|
82
|
-
|
|
83
|
-
All data plane commands are disabled until the HSM is activated. You will not be able to create keys or assign roles. Only the designated administrators that were assigned during the create command can activate the HSM. To activate the HSM you must download the security domain.
|
|
84
|
-
|
|
85
|
-
To activate your HSM you need:
|
|
86
|
-
|
|
87
|
-
- Minimum 3 RSA key-pairs (maximum 10)
|
|
88
|
-
- Specify minimum number of keys required to decrypt the security domain (quorum)
|
|
89
|
-
|
|
90
|
-
To activate the HSM you send at least 3 (maximum 10) RSA public keys to the HSM. The HSM encrypts the security domain with these keys and sends it back. Once this security domain is successfully downloaded, your HSM is ready to use. You also need to specify quorum, which is the minimum number of private keys required to decrypt the security domain.
|
|
91
|
-
|
|
92
|
-
The example below shows how to use openssl to generate 3 self signed certificate.
|
|
93
|
-
|
|
94
|
-
```PowerShell
|
|
95
|
-
openssl req -newkey rsa:2048 -nodes -keyout cert_0.key -x509 -days 365 -out cert_0.cer
|
|
96
|
-
openssl req -newkey rsa:2048 -nodes -keyout cert_1.key -x509 -days 365 -out cert_1.cer
|
|
97
|
-
openssl req -newkey rsa:2048 -nodes -keyout cert_2.key -x509 -days 365 -out cert_2.cer
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Use the az keyvault security-domain download command to download the security domain and activate your managed HSM. The example below, uses 3 RSA key pairs (only public keys are needed for this command) and sets the quorum to 2.
|
|
101
|
-
|
|
102
|
-
```PowerShell
|
|
103
|
-
az keyvault security-domain download --hsm-name <your-key-vault-name> --sd-wrapping-keys ./certs/cert_0.cer ./certs/cert_1.cer ./certs/cert_2.cer --sd-quorum 2 --security-domain-file ContosoMHSM-SD.json
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
#### Controlling access to your managed HSM
|
|
107
|
-
|
|
108
|
-
The designated administrators assigned during creation are automatically added to the "Managed HSM Administrators" [built-in role][built_in_roles],
|
|
109
|
-
who are able to download a security domain and [manage roles for data plane access][access_control], among other limited permissions.
|
|
110
|
-
|
|
111
|
-
To perform other actions on keys, you need to assign principals to other roles such as "Managed HSM Crypto User", which can perform non-destructive key operations:
|
|
112
|
-
|
|
113
|
-
```PowerShell
|
|
114
|
-
az keyvault role assignment create --hsm-name <your-key-vault-name> --role "Managed HSM Crypto User" --scope / --assignee-object-id <principal-or-user-object-ID> --assignee-principal-type <principal-type>
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Please read [best practices][best_practices] for properly securing your managed HSM.
|
|
118
|
-
|
|
119
|
-
#### Get or create an Azure Storage Account with the Azure CLI
|
|
120
|
-
|
|
121
|
-
A storage account is necessary to generate the backup of a Key Vault.
|
|
122
|
-
|
|
123
|
-
To generate Key Vault backups, you will need to point the `KeyVaultBackupClient` to an existing Storage account.
|
|
124
|
-
|
|
125
|
-
To create a new Storage Account, you can use the [Azure Portal][storage-account-create-portal],
|
|
126
|
-
[Azure PowerShell][storage-account-create-ps], or the [Azure CLI][storage-account-create-cli].
|
|
127
|
-
Here's an example using the Azure CLI:
|
|
128
|
-
|
|
129
|
-
```Powershell
|
|
130
|
-
az storage account create --name MyStorageAccount --resource-group MyResourceGroup --location westus --sku Standard_LRS
|
|
131
|
-
```
|
|
132
|
-
|
|
133
29
|
### Configure TypeScript
|
|
134
30
|
|
|
135
31
|
TypeScript users need to have Node type definitions installed:
|
|
@@ -140,21 +36,24 @@ npm install @types/node
|
|
|
140
36
|
|
|
141
37
|
You also need to enable `compilerOptions.allowSyntheticDefaultImports` in your tsconfig.json. Note that if you have enabled `compilerOptions.esModuleInterop`, `allowSyntheticDefaultImports` is enabled by default. See [TypeScript's compiler options handbook][compiler-options] for more information.
|
|
142
38
|
|
|
143
|
-
###
|
|
39
|
+
### Currently supported environments
|
|
144
40
|
|
|
145
|
-
|
|
41
|
+
- [LTS versions of Node.js](https://nodejs.org/about/releases/)
|
|
146
42
|
|
|
147
|
-
|
|
43
|
+
### Prerequisites
|
|
148
44
|
|
|
149
|
-
|
|
45
|
+
- An [Azure subscription](https://azure.microsoft.com/free/)
|
|
46
|
+
- An existing [Key Vault Managed HSM][azure_keyvault_mhsm]. If you need to create a Managed HSM, you can do so using the Azure CLI by following the steps in [this document][azure_keyvault_mhsm_cli].
|
|
150
47
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
48
|
+
## Authenticate the client
|
|
49
|
+
|
|
50
|
+
In order to interact with the Azure Key Vault service, you will need to create an instance of either the [`KeyVaultAccessControlClient`](#create-keyvaultaccesscontrolclient) class or the [`KeyVaultBackupClient`](#create-keyvaultbackupclient) class, as well as a **vault url** (which you may see as "DNS Name" in the Azure Portal) and a credential object. The examples shown in this document use a credential object named [`DefaultAzureCredential`][default_azure_credential], which is appropriate for most scenarios, including local development and production environments. Additionally, we recommend using a [managed identity][managed_identity] for authentication in production environments.
|
|
154
51
|
|
|
155
|
-
|
|
52
|
+
You can find more information on different ways of authenticating and their corresponding credential types in the [Azure Identity documentation][azure_identity].
|
|
156
53
|
|
|
157
|
-
|
|
54
|
+
### Create KeyVaultAccessControlClient
|
|
55
|
+
|
|
56
|
+
Once you've authenticated with [the authentication method that suits you best][default_azure_credential], you can create a `KeyVaultAccessControlClient` as follows, substituting in your Managed HSM URL in the constructor:
|
|
158
57
|
|
|
159
58
|
```javascript
|
|
160
59
|
const { DefaultAzureCredential } = require("@azure/identity");
|
|
@@ -162,13 +61,12 @@ const { KeyVaultAccessControlClient } = require("@azure/keyvault-admin");
|
|
|
162
61
|
|
|
163
62
|
const credentials = new DefaultAzureCredential();
|
|
164
63
|
|
|
165
|
-
const
|
|
166
|
-
const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
|
|
64
|
+
const client = new KeyVaultAccessControlClient(`<your Managed HSM URL>`, credentials);
|
|
167
65
|
```
|
|
168
66
|
|
|
169
|
-
|
|
67
|
+
### Create KeyVaultBackupClient
|
|
170
68
|
|
|
171
|
-
Once you've
|
|
69
|
+
Once you've authenticated with [the authentication method that suits you best][default_azure_credential], you can create a `KeyVaultBackupClient` as follows, substituting in your Managed HSM URL in the constructor:
|
|
172
70
|
|
|
173
71
|
```javascript
|
|
174
72
|
const { DefaultAzureCredential } = require("@azure/identity");
|
|
@@ -176,8 +74,7 @@ const { KeyVaultBackupClient } = require("@azure/keyvault-admin");
|
|
|
176
74
|
|
|
177
75
|
const credentials = new DefaultAzureCredential();
|
|
178
76
|
|
|
179
|
-
const
|
|
180
|
-
const client = new KeyVaultBackupClient(vaultUrl, credentials);
|
|
77
|
+
const client = new KeyVaultBackupClient(`<your Managed HSM URL>`, credentials);
|
|
181
78
|
```
|
|
182
79
|
|
|
183
80
|
## Key concepts
|
|
@@ -188,7 +85,7 @@ A Role Definition is a collection of permissions. A role definition defines the
|
|
|
188
85
|
|
|
189
86
|
Role definitions can be listed and specified as part of a `KeyVaultRoleAssignment`.
|
|
190
87
|
|
|
191
|
-
### KeyVaultRoleAssignment
|
|
88
|
+
### KeyVaultRoleAssignment
|
|
192
89
|
|
|
193
90
|
A Role Assignment is the association of a Role Definition to a service principal. They can be created, listed, fetched individually, and deleted.
|
|
194
91
|
|
|
@@ -235,9 +132,9 @@ setLogLevel("info");
|
|
|
235
132
|
|
|
236
133
|
You can find more code samples through the following links:
|
|
237
134
|
|
|
238
|
-
- [
|
|
239
|
-
- [
|
|
240
|
-
- [
|
|
135
|
+
- [Key Vault Administration Samples (JavaScript)](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/keyvault-admin/samples/v4/javascript)
|
|
136
|
+
- [Key Vault Administration Samples (TypeScript)](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/keyvault-admin/samples/v4/typescript)
|
|
137
|
+
- [Key Vault Administration Test Cases](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/keyvault-admin/test/)
|
|
241
138
|
|
|
242
139
|
## Contributing
|
|
243
140
|
|
|
@@ -247,34 +144,17 @@ If you'd like to contribute to this library, please read the [contributing guide
|
|
|
247
144
|
|
|
248
145
|
<!-- LINKS -->
|
|
249
146
|
|
|
250
|
-
[dac]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md
|
|
251
|
-
[jwk]: https://tools.ietf.org/html/rfc7517
|
|
252
|
-
[access_control]: https://docs.microsoft.com/azure/key-vault/managed-hsm/access-control
|
|
253
|
-
[api-rest]: https://docs.microsoft.com/rest/api/keyvault/
|
|
254
|
-
[azure-cli]: https://docs.microsoft.com/cli/azure
|
|
255
|
-
[azure-identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity
|
|
256
|
-
[azure-sub]: https://azure.microsoft.com/free/
|
|
257
|
-
[backup_client]: ./src/KeyVaultBackupClient.cs
|
|
258
|
-
[best_practices]: https://docs.microsoft.com/azure/key-vault/managed-hsm/best-practices
|
|
259
|
-
[built_in_roles]: https://docs.microsoft.com/azure/key-vault/managed-hsm/built-in-roles
|
|
260
|
-
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
|
|
261
147
|
[compiler-options]: https://www.typescriptlang.org/docs/handbook/compiler-options.html
|
|
262
148
|
[core-lro]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-lro
|
|
263
|
-
[docs-overview]: https://docs.microsoft.com/azure/key-vault/key-vault-overview
|
|
264
149
|
[docs-service]: https://azure.microsoft.com/services/key-vault/
|
|
265
150
|
[docs]: https://docs.microsoft.com/javascript/api/@azure/keyvault-admin
|
|
266
|
-
|
|
267
|
-
[dotenv]: https://www.npmjs.com/package/dotenv]
|
|
268
|
-
[identity-npm]: https://www.npmjs.com/package/@azure/identity
|
|
269
|
-
[keyvault_docs]: https://docs.microsoft.com/azure/key-vault/
|
|
270
|
-
[logging]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.ts.com/Azure/azure-sdk-for-net/blob/main/sdk/keyvault/Microsoft.Azure.KeyVault/CONTRIBUTING.md
|
|
271
151
|
[managedhsm]: https://docs.microsoft.com/azure/key-vault/managed-hsm/overview
|
|
272
152
|
[npm]: https://www.npmjs.com/
|
|
273
153
|
[package-gh]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/keyvault-admin
|
|
274
154
|
[package-npm]: https://www.npmjs.com/package/@azure/keyvault-admin
|
|
275
155
|
[samples]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/keyvault-admin/samples
|
|
276
|
-
[
|
|
277
|
-
[
|
|
278
|
-
[
|
|
279
|
-
|
|
280
|
-
|
|
156
|
+
[azure_keyvault_mhsm]: https://docs.microsoft.com/azure/key-vault/managed-hsm/overview
|
|
157
|
+
[azure_keyvault_mhsm_cli]: https://docs.microsoft.com/azure/key-vault/managed-hsm/quick-create-cli
|
|
158
|
+
[default_azure_credential]: https://docs.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable#defaultazurecredential
|
|
159
|
+
[managed_identity]: https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview
|
|
160
|
+
[azure_identity]: https://docs.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable
|
package/dist/index.js
CHANGED
|
@@ -1245,7 +1245,7 @@ class KeyVaultClientContext extends coreClient__namespace.ServiceClient {
|
|
|
1245
1245
|
const defaults = {
|
|
1246
1246
|
requestContentType: "application/json; charset=utf-8"
|
|
1247
1247
|
};
|
|
1248
|
-
const packageDetails = `azsdk-js-keyvault-admin/4.2.
|
|
1248
|
+
const packageDetails = `azsdk-js-keyvault-admin/4.2.2`;
|
|
1249
1249
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
1250
1250
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
1251
1251
|
: `${packageDetails}`;
|
|
@@ -1420,7 +1420,7 @@ const selectiveKeyRestoreOperationOperationSpec = {
|
|
|
1420
1420
|
/**
|
|
1421
1421
|
* Current version of the Key Vault Admin SDK.
|
|
1422
1422
|
*/
|
|
1423
|
-
const SDK_VERSION = "4.2.
|
|
1423
|
+
const SDK_VERSION = "4.2.2";
|
|
1424
1424
|
/**
|
|
1425
1425
|
* The latest supported Key Vault service API version.
|
|
1426
1426
|
*/
|