@azure/identity 3.2.0-alpha.20230420.2 → 3.2.0-alpha.20230421.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/dist/index.js +44 -15
- package/dist/index.js.map +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js +31 -11
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredential.js +13 -4
- package/dist-esm/src/credentials/workloadIdentityCredential.js.map +1 -1
- package/package.json +1 -1
- package/types/identity.d.ts +36 -8
package/dist/index.js
CHANGED
|
@@ -1970,9 +1970,18 @@ const SupportedWorkloadEnvironmentVariables = [
|
|
|
1970
1970
|
];
|
|
1971
1971
|
const logger$g = credentialLogger(credentialName$3);
|
|
1972
1972
|
/**
|
|
1973
|
-
*
|
|
1974
|
-
*
|
|
1975
|
-
*
|
|
1973
|
+
* Workload Identity authentication is a feature in Azure that allows applications running on virtual machines (VMs)
|
|
1974
|
+
* to access other Azure resources without the need for a service principal or managed identity. With Workload Identity
|
|
1975
|
+
* authentication, applications authenticate themselves using their own identity, rather than using a shared service
|
|
1976
|
+
* principal or managed identity. Under the hood, Workload Identity authentication uses the concept of Service Account
|
|
1977
|
+
* Credentials (SACs), which are automatically created by Azure and stored securely in the VM. By using Workload
|
|
1978
|
+
* Identity authentication, you can avoid the need to manage and rotate service principals or managed identities for
|
|
1979
|
+
* each application on each VM. Additionally, because SACs are created automatically and managed by Azure, you don't
|
|
1980
|
+
* need to worry about storing and securing sensitive credentials themselves.
|
|
1981
|
+
* The WorkloadIdentityCredential supports Azure workload identity authentication on Azure Kubernetes and acquires
|
|
1982
|
+
* a token using the SACs available in the Azure Kubernetes environment.
|
|
1983
|
+
* Refer to <a href="https://learn.microsoft.com/azure/aks/workload-identity-overview">Azure Active Directory
|
|
1984
|
+
* Workload Identity</a> for more information.
|
|
1976
1985
|
*/
|
|
1977
1986
|
class WorkloadIdentityCredential {
|
|
1978
1987
|
/**
|
|
@@ -2014,7 +2023,7 @@ class WorkloadIdentityCredential {
|
|
|
2014
2023
|
In DefaultAzureCredential and ManagedIdentityCredential, these can be provided as environment variables -
|
|
2015
2024
|
"AZURE_TENANT_ID",
|
|
2016
2025
|
"AZURE_CLIENT_ID",
|
|
2017
|
-
"AZURE_FEDERATED_TOKEN_FILE"`;
|
|
2026
|
+
"AZURE_FEDERATED_TOKEN_FILE". See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/workloadidentitycredential/troubleshoot `;
|
|
2018
2027
|
logger$g.info(errorMessage);
|
|
2019
2028
|
throw new CredentialUnavailableError(errorMessage);
|
|
2020
2029
|
}
|
|
@@ -3419,17 +3428,36 @@ const developerCliCredentialInternals = {
|
|
|
3419
3428
|
};
|
|
3420
3429
|
const logger$4 = credentialLogger("AzureDeveloperCliCredential");
|
|
3421
3430
|
/**
|
|
3422
|
-
*
|
|
3423
|
-
*
|
|
3424
|
-
*
|
|
3425
|
-
*
|
|
3431
|
+
* Azure Developer CLI is a command-line interface tool that allows developers to create, manage, and deploy
|
|
3432
|
+
* resources in Azure. It's built on top of the Azure CLI and provides additional functionality specific
|
|
3433
|
+
* to Azure developers. It allows users to authenticate as a user and/or a service principal against
|
|
3434
|
+
* <a href="https://learn.microsoft.com/azure/active-directory/fundamentals/">Azure Active Directory (Azure AD)
|
|
3435
|
+
* </a>. The AzureDeveloperCliCredential authenticates in a development environment and acquires a token on behalf of
|
|
3436
|
+
* the logged-in user or service principal in the Azure Developer CLI. It acts as the Azure Developer CLI logged in user or
|
|
3437
|
+
* service principal and executes an Azure CLI command underneath to authenticate the application against
|
|
3438
|
+
* Azure Active Directory.
|
|
3439
|
+
*
|
|
3440
|
+
* <h2> Configure AzureDeveloperCliCredential </h2>
|
|
3441
|
+
*
|
|
3442
|
+
* To use this credential, the developer needs to authenticate locally in Azure Developer CLI using one of the
|
|
3443
|
+
* commands below:
|
|
3444
|
+
*
|
|
3445
|
+
* <ol>
|
|
3446
|
+
* <li>Run "azd auth login" in Azure Developer CLI to authenticate interactively as a user.</li>
|
|
3447
|
+
* <li>Run "azd auth login --client-id clientID --client-secret clientSecret
|
|
3448
|
+
* --tenant-id tenantID" to authenticate as a service principal.</li>
|
|
3449
|
+
* </ol>
|
|
3450
|
+
*
|
|
3451
|
+
* You may need to repeat this process after a certain time period, depending on the refresh token validity in your
|
|
3452
|
+
* organization. Generally, the refresh token validity period is a few weeks to a few months.
|
|
3453
|
+
* AzureDeveloperCliCredential will prompt you to sign in again.
|
|
3426
3454
|
*/
|
|
3427
3455
|
class AzureDeveloperCliCredential {
|
|
3428
3456
|
/**
|
|
3429
3457
|
* Creates an instance of the {@link AzureDeveloperCliCredential}.
|
|
3430
3458
|
*
|
|
3431
3459
|
* To use this credential, ensure that you have already logged
|
|
3432
|
-
* in via the 'azd' tool using the command "azd login" from the commandline.
|
|
3460
|
+
* in via the 'azd' tool using the command "azd auth login" from the commandline.
|
|
3433
3461
|
*
|
|
3434
3462
|
* @param options - Options, to optionally allow multi-tenant requests.
|
|
3435
3463
|
*/
|
|
@@ -3457,19 +3485,20 @@ class AzureDeveloperCliCredential {
|
|
|
3457
3485
|
}
|
|
3458
3486
|
logger$4.getToken.info(`Using the scopes ${scopes}`);
|
|
3459
3487
|
return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {
|
|
3460
|
-
var _a, _b, _c;
|
|
3488
|
+
var _a, _b, _c, _d;
|
|
3461
3489
|
try {
|
|
3462
3490
|
const obj = await developerCliCredentialInternals.getAzdAccessToken(scopeList, tenantId, this.timeout);
|
|
3463
|
-
const isNotLoggedInError = (_a = obj.stderr) === null || _a === void 0 ? void 0 : _a.match("not logged in, run `azd login` to login")
|
|
3464
|
-
|
|
3465
|
-
|
|
3491
|
+
const isNotLoggedInError = ((_a = obj.stderr) === null || _a === void 0 ? void 0 : _a.match("not logged in, run `azd login` to login")) ||
|
|
3492
|
+
((_b = obj.stderr) === null || _b === void 0 ? void 0 : _b.match("not logged in, run `azd auth login` to login"));
|
|
3493
|
+
const isNotInstallError = ((_c = obj.stderr) === null || _c === void 0 ? void 0 : _c.match("azd:(.*)not found")) ||
|
|
3494
|
+
((_d = obj.stderr) === null || _d === void 0 ? void 0 : _d.startsWith("'azd' is not recognized"));
|
|
3466
3495
|
if (isNotInstallError || (obj.error && obj.error.code === "ENOENT")) {
|
|
3467
|
-
const error = new CredentialUnavailableError("Azure Developer CLI
|
|
3496
|
+
const error = new CredentialUnavailableError("Azure Developer CLI couldn't be found. To mitigate this issue, see the troubleshooting guidelines at https://aka.ms/azsdk/js/identity/azdevclicredential/troubleshoot.");
|
|
3468
3497
|
logger$4.getToken.info(formatError(scopes, error));
|
|
3469
3498
|
throw error;
|
|
3470
3499
|
}
|
|
3471
3500
|
if (isNotLoggedInError) {
|
|
3472
|
-
const error = new CredentialUnavailableError("Please run 'azd login' from a command prompt to authenticate before using this credential.");
|
|
3501
|
+
const error = new CredentialUnavailableError("Please run 'azd auth login' from a command prompt to authenticate before using this credential. For more information, see the troubleshooting guidelines at https://aka.ms/azsdk/js/identity/azdevclicredential/troubleshoot.");
|
|
3473
3502
|
logger$4.getToken.info(formatError(scopes, error));
|
|
3474
3503
|
throw error;
|
|
3475
3504
|
}
|