@azure/identity 2.1.0-alpha.20220413.2 → 2.1.0-alpha.20220419.3
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/CHANGELOG.md +4 -0
- package/README.md +29 -1
- package/dist/index.js +25 -21
- package/dist/index.js.map +1 -1
- package/dist-esm/src/client/identityClient.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js +2 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js +21 -18
- package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
- package/dist-esm/src/credentials/chainedTokenCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -1
- package/dist-esm/src/errors.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js +2 -2
- package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClientSecret.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
### Bugs Fixed
|
|
10
10
|
|
|
11
|
+
- Fixed a bug that would break the AzureCliCredential if the Azure CLI reported a warning. See: [21075](https://github.com/Azure/azure-sdk-for-js/issues/21075).
|
|
12
|
+
- Fixed a bug in `AuthorizationCodeCredential` where the tenant id was not being used. The `common` tenant was the only tenant being used by this credential.
|
|
13
|
+
- Fixed a bug in `AuthorizationCodeCredential` where the public client was not being used. Due to this bug, without passing in the client secret, this credential would fail.
|
|
14
|
+
|
|
11
15
|
### Other Changes
|
|
12
16
|
|
|
13
17
|
- Upgraded to `@azure/core-tracing` version `^1.0.0`.
|
package/README.md
CHANGED
|
@@ -284,7 +284,10 @@ Credentials raise `AuthenticationError` when they fail to authenticate. This cla
|
|
|
284
284
|
|
|
285
285
|
### Logging
|
|
286
286
|
|
|
287
|
-
Enabling logging may help uncover useful information about failures.
|
|
287
|
+
Enabling logging may help uncover useful information about failures.
|
|
288
|
+
|
|
289
|
+
To see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`.
|
|
290
|
+
You can read this environment variable from the *.env* file by explicitly specifying a file path:
|
|
288
291
|
|
|
289
292
|
```javascript
|
|
290
293
|
require("dotenv").config({ path: ".env" });
|
|
@@ -297,6 +300,31 @@ import { setLogLevel } from "@azure/logger";
|
|
|
297
300
|
|
|
298
301
|
setLogLevel("info");
|
|
299
302
|
```
|
|
303
|
+
|
|
304
|
+
In cases where the authenticate code might be running in an environment with more than one credential available,
|
|
305
|
+
the `@azure/identity` package offers a unique form of logging. On the optional parameters for every credential,
|
|
306
|
+
developers can set `allowLoggingAccountIdentifiers` to true in the
|
|
307
|
+
`loggingOptions` to log information specific to the authenticated account after
|
|
308
|
+
each successful authentication, including the Client ID, the Tenant ID, the
|
|
309
|
+
Object ID of the authenticated user, and if possible the User Principal Name.
|
|
310
|
+
|
|
311
|
+
For example, using the `DefaultAzureCredential`:
|
|
312
|
+
|
|
313
|
+
```js
|
|
314
|
+
import { setLogLevel } from "@azure/logger";
|
|
315
|
+
|
|
316
|
+
setLogLevel("info");
|
|
317
|
+
|
|
318
|
+
const credential = new DefaultAzureCredential({
|
|
319
|
+
loggingOptions: { allowLoggingAccountIdentifiers: true }
|
|
320
|
+
});
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Once that credential authenticates, the following message will appear in the logs (with the real information instead of `HIDDEN`):
|
|
324
|
+
|
|
325
|
+
```
|
|
326
|
+
azure:identity:info [Authenticated account] Client ID: HIDDEN. Tenant ID: HIDDEN. User Principal Name: HIDDEN. Object ID (user): HIDDEN
|
|
327
|
+
```
|
|
300
328
|
|
|
301
329
|
For assistance with troubleshooting, see the [troubleshooting guide](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/TROUBLESHOOTING.md).
|
|
302
330
|
|
package/dist/index.js
CHANGED
|
@@ -1541,29 +1541,24 @@ class AzureCliCredential {
|
|
|
1541
1541
|
logger$h.getToken.info(`Using the scope ${scope}`);
|
|
1542
1542
|
ensureValidScope(scope, logger$h);
|
|
1543
1543
|
const resource = getScopeResource(scope);
|
|
1544
|
-
let responseData = "";
|
|
1545
1544
|
return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {
|
|
1545
|
+
var _a, _b, _c;
|
|
1546
1546
|
try {
|
|
1547
1547
|
const obj = await cliCredentialInternals.getAzureCliAccessToken(resource, tenantId);
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
const error = new CredentialUnavailableError("Azure CLI could not be found. Please visit https://aka.ms/azure-cli for installation instructions and then, once installed, authenticate to your Azure account using 'az login'.");
|
|
1553
|
-
logger$h.getToken.info(formatError(scopes, error));
|
|
1554
|
-
throw error;
|
|
1555
|
-
}
|
|
1556
|
-
else if (isLoginError) {
|
|
1557
|
-
const error = new CredentialUnavailableError("Please run 'az login' from a command prompt to authenticate before using this credential.");
|
|
1558
|
-
logger$h.getToken.info(formatError(scopes, error));
|
|
1559
|
-
throw error;
|
|
1560
|
-
}
|
|
1561
|
-
const error = new CredentialUnavailableError(obj.stderr);
|
|
1548
|
+
const isLoginError = (_a = obj.stderr) === null || _a === void 0 ? void 0 : _a.match("(.*)az login(.*)");
|
|
1549
|
+
const isNotInstallError = ((_b = obj.stderr) === null || _b === void 0 ? void 0 : _b.match("az:(.*)not found")) || ((_c = obj.stderr) === null || _c === void 0 ? void 0 : _c.startsWith("'az' is not recognized"));
|
|
1550
|
+
if (isNotInstallError) {
|
|
1551
|
+
const error = new CredentialUnavailableError("Azure CLI could not be found. Please visit https://aka.ms/azure-cli for installation instructions and then, once installed, authenticate to your Azure account using 'az login'.");
|
|
1562
1552
|
logger$h.getToken.info(formatError(scopes, error));
|
|
1563
1553
|
throw error;
|
|
1564
1554
|
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1555
|
+
if (isLoginError) {
|
|
1556
|
+
const error = new CredentialUnavailableError("Please run 'az login' from a command prompt to authenticate before using this credential.");
|
|
1557
|
+
logger$h.getToken.info(formatError(scopes, error));
|
|
1558
|
+
throw error;
|
|
1559
|
+
}
|
|
1560
|
+
try {
|
|
1561
|
+
const responseData = obj.stdout;
|
|
1567
1562
|
const response = JSON.parse(responseData);
|
|
1568
1563
|
logger$h.getToken.info(formatSuccess(scopes));
|
|
1569
1564
|
const returnValue = {
|
|
@@ -1572,9 +1567,17 @@ class AzureCliCredential {
|
|
|
1572
1567
|
};
|
|
1573
1568
|
return returnValue;
|
|
1574
1569
|
}
|
|
1570
|
+
catch (e) {
|
|
1571
|
+
if (obj.stderr) {
|
|
1572
|
+
throw new CredentialUnavailableError(obj.stderr);
|
|
1573
|
+
}
|
|
1574
|
+
throw e;
|
|
1575
|
+
}
|
|
1575
1576
|
}
|
|
1576
1577
|
catch (err) {
|
|
1577
|
-
const error =
|
|
1578
|
+
const error = err.name === "CredentialUnavailableError"
|
|
1579
|
+
? err
|
|
1580
|
+
: new Error(err.message || "Unknown error while trying to retrieve the access token");
|
|
1578
1581
|
logger$h.getToken.info(formatError(scopes, error));
|
|
1579
1582
|
throw error;
|
|
1580
1583
|
}
|
|
@@ -3440,12 +3443,12 @@ class MsalAuthorizationCode extends MsalNode {
|
|
|
3440
3443
|
}
|
|
3441
3444
|
async getAuthCodeUrl(options) {
|
|
3442
3445
|
await this.init();
|
|
3443
|
-
return this.confidentialApp.getAuthCodeUrl(options);
|
|
3446
|
+
return (this.confidentialApp || this.publicApp).getAuthCodeUrl(options);
|
|
3444
3447
|
}
|
|
3445
3448
|
async doGetToken(scopes, options) {
|
|
3446
3449
|
var _a;
|
|
3447
3450
|
try {
|
|
3448
|
-
const result = await ((_a = this.confidentialApp) === null || _a === void 0 ? void 0 : _a.acquireTokenByCode({
|
|
3451
|
+
const result = await ((_a = (this.confidentialApp || this.publicApp)) === null || _a === void 0 ? void 0 : _a.acquireTokenByCode({
|
|
3449
3452
|
scopes,
|
|
3450
3453
|
redirectUri: this.redirectUri,
|
|
3451
3454
|
code: this.authorizationCode,
|
|
@@ -3494,7 +3497,8 @@ class AuthorizationCodeCredential {
|
|
|
3494
3497
|
options = redirectUriOrOptions;
|
|
3495
3498
|
}
|
|
3496
3499
|
this.msalFlow = new MsalAuthorizationCode(Object.assign(Object.assign({}, options), { clientSecret,
|
|
3497
|
-
clientId,
|
|
3500
|
+
clientId,
|
|
3501
|
+
tenantId, tokenCredentialOptions: options || {}, logger: logger$1, redirectUri: this.redirectUri, authorizationCode: this.authorizationCode }));
|
|
3498
3502
|
}
|
|
3499
3503
|
/**
|
|
3500
3504
|
* Authenticates with Azure Active Directory and returns an access token if successful.
|