@azure/identity 3.2.0-alpha.20230420.2 → 3.2.0-alpha.20230425.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 CHANGED
@@ -1970,9 +1970,18 @@ const SupportedWorkloadEnvironmentVariables = [
1970
1970
  ];
1971
1971
  const logger$g = credentialLogger(credentialName$3);
1972
1972
  /**
1973
- * WorkloadIdentityCredential supports Azure workload identity authentication on Kubernetes.
1974
- * Refer to <a href="https://learn.microsoft.com/azure/aks/workload-identity-overview">Azure Active Directory Workload Identity</a>
1975
- * for more information.
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
  /**
@@ -1990,8 +1999,7 @@ class WorkloadIdentityCredential {
1990
1999
  const tenantId = workloadIdentityCredentialOptions.tenantId || process.env.AZURE_TENANT_ID;
1991
2000
  const clientId = workloadIdentityCredentialOptions.clientId || process.env.AZURE_CLIENT_ID;
1992
2001
  this.federatedTokenFilePath =
1993
- workloadIdentityCredentialOptions.federatedTokenFilePath ||
1994
- process.env.AZURE_FEDERATED_TOKEN_FILE;
2002
+ workloadIdentityCredentialOptions.tokenFilePath || process.env.AZURE_FEDERATED_TOKEN_FILE;
1995
2003
  if (tenantId) {
1996
2004
  checkTenantId(logger$g, tenantId);
1997
2005
  }
@@ -2014,7 +2022,7 @@ class WorkloadIdentityCredential {
2014
2022
  In DefaultAzureCredential and ManagedIdentityCredential, these can be provided as environment variables -
2015
2023
  "AZURE_TENANT_ID",
2016
2024
  "AZURE_CLIENT_ID",
2017
- "AZURE_FEDERATED_TOKEN_FILE"`;
2025
+ "AZURE_FEDERATED_TOKEN_FILE". See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/workloadidentitycredential/troubleshoot `;
2018
2026
  logger$g.info(errorMessage);
2019
2027
  throw new CredentialUnavailableError(errorMessage);
2020
2028
  }
@@ -2066,7 +2074,7 @@ function tokenExchangeMsi() {
2066
2074
  async getToken(configuration, getTokenOptions = {}) {
2067
2075
  const { scopes, clientId } = configuration;
2068
2076
  const identityClientTokenCredentialOptions = {};
2069
- const workloadIdentityCredential = new WorkloadIdentityCredential(Object.assign(Object.assign({ clientId, tenantId: process.env.AZURE_TENANT_ID, federatedTokenFilePath: process.env.AZURE_FEDERATED_TOKEN_FILE }, identityClientTokenCredentialOptions), { disableInstanceDiscovery: true }));
2077
+ const workloadIdentityCredential = new WorkloadIdentityCredential(Object.assign(Object.assign({ clientId, tenantId: process.env.AZURE_TENANT_ID, tokenFilePath: process.env.AZURE_FEDERATED_TOKEN_FILE }, identityClientTokenCredentialOptions), { disableAuthorityValidationAndInstanceDiscovery: true }));
2070
2078
  const token = await workloadIdentityCredential.getToken(scopes, getTokenOptions);
2071
2079
  return token;
2072
2080
  },
@@ -3419,17 +3427,36 @@ const developerCliCredentialInternals = {
3419
3427
  };
3420
3428
  const logger$4 = credentialLogger("AzureDeveloperCliCredential");
3421
3429
  /**
3422
- * This credential will use the currently logged-in user login information
3423
- * via the Azure Developer CLI ('az') commandline tool.
3424
- * To do so, it will read the user access token and expire time
3425
- * with Azure Developer CLI command "azd auth token".
3430
+ * Azure Developer CLI is a command-line interface tool that allows developers to create, manage, and deploy
3431
+ * resources in Azure. It's built on top of the Azure CLI and provides additional functionality specific
3432
+ * to Azure developers. It allows users to authenticate as a user and/or a service principal against
3433
+ * <a href="https://learn.microsoft.com/azure/active-directory/fundamentals/">Azure Active Directory (Azure AD)
3434
+ * </a>. The AzureDeveloperCliCredential authenticates in a development environment and acquires a token on behalf of
3435
+ * the logged-in user or service principal in the Azure Developer CLI. It acts as the Azure Developer CLI logged in user or
3436
+ * service principal and executes an Azure CLI command underneath to authenticate the application against
3437
+ * Azure Active Directory.
3438
+ *
3439
+ * <h2> Configure AzureDeveloperCliCredential </h2>
3440
+ *
3441
+ * To use this credential, the developer needs to authenticate locally in Azure Developer CLI using one of the
3442
+ * commands below:
3443
+ *
3444
+ * <ol>
3445
+ * <li>Run "azd auth login" in Azure Developer CLI to authenticate interactively as a user.</li>
3446
+ * <li>Run "azd auth login --client-id clientID --client-secret clientSecret
3447
+ * --tenant-id tenantID" to authenticate as a service principal.</li>
3448
+ * </ol>
3449
+ *
3450
+ * You may need to repeat this process after a certain time period, depending on the refresh token validity in your
3451
+ * organization. Generally, the refresh token validity period is a few weeks to a few months.
3452
+ * AzureDeveloperCliCredential will prompt you to sign in again.
3426
3453
  */
