@azure/identity 3.0.0-alpha.20220804.2 → 3.0.0-alpha.20220914.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.
Potentially problematic release.
This version of @azure/identity might be problematic. Click here for more details.
- package/README.md +5 -3
- package/dist/index.js +33 -34
- package/dist/index.js.map +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.js +0 -2
- package/dist-esm/src/credentials/defaultAzureCredential.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +30 -35
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.js +1 -0
- package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -1
- package/dist-esm/src/util/logging.js +4 -0
- package/dist-esm/src/util/logging.js.map +1 -1
- package/package.json +1 -1
- package/types/identity.d.ts +0 -16
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ If interactive authentication cannot be supported in the session, then the `-Use
|
|
|
88
88
|
|
|
89
89
|
#### Authenticate via Visual Studio Code
|
|
90
90
|
|
|
91
|
-
Developers using Visual Studio Code can use the [Azure Account extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account) to authenticate via the editor. Apps using `
|
|
91
|
+
Developers using Visual Studio Code can use the [Azure Account extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account) to authenticate via the editor. Apps using `VisualStudioCodeCredential` can then use this account to authenticate calls in their app when running locally.
|
|
92
92
|
|
|
93
93
|
To authenticate in Visual Studio Code, ensure the Azure Account extension is installed. Once installed, open the **Command Palette** and run the **Azure: Sign In** command.
|
|
94
94
|
|
|
@@ -124,11 +124,13 @@ If used from Node.js, the `DefaultAzureCredential` will attempt to authenticate
|
|
|
124
124
|
|
|
125
125
|
1. **Environment** - The `DefaultAzureCredential` will read account information specified via [environment variables](#environment-variables) and use it to authenticate.
|
|
126
126
|
1. **Managed Identity** - If the application is deployed to an Azure host with Managed Identity enabled, the `DefaultAzureCredential` will authenticate with that account.
|
|
127
|
-
1. **Visual Studio Code** - If the developer has authenticated with the [Visual Studio Code Azure Account extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account), the `DefaultAzureCredential` will authenticate using that account.
|
|
128
|
-
- In `@azure/identity` version 2.0 or later, the [`@azure/identity-vscode`](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity-vscode) package must be installed for the Visual Studio Code authentication to work.
|
|
129
127
|
1. **Azure CLI** - If the developer has authenticated an account via the Azure CLI `az login` command, the `DefaultAzureCredential` will authenticate with that account.
|
|
130
128
|
1. **Azure PowerShell** - If the developer has authenticated using the Azure PowerShell module `Connect-AzAccount` command, the `DefaultAzureCredential` will authenticate with that account.
|
|
131
129
|
|
|
130
|
+
#### Note about `VisualStudioCodeCredential`
|
|
131
|
+
|
|
132
|
+
Due to a [known issue](https://github.com/Azure/azure-sdk-for-js/issues/20500), `VisualStudioCodeCredential` has been removed from the `DefaultAzureCredential` token chain. When the issue is resolved in a future release it will return.
|
|
133
|
+
|
|
132
134
|
## Plugins
|
|
133
135
|
|
|
134
136
|
Azure Identity for JavaScript provides a plugin API that allows us to provide certain functionality through separate _plugin packages_. The `@azure/identity` package exports a top-level function (`useIdentityPlugin`) that can be used to enable a plugin. We provide two plugin packages:
|
package/dist/index.js
CHANGED
|
@@ -293,11 +293,15 @@ function credentialLoggerInstance(title, parent, log = logger$l) {
|
|
|
293
293
|
function warning(message) {
|
|
294
294
|
log.warning(`${fullTitle} =>`, message);
|
|
295
295
|
}
|
|
296
|
+
function verbose(message) {
|
|
297
|
+
log.verbose(`${fullTitle} =>`, message);
|
|
298
|
+
}
|
|
296
299
|
return {
|
|
297
300
|
title,
|
|
298
301
|
fullTitle,
|
|
299
302
|
info,
|
|
300
303
|
warning,
|
|
304
|
+
verbose,
|
|
301
305
|
};
|
|
302
306
|
}
|
|
303
307
|
/**
|
|
@@ -1279,6 +1283,7 @@ class VisualStudioCodeCredential {
|
|
|
1279
1283
|
"You must install the identity-vscode plugin package (`npm install --save-dev @azure/identity-vscode`)",
|
|
1280
1284
|
"and enable it by importing `useIdentityPlugin` from `@azure/identity` and calling",
|
|
1281
1285
|
"`useIdentityPlugin(vsCodePlugin)` before creating a `VisualStudioCodeCredential`.",
|
|
1286
|
+
"To troubleshoot, visit https://aka.ms/azsdk/js/identity/vscodecredential/troubleshoot.",
|
|
1282
1287
|
].join(" "));
|
|
1283
1288
|
}
|
|
1284
1289
|
let scopeString = typeof scopes === "string" ? scopes : scopes.join(" ");
|
|
@@ -2470,48 +2475,43 @@ const imdsMsi = {
|
|
|
2470
2475
|
skipQuery: true,
|
|
2471
2476
|
});
|
|
2472
2477
|
return tracingClient.withSpan("ManagedIdentityCredential-pingImdsEndpoint", getTokenOptions, async (options) => {
|
|
2473
|
-
var _a
|
|
2478
|
+
var _a;
|
|
2474
2479
|
requestOptions.tracingOptions = options.tracingOptions;
|
|
2480
|
+
// Create a request with a timeout since we expect that
|
|
2481
|
+
// not having a "Metadata" header should cause an error to be
|
|
2482
|
+
// returned quickly from the endpoint, proving its availability.
|
|
2483
|
+
const request = coreRestPipeline.createPipelineRequest(requestOptions);
|
|
2484
|
+
// Default to 300 if the default of 0 is used.
|
|
2485
|
+
// Negative values can still be used to disable the timeout.
|
|
2486
|
+
request.timeout = ((_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.timeout) || 300;
|
|
2487
|
+
// This MSI uses the imdsEndpoint to get the token, which only uses http://
|
|
2488
|
+
request.allowInsecureConnection = true;
|
|
2475
2489
|
try {
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
// returned quickly from the endpoint, proving its availability.
|
|
2479
|
-
const request = coreRestPipeline.createPipelineRequest(requestOptions);
|
|
2480
|
-
request.timeout = (_b = (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.timeout) !== null && _b !== void 0 ? _b : 300;
|
|
2481
|
-
// This MSI uses the imdsEndpoint to get the token, which only uses http://
|
|
2482
|
-
request.allowInsecureConnection = true;
|
|
2483
|
-
try {
|
|
2484
|
-
logger$a.info(`${msiName$4}: Pinging the Azure IMDS endpoint`);
|
|
2485
|
-
await identityClient.sendRequest(request);
|
|
2486
|
-
}
|
|
2487
|
-
catch (err) {
|
|
2488
|
-
if ((err.name === "RestError" && err.code === coreRestPipeline.RestError.REQUEST_SEND_ERROR) ||
|
|
2489
|
-
err.name === "AbortError" ||
|
|
2490
|
-
err.code === "ENETUNREACH" || // Network unreachable
|
|
2491
|
-
err.code === "ECONNREFUSED" || // connection refused
|
|
2492
|
-
err.code === "EHOSTDOWN" // host is down
|
|
2493
|
-
) {
|
|
2494
|
-
// If the request failed, or Node.js was unable to establish a connection,
|
|
2495
|
-
// or the host was down, we'll assume the IMDS endpoint isn't available.
|
|
2496
|
-
logger$a.info(`${msiName$4}: The Azure IMDS endpoint is unavailable`);
|
|
2497
|
-
return false;
|
|
2498
|
-
}
|
|
2499
|
-
}
|
|
2500
|
-
// If we received any response, the endpoint is available
|
|
2501
|
-
logger$a.info(`${msiName$4}: The Azure IMDS endpoint is available`);
|
|
2502
|
-
return true;
|
|
2490
|
+
logger$a.info(`${msiName$4}: Pinging the Azure IMDS endpoint`);
|
|
2491
|
+
await identityClient.sendRequest(request);
|
|
2503
2492
|
}
|
|
2504
2493
|
catch (err) {
|
|
2505
|
-
//
|
|
2506
|
-
//
|
|
2507
|
-
|
|
2508
|
-
|
|
2494
|
+
// If the request failed, or Node.js was unable to establish a connection,
|
|
2495
|
+
// or the host was down, we'll assume the IMDS endpoint isn't available.
|
|
2496
|
+
if (coreUtil.isError(err)) {
|
|
2497
|
+
logger$a.verbose(`${msiName$4}: Caught error ${err.name}: ${err.message}`);
|
|
2498
|
+
}
|
|
2499
|
+
logger$a.info(`${msiName$4}: The Azure IMDS endpoint is unavailable`);
|
|
2500
|
+
return false;
|
|
2509
2501
|
}
|
|
2502
|
+
// If we received any response, the endpoint is available
|
|
2503
|
+
logger$a.info(`${msiName$4}: The Azure IMDS endpoint is available`);
|
|
2504
|
+
return true;
|
|
2510
2505
|
});
|
|
2511
2506
|
},
|
|
2512
2507
|
async getToken(configuration, getTokenOptions = {}) {
|
|
2513
2508
|
const { identityClient, scopes, clientId, resourceId } = configuration;
|
|
2514
|
-
|
|
2509
|
+
if (process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST) {
|
|
2510
|
+
logger$a.info(`${msiName$4}: Using the Azure IMDS endpoint coming from the environment variable AZURE_POD_IDENTITY_AUTHORITY_HOST=${process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST}.`);
|
|
2511
|
+
}
|
|
2512
|
+
else {
|
|
2513
|
+
logger$a.info(`${msiName$4}: Using the default Azure IMDS endpoint ${imdsHost}.`);
|
|
2514
|
+
}
|
|
2515
2515
|
let nextDelayInMs = imdsMsiRetryConfig.startDelayInMs;
|
|
2516
2516
|
for (let retries = 0; retries < imdsMsiRetryConfig.maxRetries; retries++) {
|
|
2517
2517
|
try {
|
|
@@ -3103,7 +3103,6 @@ class DefaultManagedIdentityCredential extends ManagedIdentityCredential {
|
|
|
3103
3103
|
const defaultCredentials = [
|
|
3104
3104
|
EnvironmentCredential,
|
|
3105
3105
|
DefaultManagedIdentityCredential,
|
|
3106
|
-
VisualStudioCodeCredential,
|
|
3107
3106
|
AzureCliCredential,
|
|
3108
3107
|
AzurePowerShellCredential,
|
|
3109
3108
|
];
|