@azure/identity 3.2.0-alpha.20230418.1 → 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 +52 -19
- 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/chainedTokenCredential.js +8 -4
- package/dist-esm/src/credentials/chainedTokenCredential.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 +37 -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
|
}
|
|
@@ -2893,14 +2902,18 @@ class ChainedTokenCredential {
|
|
|
2893
2902
|
* `TokenCredential` implementation might make.
|
|
2894
2903
|
*/
|
|
2895
2904
|
async getToken(scopes, options = {}) {
|
|
2905
|
+
const { token } = await this.getTokenInternal(scopes, options);
|
|
2906
|
+
return token;
|
|
2907
|
+
}
|
|
2908
|
+
async getTokenInternal(scopes, options = {}) {
|
|
2896
2909
|
let token = null;
|
|
2897
|
-
let
|
|
2910
|
+
let successfulCredential;
|
|
2898
2911
|
const errors = [];
|
|
2899
2912
|
return tracingClient.withSpan("ChainedTokenCredential.getToken", options, async (updatedOptions) => {
|
|
2900
2913
|
for (let i = 0; i < this._sources.length && token === null; i++) {
|
|
2901
2914
|
try {
|
|
2902
2915
|
token = await this._sources[i].getToken(scopes, updatedOptions);
|
|
2903
|
-
|
|
2916
|
+
successfulCredential = this._sources[i];
|
|
2904
2917
|
}
|
|
2905
2918
|
catch (err) {
|
|
2906
2919
|
if (err.name === "CredentialUnavailableError" ||
|
|
@@ -2918,11 +2931,11 @@ class ChainedTokenCredential {
|
|
|
2918
2931
|
logger$9.getToken.info(formatError(scopes, err));
|
|
2919
2932
|
throw err;
|
|
2920
2933
|
}
|
|
2921
|
-
logger$9.getToken.info(`Result for ${
|
|
2934
|
+
logger$9.getToken.info(`Result for ${successfulCredential.constructor.name}: ${formatSuccess(scopes)}`);
|
|
2922
2935
|
if (token === null) {
|
|
2923
2936
|
throw new CredentialUnavailableError("Failed to retrieve a valid token");
|
|
2924
2937
|
}
|
|
2925
|
-
return token;
|
|
2938
|
+
return { token, successfulCredential };
|
|
2926
2939
|
});
|
|
2927
2940
|
}
|
|
2928
2941
|
}
|
|
@@ -3415,17 +3428,36 @@ const developerCliCredentialInternals = {
|
|
|
3415
3428
|
};
|
|
3416
3429
|
const logger$4 = credentialLogger("AzureDeveloperCliCredential");
|
|
3417
3430
|
/**
|
|
3418
|
-
*
|
|
3419
|
-
*
|
|
3420
|
-
*
|
|
3421
|
-
*
|
|
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.
|
|
3422
3454
|
*/
|
|
3423
3455
|
class AzureDeveloperCliCredential {
|
|
3424
3456
|
/**
|
|
3425
3457
|
* Creates an instance of the {@link AzureDeveloperCliCredential}.
|
|
3426
3458
|
*
|
|
3427
3459
|
* To use this credential, ensure that you have already logged
|
|
3428
|
-
* 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.
|
|
3429
3461
|
*
|
|
3430
3462
|
* @param options - Options, to optionally allow multi-tenant requests.
|
|
3431
3463
|
*/
|
|
@@ -3453,19 +3485,20 @@ class AzureDeveloperCliCredential {
|
|
|
3453
3485
|
}
|
|
3454
3486
|
logger$4.getToken.info(`Using the scopes ${scopes}`);
|
|
3455
3487
|
return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {
|
|
3456
|
-
var _a, _b, _c;
|
|
3488
|
+
var _a, _b, _c, _d;
|
|
3457
3489
|
try {
|
|
3458
3490
|
const obj = await developerCliCredentialInternals.getAzdAccessToken(scopeList, tenantId, this.timeout);
|
|
3459
|
-
const isNotLoggedInError = (_a = obj.stderr) === null || _a === void 0 ? void 0 : _a.match("not logged in, run `azd login` to login")
|
|
3460
|
-
|
|
3461
|
-
|
|
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"));
|
|
3462
3495
|
if (isNotInstallError || (obj.error && obj.error.code === "ENOENT")) {
|
|
3463
|
-
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.");
|
|
3464
3497
|
logger$4.getToken.info(formatError(scopes, error));
|
|
3465
3498
|
throw error;
|
|
3466
3499
|
}
|
|
3467
3500
|
if (isNotLoggedInError) {
|
|
3468
|
-
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.");
|
|
3469
3502
|
logger$4.getToken.info(formatError(scopes, error));
|
|
3470
3503
|
throw error;
|
|
3471
3504
|
}
|