@azure/identity 4.5.0-beta.2 → 4.5.0-beta.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +45 -49
- package/dist/index.js +119 -60
- package/dist/index.js.map +1 -1
- package/dist-esm/src/client/identityClient.js +3 -2
- package/dist-esm/src/client/identityClient.js.map +1 -1
- package/dist-esm/src/constants.js +2 -2
- package/dist-esm/src/constants.js.map +1 -1
- package/dist-esm/src/credentials/authorityValidationOptions.js +1 -1
- package/dist-esm/src/credentials/authorityValidationOptions.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.browser.js +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/azureApplicationCredential.browser.js +1 -1
- package/dist-esm/src/credentials/azureApplicationCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/azureApplicationCredential.js +1 -1
- package/dist-esm/src/credentials/azureApplicationCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureApplicationCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/azureApplicationCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredential.browser.js +1 -1
- package/dist-esm/src/credentials/azureCliCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/azureCliCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.browser.js +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/azurePipelinesCredential.browser.js +1 -1
- package/dist-esm/src/credentials/azurePipelinesCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/azurePipelinesCredential.js +1 -1
- package/dist-esm/src/credentials/azurePipelinesCredential.js.map +1 -1
- package/dist-esm/src/credentials/azurePipelinesCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/azurePipelinesCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.browser.js +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.js +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/brokerAuthOptions.js.map +1 -1
- package/dist-esm/src/credentials/browserCustomizationOptions.js +1 -1
- package/dist-esm/src/credentials/browserCustomizationOptions.js.map +1 -1
- package/dist-esm/src/credentials/chainedTokenCredential.js +1 -1
- package/dist-esm/src/credentials/chainedTokenCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientAssertionCredential.browser.js +1 -1
- package/dist-esm/src/credentials/clientAssertionCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/clientAssertionCredential.js +1 -1
- package/dist-esm/src/credentials/clientAssertionCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientAssertionCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/clientAssertionCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.browser.js +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.js +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/clientCertificateCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.browser.js +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.js +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/clientSecretCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/credentialPersistenceOptions.js +1 -1
- package/dist-esm/src/credentials/credentialPersistenceOptions.js.map +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.browser.js +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.js +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.js.map +1 -1
- package/dist-esm/src/credentials/defaultAzureCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/defaultAzureCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.browser.js +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.js +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/deviceCodeCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.browser.js +1 -1
- package/dist-esm/src/credentials/environmentCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.js +1 -1
- package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/environmentCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.js +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/interactiveCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/interactiveCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2019.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2019.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/constants.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/constants.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/imdsRetryPolicy.js +6 -10
- package/dist-esm/src/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.browser.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.browser.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/legacyMsiProvider.js +7 -1
- package/dist-esm/src/credentials/managedIdentityCredential/legacyMsiProvider.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/models.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/models.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/msalMsiProvider.js +20 -4
- package/dist-esm/src/credentials/managedIdentityCredential/msalMsiProvider.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/utils.js +26 -1
- package/dist-esm/src/credentials/managedIdentityCredential/utils.js.map +1 -1
- package/dist-esm/src/credentials/multiTenantTokenCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/multiTenantTokenCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.browser.js +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.js +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.browser.js +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.js +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.js +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredentialPlugin.js +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredentialPlugin.js.map +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredential.browser.js +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredential.js +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredential.js.map +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredentialOptions.js.map +1 -1
- package/dist-esm/src/errors.js +1 -2
- package/dist-esm/src/errors.js.map +1 -1
- package/dist-esm/src/index.js +1 -1
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/flows.js +1 -1
- package/dist-esm/src/msal/browserFlows/flows.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js +1 -1
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js +3 -1
- package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js.map +1 -1
- package/dist-esm/src/msal/credentials.js +1 -1
- package/dist-esm/src/msal/credentials.js.map +1 -1
- package/dist-esm/src/msal/msal.browser.js +1 -1
- package/dist-esm/src/msal/msal.browser.js.map +1 -1
- package/dist-esm/src/msal/msal.js +1 -1
- package/dist-esm/src/msal/msal.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/brokerOptions.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClient.js +17 -8
- package/dist-esm/src/msal/nodeFlows/msalClient.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalPlugins.js +1 -1
- package/dist-esm/src/msal/nodeFlows/msalPlugins.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/tokenCachePersistenceOptions.js +1 -1
- package/dist-esm/src/msal/nodeFlows/tokenCachePersistenceOptions.js.map +1 -1
- package/dist-esm/src/msal/types.js +1 -1
- package/dist-esm/src/msal/types.js.map +1 -1
- package/dist-esm/src/msal/utils.js +15 -2
- package/dist-esm/src/msal/utils.js.map +1 -1
- package/dist-esm/src/plugins/consumer.browser.js +1 -1
- package/dist-esm/src/plugins/consumer.browser.js.map +1 -1
- package/dist-esm/src/plugins/consumer.js +1 -1
- package/dist-esm/src/plugins/consumer.js.map +1 -1
- package/dist-esm/src/plugins/provider.js +1 -1
- package/dist-esm/src/plugins/provider.js.map +1 -1
- package/dist-esm/src/regionalAuthority.js +1 -1
- package/dist-esm/src/regionalAuthority.js.map +1 -1
- package/dist-esm/src/tokenCredentialOptions.js +1 -1
- package/dist-esm/src/tokenCredentialOptions.js.map +1 -1
- package/dist-esm/src/tokenProvider.js +1 -1
- package/dist-esm/src/tokenProvider.js.map +1 -1
- package/dist-esm/src/util/authHostEnv.browser.js +1 -1
- package/dist-esm/src/util/authHostEnv.browser.js.map +1 -1
- package/dist-esm/src/util/identityTokenEndpoint.js +1 -1
- package/dist-esm/src/util/identityTokenEndpoint.js.map +1 -1
- package/dist-esm/src/util/logging.js +1 -1
- package/dist-esm/src/util/logging.js.map +1 -1
- package/dist-esm/src/util/processMultiTenantRequest.browser.js +1 -1
- package/dist-esm/src/util/processMultiTenantRequest.browser.js.map +1 -1
- package/dist-esm/src/util/processMultiTenantRequest.js +1 -1
- package/dist-esm/src/util/processMultiTenantRequest.js.map +1 -1
- package/dist-esm/src/util/processUtils.js +1 -1
- package/dist-esm/src/util/processUtils.js.map +1 -1
- package/dist-esm/src/util/scopeUtils.js +1 -1
- package/dist-esm/src/util/scopeUtils.js.map +1 -1
- package/dist-esm/src/util/tenantIdUtils.js +1 -1
- package/dist-esm/src/util/tenantIdUtils.js.map +1 -1
- package/dist-esm/src/util/tracing.js +1 -1
- package/dist-esm/src/util/tracing.js.map +1 -1
- package/package.json +7 -7
- package/types/identity.d.ts +21 -3
package/README.md
CHANGED
@@ -17,11 +17,10 @@ Key links:
|
|
17
17
|
### Currently supported environments
|
18
18
|
|
19
19
|
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
|
20
|
-
- **Note:** If your application runs on Node.js v8 or lower and you cannot upgrade your Node.js version to latest stable version, then pin your `@azure/identity` dependency to version 1.1.0.
|
21
20
|
- Latest versions of Safari, Chrome, Edge, and Firefox.
|
22
|
-
- **Note**: Among the different credentials exported in this library, `InteractiveBrowserCredential` is the only one
|
21
|
+
- **Note**: Among the different credentials exported in this library, `InteractiveBrowserCredential` is the only one supported in the browser.
|
23
22
|
|
24
|
-
|
23
|
+
For more information, see our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md).
|
25
24
|
|
26
25
|
### Install the package
|
27
26
|
|
@@ -46,7 +45,7 @@ Most of the credential types offered by `@azure/identity` use the [Microsoft Aut
|
|
46
45
|
|
47
46
|
#### When to use something else
|
48
47
|
|
49
|
-
The `@azure/identity` credential types are implementations of [@azure/core-auth](https://www.npmjs.com/package/@azure/core-auth)'s `TokenCredential` class. In principle, any object with a `getToken` method that satisfies `getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>`
|
48
|
+
The `@azure/identity` credential types are implementations of [@azure/core-auth](https://www.npmjs.com/package/@azure/core-auth)'s `TokenCredential` class. In principle, any object with a `getToken` method that satisfies `getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>` works as a `TokenCredential`. This means developers can write their own credential types to support authentication cases not covered by `@azure/identity`. To learn more, see [Custom Credentials](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#custom-credentials).
|
50
49
|
|
51
50
|
Though our credential types support many advanced cases, developers may want full control of the authentication protocol. For that use case, we recommend using [Microsoft Authentication Library for JavaScript (MSAL.js)](https://github.com/AzureAD/microsoft-authentication-library-for-js) directly. You can read more through the following links:
|
52
51
|
|
@@ -58,25 +57,25 @@ For advanced authentication workflows in the browser, we have a section where we
|
|
58
57
|
|
59
58
|
### Authenticate the client in development environment
|
60
59
|
|
61
|
-
While we recommend using managed identity in your Azure-hosted application, it
|
60
|
+
While we recommend using managed identity in your Azure-hosted application, it's typical for a developer to use their own account for authenticating calls to Azure services when debugging and executing code locally. There are several developer tools that can be used to perform this authentication in your development environment.
|
62
61
|
|
63
62
|
#### Authenticate via the Azure Developer CLI
|
64
63
|
|
65
64
|
Developers coding outside of an IDE can also use the [Azure Developer CLI][azure_developer_cli] to authenticate. Applications using the `DefaultAzureCredential` or the `AzureDeveloperCliCredential` can then use this account to authenticate calls in their application when running locally.
|
66
65
|
|
67
|
-
To authenticate with the [Azure Developer CLI][azure_developer_cli], users can run the command `azd auth login`. For users running on a system with a default web browser, the Azure Developer CLI
|
66
|
+
To authenticate with the [Azure Developer CLI][azure_developer_cli], users can run the command `azd auth login`. For users running on a system with a default web browser, the Azure Developer CLI launches the browser to authenticate the user.
|
68
67
|
|
69
|
-
For systems without a default web browser, the `azd auth login --use-device-code` command
|
68
|
+
For systems without a default web browser, the `azd auth login --use-device-code` command uses the device code authentication flow.
|
70
69
|
|
71
70
|
#### Authenticate via the Azure CLI
|
72
71
|
|
73
72
|
Applications using the `AzureCliCredential`, whether directly or via the `DefaultAzureCredential`, can use the Azure CLI account to authenticate calls in the application when running locally.
|
74
73
|
|
75
|
-
To authenticate with the [Azure CLI][azure_cli]
|
74
|
+
To authenticate with the [Azure CLI][azure_cli], run the command `az login`. For users running on a system with a default web browser, the Azure CLI launches the browser to authenticate the user.
|
76
75
|
|
77
76
|
![Azure CLI Account Sign In][azureclilogin_image]
|
78
77
|
|
79
|
-
For systems without a default web browser, the `az login` command
|
78
|
+
For systems without a default web browser, the `az login` command uses the device code authentication flow. The user can also force the Azure CLI to use the device code flow rather than launching a browser by specifying the `--use-device-code` argument.
|
80
79
|
|
81
80
|
![Azure CLI Account Device Code Sign In][azureclilogindevicecode_image]
|
82
81
|
|
@@ -84,11 +83,11 @@ For systems without a default web browser, the `az login` command will use the d
|
|
84
83
|
|
85
84
|
Applications using the `AzurePowerShellCredential`, whether directly or via the `DefaultAzureCredential`, can use the account connected to Azure PowerShell to authenticate calls in the application when running locally.
|
86
85
|
|
87
|
-
To authenticate with [Azure PowerShell][azure_powershell]
|
86
|
+
To authenticate with [Azure PowerShell][azure_powershell], run the `Connect-AzAccount` cmdlet. By default, like the Azure CLI, `Connect-AzAccount` launches the default web browser to authenticate a user account.
|
88
87
|
|
89
88
|
![Azure PowerShell Account Sign In][azurepowershelllogin_image]
|
90
89
|
|
91
|
-
If interactive authentication
|
90
|
+
If interactive authentication can't be supported in the session, then the `-UseDeviceAuthentication` argument forces the cmdlet to use a device code authentication flow instead, similar to the corresponding option in the Azure CLI credential.
|
92
91
|
|
93
92
|
#### Authenticate via Visual Studio Code
|
94
93
|
|
@@ -110,32 +109,32 @@ If this is your first time using `@azure/identity` or Microsoft Entra ID, read [
|
|
110
109
|
|
111
110
|
### Credentials
|
112
111
|
|
113
|
-
A credential is a class
|
112
|
+
A credential is a class that contains or can obtain the data needed for a service client to authenticate requests. Service clients across the Azure SDK accept credentials when they're constructed. Service clients use those credentials to authenticate requests to the service.
|
114
113
|
|
115
|
-
The Azure Identity library focuses on OAuth authentication with Microsoft Entra ID, and it offers
|
114
|
+
The Azure Identity library focuses on OAuth authentication with Microsoft Entra ID, and it offers various credential classes capable of acquiring a Microsoft Entra token to authenticate service requests. All of the credential classes in this library are implementations of the [TokenCredential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-auth/src/tokenCredential.ts) abstract class, and any of them can be used by to construct service clients capable of authenticating with a `TokenCredential`.
|
116
115
|
|
117
116
|
See [Credential Classes](#credential-classes).
|
118
117
|
|
119
118
|
### DefaultAzureCredential
|
120
119
|
|
121
|
-
|
120
|
+
`DefaultAzureCredential` is appropriate for most scenarios where the application is intended to ultimately be run in Azure. This is because `DefaultAzureCredential` combines credentials commonly used to authenticate when deployed with credentials used to authenticate in a development environment.
|
122
121
|
|
123
122
|
> Note: `DefaultAzureCredential` is intended to simplify getting started with the SDK by handling common scenarios with reasonable default behaviors. Developers who want more control or whose scenario isn't served by the default settings should use other credential types.
|
124
123
|
|
125
|
-
If used from Node.js,
|
124
|
+
If used from Node.js, `DefaultAzureCredential` attempts to authenticate via the following mechanisms in order:
|
126
125
|
|
127
126
|
![DefaultAzureCredential authentication flow][defaultauthflow_image]
|
128
127
|
|
129
|
-
1. **Environment** -
|
130
|
-
1. **Workload Identity** - If the application is deployed to Azure Kubernetes Service with Managed Identity enabled, `DefaultAzureCredential`
|
131
|
-
1. **Managed Identity** - If the application is deployed to an Azure host with Managed Identity enabled,
|
132
|
-
1. **Azure CLI** - If the developer
|
133
|
-
1. **Azure PowerShell** - If the developer
|
134
|
-
1. **Azure Developer CLI** - If the developer
|
128
|
+
1. **Environment** - `DefaultAzureCredential` reads account information specified via [environment variables](#environment-variables) and uses it to authenticate.
|
129
|
+
1. **Workload Identity** - If the application is deployed to Azure Kubernetes Service with Managed Identity enabled, `DefaultAzureCredential` authenticates with it.
|
130
|
+
1. **Managed Identity** - If the application is deployed to an Azure host with Managed Identity enabled, `DefaultAzureCredential` authenticates with that account.
|
131
|
+
1. **Azure CLI** - If the developer authenticated an account via the Azure CLI `az login` command, `DefaultAzureCredential` authenticates with that account.
|
132
|
+
1. **Azure PowerShell** - If the developer authenticated using the Azure PowerShell module `Connect-AzAccount` command, `DefaultAzureCredential` authenticates with that account.
|
133
|
+
1. **Azure Developer CLI** - If the developer authenticated an account via the Azure Developer CLI `azd auth login` command, `DefaultAzureCredential` authenticates with that account.
|
135
134
|
|
136
135
|
#### Continuation policy
|
137
136
|
|
138
|
-
As of version 3.3.0, `DefaultAzureCredential`
|
137
|
+
As of version 3.3.0, `DefaultAzureCredential` attempts to authenticate with all developer credentials until one succeeds, regardless of any errors previous developer credentials experienced. For example, a developer credential may attempt to get a token and fail, so `DefaultAzureCredential` continues to the next credential in the flow. Deployed service credentials stop the flow with a thrown exception if they're able to attempt token retrieval, but don't receive one.
|
139
138
|
|
140
139
|
This allows for trying all of the developer credentials on your machine while having predictable deployed behavior.
|
141
140
|
|
@@ -148,15 +147,15 @@ Due to a [known issue](https://github.com/Azure/azure-sdk-for-js/issues/20500),
|
|
148
147
|
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:
|
149
148
|
|
150
149
|
- [`@azure/identity-broker`](https://www.npmjs.com/package/@azure/identity-broker), which provides brokered authentication support through a native broker, such as Web Account Manager.
|
151
|
-
- [`@azure/identity-cache-persistence`](https://www.npmjs.com/package/@azure/identity-cache-persistence), which provides persistent token caching in Node.js using a native secure storage system provided by your operating system. This plugin allows cached `access_token` values to persist across sessions, meaning that an interactive login flow
|
150
|
+
- [`@azure/identity-cache-persistence`](https://www.npmjs.com/package/@azure/identity-cache-persistence), which provides persistent token caching in Node.js using a native secure storage system provided by your operating system. This plugin allows cached `access_token` values to persist across sessions, meaning that an interactive login flow doesn't need to be repeated as long as a cached token is available.
|
152
151
|
|
153
152
|
## Examples
|
154
153
|
|
155
154
|
You can find more examples of using various credentials in [Azure Identity Examples Page](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md)
|
156
155
|
|
157
|
-
### Authenticate with
|
156
|
+
### Authenticate with `DefaultAzureCredential`
|
158
157
|
|
159
|
-
This example demonstrates authenticating the `KeyClient` from the [@azure/keyvault-keys](https://www.npmjs.com/package/@azure/keyvault-keys) client library using
|
158
|
+
This example demonstrates authenticating the `KeyClient` from the [@azure/keyvault-keys](https://www.npmjs.com/package/@azure/keyvault-keys) client library using `DefaultAzureCredential`.
|
160
159
|
|
161
160
|
```javascript
|
162
161
|
// The default credential first checks environment variables for configuration as described above.
|
@@ -175,13 +174,13 @@ const credential = new DefaultAzureCredential();
|
|
175
174
|
const client = new KeyClient(vaultUrl, credential);
|
176
175
|
```
|
177
176
|
|
178
|
-
### Specify a user-assigned managed identity with
|
177
|
+
### Specify a user-assigned managed identity with `DefaultAzureCredential`
|
179
178
|
|
180
179
|
A relatively common scenario involves authenticating using a user-assigned managed identity for an Azure resource. Explore the [example on Authenticating a user-assigned managed identity with DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-a-user-assigned-managed-identity-with-defaultazurecredential) to see how this is made a relatively straightforward task that can be configured using environment variables or in code.
|
181
180
|
|
182
|
-
### Define a custom authentication flow with
|
181
|
+
### Define a custom authentication flow with `ChainedTokenCredential`
|
183
182
|
|
184
|
-
While
|
183
|
+
While `DefaultAzureCredential` is generally the quickest way to get started developing applications for Azure, more advanced users may want to customize the credentials considered when authenticating. The `ChainedTokenCredential` enables users to combine multiple credential instances to define a customized chain of credentials. This example demonstrates creating a `ChainedTokenCredential` that attempts to authenticate using two differently configured instances of `ClientSecretCredential`, to then authenticate the `KeyClient` from the [@azure/keyvault-keys](https://www.npmjs.com/package/@azure/keyvault-keys):
|
185
184
|
|
186
185
|
```typescript
|
187
186
|
import { ClientSecretCredential, ChainedTokenCredential } from "@azure/identity";
|
@@ -251,12 +250,17 @@ Not all credentials require this configuration. Credentials that authenticate th
|
|
251
250
|
|
252
251
|
## Credential classes
|
253
252
|
|
254
|
-
###
|
253
|
+
### Credential chains
|
255
254
|
|
256
255
|
| Credential | Usage | Example |
|
257
256
|
| -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
258
257
|
| [`DefaultAzureCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/defaultazurecredential?view=azure-node-latest) | Provides a simplified authentication experience to quickly start developing applications run in Azure. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-defaultazurecredential) |
|
259
258
|
| [`ChainedTokenCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/chainedtokencredential?view=azure-node-latest) | Allows users to define custom authentication flows composing multiple credentials. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#chaining-credentials) |
|
259
|
+
|
260
|
+
### Authenticate Azure-hosted applications
|
261
|
+
|
262
|
+
| Credential | Usage | Example |
|
263
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
260
264
|
| [`EnvironmentCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/environmentcredential?view=azure-node-latest) | Authenticates a service principal or user via credential information specified in environment variables. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-a-service-principal-with-environment-credentials) |
|
261
265
|
| [`ManagedIdentityCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/managedidentitycredential?view=azure-node-latest) | Authenticates the managed identity of an Azure resource. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-in-azure-with-managed-identity) |
|
262
266
|
| [`WorkloadIdentityCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/workloadidentitycredential?view=azure-node-latest) | Supports [Microsoft Entra Workload ID](https://learn.microsoft.com/azure/aks/workload-identity-overview) on Kubernetes. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-in-azure-with-workload-identity) |
|
@@ -305,12 +309,13 @@ Not all credentials require this configuration. Credentials that authenticate th
|
|
305
309
|
|
306
310
|
#### Service principal with certificate
|
307
311
|
|
308
|
-
| Variable name
|
309
|
-
|
310
|
-
| `AZURE_CLIENT_ID`
|
311
|
-
| `AZURE_TENANT_ID`
|
312
|
-
| `AZURE_CLIENT_CERTIFICATE_PATH`
|
313
|
-
| `AZURE_CLIENT_CERTIFICATE_PASSWORD`
|
312
|
+
| Variable name | Value |
|
313
|
+
|---------------------------------------|--------------------------------------------------------------|
|
314
|
+
| `AZURE_CLIENT_ID` | ID of a Microsoft Entra application |
|
315
|
+
| `AZURE_TENANT_ID` | ID of the application's Microsoft Entra tenant |
|
316
|
+
| `AZURE_CLIENT_CERTIFICATE_PATH` | path to a PEM-encoded certificate file including private key |
|
317
|
+
| `AZURE_CLIENT_CERTIFICATE_PASSWORD` | (optional) password of the certificate file, if any |
|
318
|
+
| `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN` | (optional) send certificate chain in x5c header to support subject name / issuer-based authentication |
|
314
319
|
|
315
320
|
#### Username and password
|
316
321
|
|
@@ -321,7 +326,7 @@ Not all credentials require this configuration. Credentials that authenticate th
|
|
321
326
|
| `AZURE_USERNAME` | a username (usually an email address) |
|
322
327
|
| `AZURE_PASSWORD` | that user's password |
|
323
328
|
|
324
|
-
Configuration is attempted in the
|
329
|
+
Configuration is attempted in the preceding order. For example, if values for a client secret and certificate are both present, the client secret is used.
|
325
330
|
|
326
331
|
## Continuous Access Evaluation
|
327
332
|
|
@@ -335,7 +340,7 @@ Token caching is a feature provided by the Azure Identity library that allows ap
|
|
335
340
|
- Improve resilience and performance.
|
336
341
|
- Reduce the number of requests made to Microsoft Entra ID to obtain access tokens.
|
337
342
|
|
338
|
-
The Azure Identity library offers both in-memory and persistent disk caching. For more
|
343
|
+
The Azure Identity library offers both in-memory and persistent disk caching. For more information, see the [token caching documentation](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/TOKEN_CACHING.md).
|
339
344
|
|
340
345
|
## Brokered authentication
|
341
346
|
|
@@ -365,21 +370,12 @@ For other open issues, see the library's [GitHub repository](https://github.com/
|
|
365
370
|
|
366
371
|
### Provide feedback
|
367
372
|
|
368
|
-
If you encounter bugs or have suggestions,
|
373
|
+
If you encounter bugs or have suggestions, [open an issue](https://github.com/Azure/azure-sdk-for-js/issues).
|
369
374
|
|
370
375
|
## Contributing
|
371
376
|
|
372
|
-
|
373
|
-
|
374
|
-
[1]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/defaultazurecredential.html
|
375
|
-
[2]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/managedidentitycredential.html
|
376
|
-
[3]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/environmentcredential.html
|
377
|
-
[4]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/clientsecretcredential.html
|
378
|
-
[5]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/clientcertificatecredential.html
|
379
|
-
[6]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/devicecodecredential.html
|
380
|
-
[7]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/authorizationcodecredential.html
|
381
|
-
[8]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/interactivebrowsercredential.html
|
382
|
-
[9]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/usernamepasswordcredential.html
|
377
|
+
To contribute to this library, read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
|
378
|
+
|
383
379
|
[azure_cli]: https://learn.microsoft.com/cli/azure
|
384
380
|
[azure_developer_cli]: https://learn.microsoft.com/azure/developer/azure-developer-cli
|
385
381
|
[azure_powershell]: https://learn.microsoft.com/powershell/azure/
|