3427
3454
  class AzureDeveloperCliCredential {
3428
3455
  /**
3429
3456
  * Creates an instance of the {@link AzureDeveloperCliCredential}.
3430
3457
  *
3431
3458
  * To use this credential, ensure that you have already logged
3432
- * in via the 'azd' tool using the command "azd login" from the commandline.
3459
+ * in via the 'azd' tool using the command "azd auth login" from the commandline.
3433
3460
  *
3434
3461
  * @param options - Options, to optionally allow multi-tenant requests.
3435
3462
  */
@@ -3457,19 +3484,20 @@ class AzureDeveloperCliCredential {
3457
3484
  }
3458
3485
  logger$4.getToken.info(`Using the scopes ${scopes}`);
3459
3486
  return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {
3460
- var _a, _b, _c;
3487
+ var _a, _b, _c, _d;
3461
3488
  try {
3462
3489
  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
- const isNotInstallError = ((_b = obj.stderr) === null || _b === void 0 ? void 0 : _b.match("azd:(.*)not found")) ||
3465
- ((_c = obj.stderr) === null || _c === void 0 ? void 0 : _c.startsWith("'azd' is not recognized"));
3490
+ const isNotLoggedInError = ((_a = obj.stderr) === null || _a === void 0 ? void 0 : _a.match("not logged in, run `azd login` to login")) ||
3491
+ ((_b = obj.stderr) === null || _b === void 0 ? void 0 : _b.match("not logged in, run `azd auth login` to login"));
3492
+ const isNotInstallError = ((_c = obj.stderr) === null || _c === void 0 ? void 0 : _c.match("azd:(.*)not found")) ||
3493
+ ((_d = obj.stderr) === null || _d === void 0 ? void 0 : _d.startsWith("'azd' is not recognized"));
3466
3494
  if (isNotInstallError || (obj.error && obj.error.code === "ENOENT")) {
3467
- const error = new CredentialUnavailableError("Azure Developer CLI could not be found. Please visit https://aka.ms/azure-dev for installation instructions and then, once installed, authenticate to your Azure account using 'azd login'.");
3495
+ 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
3496
  logger$4.getToken.info(formatError(scopes, error));
3469
3497
  throw error;
3470
3498
  }
3471
3499
  if (isNotLoggedInError) {
3472
- const error = new CredentialUnavailableError("Please run 'azd login' from a command prompt to authenticate before using this credential.");
3500
+ 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
3501
  logger$4.getToken.info(formatError(scopes, error));
3474
3502
  throw error;
3475
3503
  }
@@ -3550,7 +3578,7 @@ class DefaultWorkloadIdentityCredential extends WorkloadIdentityCredential {
3550
3578
  const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;
3551
3579
  const tenantId = (_c = options === null || options === void 0 ? void 0 : options.tenantId) !== null && _c !== void 0 ? _c : process.env.AZURE_TENANT_ID;
3552
3580
  if (workloadFile && workloadIdentityClientId) {
3553
- const workloadIdentityCredentialOptions = Object.assign(Object.assign({}, options), { tenantId, clientId: workloadIdentityClientId, federatedTokenFilePath: workloadFile });
3581
+ const workloadIdentityCredentialOptions = Object.assign(Object.assign({}, options), { tenantId, clientId: workloadIdentityClientId, tokenFilePath: workloadFile });
3554
3582
  super(workloadIdentityCredentialOptions);
3555
3583
  }
3556
3584
  else if (tenantId) {
@@ -3564,17 +3592,17 @@ class DefaultWorkloadIdentityCredential extends WorkloadIdentityCredential {
3564
3592
  }
3565
3593
  class DefaultAzureDeveloperCliCredential extends AzureDeveloperCliCredential {
3566
3594
  constructor(options) {
3567
- super(Object.assign({ processTimeoutInMs: options === null || options === void 0 ? void 0 : options.developerCredentialTimeOutInMs }, options));
3595
+ super(Object.assign({ processTimeoutInMs: options === null || options === void 0 ? void 0 : options.credentialProcessTimeoutInMs }, options));
3568
3596
  }
3569
3597
  }
3570
3598
  class DefaultAzureCliCredential extends AzureCliCredential {
3571
3599
  constructor(options) {
3572
- super(Object.assign({ processTimeoutInMs: options === null || options === void 0 ? void 0 : options.developerCredentialTimeOutInMs }, options));
3600
+ super(Object.assign({ processTimeoutInMs: options === null || options === void 0 ? void 0 : options.credentialProcessTimeoutInMs }, options));
3573
3601
  }
3574
3602
  }
3575
3603
  class DefaultAzurePowershellCredential extends AzurePowerShellCredential {
3576
3604
  constructor(options) {
3577
- super(Object.assign({ processTimeoutInMs: options === null || options === void 0 ? void 0 : options.developerCredentialTimeOutInMs }, options));
3605
+ super(Object.assign({ processTimeoutInMs: options === null || options === void 0 ? void 0 : options.credentialProcessTimeoutInMs }, options));
3578
3606
  }
3579
3607
  }
3580
3608
  const defaultCredentials = [