@azure/identity 2.1.1-alpha.20220712.2 → 3.0.0-alpha.20220809.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 +24 -4
- package/dist/index.js.map +1 -1
- package/dist-esm/src/constants.js +1 -1
- package/dist-esm/src/constants.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.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/environmentCredential.js +4 -1
- package/dist-esm/src/credentials/environmentCredential.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/msal/nodeFlows/msalClientCertificate.js +19 -2
- package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js.map +1 -1
- package/package.json +1 -1
- package/types/identity.d.ts +9 -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
|
@@ -189,7 +189,7 @@ function getIdentityTokenEndpointSuffix(tenantId) {
|
|
|
189
189
|
/**
|
|
190
190
|
* Current version of the `@azure/identity` package.
|
|
191
191
|
*/
|
|
192
|
-
const SDK_VERSION = `
|
|
192
|
+
const SDK_VERSION = `3.0.0-beta.1`;
|
|
193
193
|
/**
|
|
194
194
|
* The default client ID for authentication
|
|
195
195
|
* @internal
|
|
@@ -1279,6 +1279,7 @@ class VisualStudioCodeCredential {
|
|
|
1279
1279
|
"You must install the identity-vscode plugin package (`npm install --save-dev @azure/identity-vscode`)",
|
|
1280
1280
|
"and enable it by importing `useIdentityPlugin` from `@azure/identity` and calling",
|
|
1281
1281
|
"`useIdentityPlugin(vsCodePlugin)` before creating a `VisualStudioCodeCredential`.",
|
|
1282
|
+
"To troubleshoot, visit https://aka.ms/azsdk/js/identity/vscodecredential/troubleshoot.",
|
|
1282
1283
|
].join(" "));
|
|
1283
1284
|
}
|
|
1284
1285
|
let scopeString = typeof scopes === "string" ? scopes : scopes.join(" ");
|
|
@@ -1918,9 +1919,26 @@ class MsalClientCertificate extends MsalNode {
|
|
|
1918
1919
|
async init(options) {
|
|
1919
1920
|
try {
|
|
1920
1921
|
const parts = await parseCertificate(this.configuration, this.sendCertificateChain);
|
|
1922
|
+
let privateKey;
|
|
1923
|
+
if (this.configuration.certificatePassword !== undefined) {
|
|
1924
|
+
const privateKeyObject = crypto.createPrivateKey({
|
|
1925
|
+
key: parts.certificateContents,
|
|
1926
|
+
passphrase: this.configuration.certificatePassword,
|
|
1927
|
+
format: "pem",
|
|
1928
|
+
});
|
|
1929
|
+
privateKey = privateKeyObject
|
|
1930
|
+
.export({
|
|
1931
|
+
format: "pem",
|
|
1932
|
+
type: "pkcs8",
|
|
1933
|
+
})
|
|
1934
|
+
.toString();
|
|
1935
|
+
}
|
|
1936
|
+
else {
|
|
1937
|
+
privateKey = parts.certificateContents;
|
|
1938
|
+
}
|
|
1921
1939
|
this.msalConfig.auth.clientCertificate = {
|
|
1922
1940
|
thumbprint: parts.thumbprint,
|
|
1923
|
-
privateKey:
|
|
1941
|
+
privateKey: privateKey,
|
|
1924
1942
|
x5c: parts.x5c,
|
|
1925
1943
|
};
|
|
1926
1944
|
}
|
|
@@ -2095,6 +2113,7 @@ const AllSupportedEnvironmentVariables = [
|
|
|
2095
2113
|
"AZURE_CLIENT_ID",
|
|
2096
2114
|
"AZURE_CLIENT_SECRET",
|
|
2097
2115
|
"AZURE_CLIENT_CERTIFICATE_PATH",
|
|
2116
|
+
"AZURE_CLIENT_CERTIFICATE_PASSWORD",
|
|
2098
2117
|
"AZURE_USERNAME",
|
|
2099
2118
|
"AZURE_PASSWORD",
|
|
2100
2119
|
];
|
|
@@ -2115,6 +2134,7 @@ class EnvironmentCredential {
|
|
|
2115
2134
|
* Environment variables used for client credential authentication:
|
|
2116
2135
|
* - `AZURE_CLIENT_SECRET`: A client secret that was generated for the App Registration.
|
|
2117
2136
|
* - `AZURE_CLIENT_CERTIFICATE_PATH`: The path to a PEM certificate to use during the authentication, instead of the client secret.
|
|
2137
|
+
* - `AZURE_CLIENT_CERTIFICATE_PASSWORD`: (optional) password for the certificate file.
|
|
2118
2138
|
*
|
|
2119
2139
|
* Alternatively, users can provide environment variables for username and password authentication:
|
|
2120
2140
|
* - `AZURE_USERNAME`: Username to authenticate with.
|
|
@@ -2140,9 +2160,10 @@ class EnvironmentCredential {
|
|
|
2140
2160
|
return;
|
|
2141
2161
|
}
|
|
2142
2162
|
const certificatePath = process.env.AZURE_CLIENT_CERTIFICATE_PATH;
|
|
2163
|
+
const certificatePassword = process.env.AZURE_CLIENT_CERTIFICATE_PASSWORD;
|
|
2143
2164
|
if (tenantId && clientId && certificatePath) {
|
|
2144
2165
|
logger$d.info(`Invoking ClientCertificateCredential with tenant ID: ${tenantId}, clientId: ${clientId} and certificatePath: ${certificatePath}`);
|
|
2145
|
-
this._credential = new ClientCertificateCredential(tenantId, clientId, { certificatePath }, options);
|
|
2166
|
+
this._credential = new ClientCertificateCredential(tenantId, clientId, { certificatePath, certificatePassword }, options);
|
|
2146
2167
|
return;
|
|
2147
2168
|
}
|
|
2148
2169
|
const username = process.env.AZURE_USERNAME;
|
|
@@ -3083,7 +3104,6 @@ class DefaultManagedIdentityCredential extends ManagedIdentityCredential {
|
|
|
3083
3104
|
const defaultCredentials = [
|
|
3084
3105
|
EnvironmentCredential,
|
|
3085
3106
|
DefaultManagedIdentityCredential,
|
|
3086
|
-
VisualStudioCodeCredential,
|
|
3087
3107
|
AzureCliCredential,
|
|
3088
3108
|
AzurePowerShellCredential,
|
|
3089
3109
|
];
|