@azure/identity 2.0.0-beta.6 → 2.0.0

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.

Files changed (100) hide show
  1. package/CHANGELOG.md +131 -3
  2. package/README.md +51 -3
  3. package/dist/index.js +207 -218
  4. package/dist/index.js.map +1 -1
  5. package/dist-esm/src/client/identityClient.js +2 -2
  6. package/dist-esm/src/client/identityClient.js.map +1 -1
  7. package/dist-esm/src/credentials/authorizationCodeCredential.browser.js +1 -1
  8. package/dist-esm/src/credentials/authorizationCodeCredential.browser.js.map +1 -1
  9. package/dist-esm/src/credentials/{applicationCredential.browser.js → azureApplicationCredential.browser.js} +9 -4
  10. package/dist-esm/src/credentials/azureApplicationCredential.browser.js.map +1 -0
  11. package/dist-esm/src/credentials/azureApplicationCredential.js +36 -0
  12. package/dist-esm/src/credentials/azureApplicationCredential.js.map +1 -0
  13. package/dist-esm/src/credentials/azureCliCredential.browser.js +7 -0
  14. package/dist-esm/src/credentials/azureCliCredential.browser.js.map +1 -1
  15. package/dist-esm/src/credentials/azureCliCredential.js +9 -9
  16. package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
  17. package/dist-esm/src/credentials/azurePowerShellCredential.browser.js +3 -1
  18. package/dist-esm/src/credentials/azurePowerShellCredential.browser.js.map +1 -1
  19. package/dist-esm/src/credentials/azurePowerShellCredential.js +13 -13
  20. package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
  21. package/dist-esm/src/credentials/chainedTokenCredential.js +2 -2
  22. package/dist-esm/src/credentials/chainedTokenCredential.js.map +1 -1
  23. package/dist-esm/src/credentials/clientCertificateCredential.browser.js +7 -0
  24. package/dist-esm/src/credentials/clientCertificateCredential.browser.js.map +1 -1
  25. package/dist-esm/src/credentials/clientCertificateCredential.js +18 -15
  26. package/dist-esm/src/credentials/clientCertificateCredential.js.map +1 -1
  27. package/dist-esm/src/credentials/clientCertificateCredentialOptions.js.map +1 -1
  28. package/dist-esm/src/credentials/clientSecretCredential.browser.js +1 -1
  29. package/dist-esm/src/credentials/clientSecretCredential.browser.js.map +1 -1
  30. package/dist-esm/src/credentials/clientSecretCredential.js +1 -1
  31. package/dist-esm/src/credentials/clientSecretCredential.js.map +1 -1
  32. package/dist-esm/src/credentials/clientSecretCredentialOptions.js.map +1 -1
  33. package/dist-esm/src/credentials/defaultAzureCredential.js +16 -12
  34. package/dist-esm/src/credentials/defaultAzureCredential.js.map +1 -1
  35. package/dist-esm/src/credentials/deviceCodeCredential.browser.js +7 -0
  36. package/dist-esm/src/credentials/deviceCodeCredential.browser.js.map +1 -1
  37. package/dist-esm/src/credentials/deviceCodeCredential.js +14 -0
  38. package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -1
  39. package/dist-esm/src/credentials/environmentCredential.browser.js +7 -0
  40. package/dist-esm/src/credentials/environmentCredential.browser.js.map +1 -1
  41. package/dist-esm/src/credentials/environmentCredential.js +5 -21
  42. package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
  43. package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js +7 -7
  44. package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -1
  45. package/dist-esm/src/credentials/interactiveBrowserCredential.js +7 -7
  46. package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -1
  47. package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +1 -1
  48. package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js +1 -1
  49. package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js.map +1 -1
  50. package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +32 -23
  51. package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
  52. package/dist-esm/src/credentials/managedIdentityCredential/index.js +2 -2
  53. package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
  54. package/dist-esm/src/credentials/onBehalfOfCredential.browser.js +6 -0
  55. package/dist-esm/src/credentials/onBehalfOfCredential.browser.js.map +1 -1
  56. package/dist-esm/src/credentials/onBehalfOfCredential.js +6 -11
  57. package/dist-esm/src/credentials/onBehalfOfCredential.js.map +1 -1
  58. package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js.map +1 -1
  59. package/dist-esm/src/credentials/usernamePasswordCredential.browser.js +1 -1
  60. package/dist-esm/src/credentials/usernamePasswordCredential.browser.js.map +1 -1
  61. package/dist-esm/src/credentials/usernamePasswordCredential.js +1 -3
  62. package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -1
  63. package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js +6 -0
  64. package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js.map +1 -1
  65. package/dist-esm/src/credentials/visualStudioCodeCredential.js +5 -7
  66. package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -1
  67. package/dist-esm/src/{client/errors.js → errors.js} +15 -0
  68. package/dist-esm/src/errors.js.map +1 -0
  69. package/dist-esm/src/index.js +1 -4
  70. package/dist-esm/src/index.js.map +1 -1
  71. package/dist-esm/src/msal/browserFlows/browserCommon.js +8 -7
  72. package/dist-esm/src/msal/browserFlows/browserCommon.js.map +1 -1
  73. package/dist-esm/src/msal/browserFlows/msalAuthCode.js +12 -4
  74. package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +1 -1
  75. package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js +1 -1
  76. package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js.map +1 -1
  77. package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js +6 -5
  78. package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js.map +1 -1
  79. package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js +1 -1
  80. package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js.map +1 -1
  81. package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js +1 -1
  82. package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +1 -1
  83. package/dist-esm/src/msal/nodeFlows/nodeCommon.js +13 -7
  84. package/dist-esm/src/msal/nodeFlows/nodeCommon.js.map +1 -1
  85. package/dist-esm/src/msal/utils.js +7 -4
  86. package/dist-esm/src/msal/utils.js.map +1 -1
  87. package/dist-esm/src/util/tracing.js +1 -1
  88. package/dist-esm/src/util/tracing.js.map +1 -1
  89. package/dist-esm/src/util/validateMultiTenant.browser.js +22 -0
  90. package/dist-esm/src/util/validateMultiTenant.browser.js.map +1 -0
  91. package/dist-esm/src/util/validateMultiTenant.js +17 -12
  92. package/dist-esm/src/util/validateMultiTenant.js.map +1 -1
  93. package/package.json +7 -5
  94. package/types/identity.d.ts +133 -233
  95. package/dist-esm/src/client/errors.js.map +0 -1
  96. package/dist-esm/src/credentials/applicationCredential.browser.js.map +0 -1
  97. package/dist-esm/src/credentials/applicationCredential.js +0 -34
  98. package/dist-esm/src/credentials/applicationCredential.js.map +0 -1
  99. package/dist-esm/src/msal/errors.js +0 -22
  100. package/dist-esm/src/msal/errors.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,134 @@
1
1
  # Release History
2
2
 
3
+ ## 2.0.0 (2021-10-15)
4
+
5
+ After multiple beta releases over the past year, we're proud to announce the general availability of version 2 of the `@azure/identity` package. This version includes the best parts of v1, plus several improvements.
6
+
7
+ This changelog entry showcases the changes that have been made from version 1 of this package. See the [v1-to-v2 migration guide](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/migration-v1-v2.md) for details on how to upgrade your application to use the version 2 of `@azure/identity`. For information on troubleshooting the Identity package, see the [troubleshooting guide](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/Troubleshooting.md).
8
+
9
+ ### Features Added
10
+
11
+ #### Plugin API
12
+
13
+ Identity v2 provides a top-level `useIdentityPlugin` function, which allows using two new plugin packages:
14
+
15
+ - [@azure/identity-vscode](https://www.npmjs.com/package/@azure/identity-vscode), which provides the dependencies of `VisualStudioCodeCredential` and enables it.
16
+ - If the `@azure/identity-vscode` plugin isn't used through the `useIdentityPlugin` function, the `VisualStudioCodeCredential` exposed by Identity v2 will throw a `CredentialUnavailableError`.
17
+ - [@azure/identity-cache-persistence](https://www.npmjs.com/package/@azure/identity-cache-persistence), which provides persistent token caching.
18
+
19
+ Most credentials on Identity v2 now support the persistent token caching feature. Such credentials include the property [tokenCachePersistenceOptions](https://docs.microsoft.com/javascript/api/@azure/identity/tokencachepersistenceoptions) in the constructor options which can be used to enable this feature.
20
+
21
+ The following example showcases how to enable persistence caching by first enabling the `@azure/identity-cache-persistence` plugin with `useIdentityPlugin(cachePersistencePlugin)`, and then passing the `tokenCachePersistenceOptions` through the constructor of the `DeviceCodeCredential`:
22
+
23
+ ```ts
24
+ import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
25
+ import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";
26
+
27
+ useIdentityPlugin(cachePersistencePlugin);
28
+
29
+ async function main() {
30
+ const credential = new DeviceCodeCredential({
31
+ tokenCachePersistenceOptions: {
32
+ enabled: true
33
+ }
34
+ });
35
+ }
36
+ ```
37
+
38
+ #### New credentials
39
+
40
+ Identity v2 includes two new credential types:
41
+
42
+ - `AzurePowerShellCredential`, which re-uses any account previously authenticated with the `Az.Account` PowerShell module.
43
+ - `OnBehalfOfCredential`, which enables the [On-Behalf-Of authentication flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow).
44
+
45
+ #### New features in all credentials
46
+
47
+ Identity v2 enables:
48
+
49
+ - Support for claims challenges resulting from [Continuous Access Enforcement (CAE)](https://docs.microsoft.com/azure/active-directory/conditional-access/concept-continuous-access-evaluation) and [Conditional Access authentication context](https://techcommunity.microsoft.com/t5/azure-active-directory-identity/granular-conditional-access-for-sensitive-data-and-actions/ba-p/1751775).
50
+ - By default, credentials of Identity v2 will produce tokens that can be used to trigger the challenge authentication flows. After these tokens expire, the next HTTP requests to Azure will fail, but the response will contain information to re-authenticate.
51
+ - To disable this behavior, set the environment variable `AZURE_IDENTITY_DISABLE_CP1` to any value. For more about claims challenges, see [Claims challenges, claims requests, and client capabilities](https://docs.microsoft.com/azure/active-directory/develop/claims-challenge).
52
+ - Support for multi-tenant authentication on all credentials except `ManagedIdentityCredential`.
53
+ - At the moment, applications needing multi-tenancy support will need to call to the credentials' `getToken` directly, sending the new `tenantId` property.
54
+ - A sample with more context will be provided in a future date.
55
+ - To disable it, set the environment variable `AZURE_IDENTITY_DISABLE_MULTITENANTAUTH`. For more about multitenancy, see [Identity management in multitenant apps](https://docs.microsoft.com/azure/architecture/multitenant-identity/).
56
+
57
+ #### New features in InteractiveBrowserCredential and DeviceCodeCredential
58
+
59
+ You can now control when the credential requests user input with the new `disableAutomaticAuthentication` option added to the options you pass to the credential constructors.
60
+
61
+ - When enabled, this option stops the `getToken()` method from requesting user input in case the credential is unable to authenticate silently.
62
+ - If `getToken()` fails to authenticate without user interaction, and `disableAutomaticAuthentication` has been set to true, a new error will be thrown: `AuthenticationRequired`. You may use this error to identify scenarios when manual authentication needs to be triggered (with `authenticate()`, as described in the next point).
63
+
64
+ A new method `authenticate()` is added to these credentials which is similar to `getToken()`, but it does not read the `disableAutomaticAuthentication` option described above.
65
+
66
+ - Use this to get an `AuthenticationRecord` which you can then use to create new credentials that will re-use the token information.
67
+ - The `AuthenticationRecord` object has a `serialize()` method that allows an authenticated account to be stored as a string and re-used in another credential at any time. Use the new helper function `deserializeAuthenticationRecord` to de-serialize this string.
68
+ - `authenticate()` might succeed and still return `undefined` if we're unable to pick just one account record from the cache. This might happen if the cache is being used by more than one credential, or if multiple users have authenticated using the same Client ID and Tenant ID. To ensure consistency on a program with many users, please keep track of the `AuthenticationRecord` and provide them in the constructors of the credentials on initialization.
69
+
70
+ Learn more via the below samples
71
+
72
+ - [Samples around controlling user interaction](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#control-user-interaction).
73
+ - [Samples around persisting user authentication data](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#persist-user-authentication-data).
74
+
75
+ #### New features in ManagedIdentityCredential
76
+
77
+ In Identity v2, the `ManagedIdentityCredential` retries with exponential back-off when a request for a token fails with a 404 status code. This change only applies to environments with available IMDS endpoints.
78
+
79
+ Azure Service Fabric support hasn't been added on the initial version 2 of Identity. Subscribe to [issue #12420](https://github.com/Azure/azure-sdk-for-js/issues/12420) for updates on this feature.
80
+
81
+ #### Other features
82
+
83
+ - `ClientCertificateCredential` now optionally accepts a configuration object as its third constructor parameter, instead of the PEM certificate path. This new object, called `ClientCertificateCredentialPEMConfiguration`, can contain either the PEM certificate path with the `certificatePath` property, or the contents of the PEM certificate with the `certificate` property..
84
+ - The Node.js version of `InteractiveBrowserCredential` has [Proof Key for Code Exchange (PKCE)](https://datatracker.ietf.org/doc/html/rfc7636) enabled by default.
85
+ - `InteractiveBrowserCredential` has a new `loginHint` constructor option, which allows a username to be pre-selected for interactive logins.
86
+ - In `AzureCliCredential`, we allow specifying a `tenantId` in the parameters through the `AzureCliCredentialOptions`.
87
+ - A new error, named `AuthenticationRequiredError`, has been added. This error shows up when a credential fails to authenticate silently.
88
+ - Errors and logged exceptions may point to the new [troubleshooting guidelines](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/Troubleshooting.md).
89
+ - On all of the credentials we're providing, the initial authentication attempt in the lifetime of your app will include an additional request to first discover relevant endpoint metadata information from Azure.
90
+
91
+ ### Breaking changes
92
+
93
+ #### Breaking changes from v1
94
+
95
+ - For `ClientCertificateCredential` specifically, the validity of the PEM certificate is evaluated on `getToken` and not on the constructor.
96
+ - We have also renamed the error `CredentialUnavailable` to `CredentialUnavailableError`, to align with the naming convention used for error classes in the Azure SDKs in JavaScript.
97
+ - In v1 of Identity some `getToken` calls could resolve with `null` in the case the authentication request succeeded with a malformed output. In v2, issues with the `getToken` method will always throw errors.
98
+ - Breaking changes to InteractiveBrowserCredential
99
+ - The `InteractiveBrowserCredential` will use the [Auth Code Flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow) with [PKCE](https://tools.ietf.org/html/rfc7636) rather than [Implicit Grant Flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-implicit-grant-flow) to better support browsers with enhanced security restrictions. Learn how to migrate in the [migration guide](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/migration-v1-v2.md). Read more about the latest `InteractiveBrowserCredential` [here](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/interactive-browser-credential.md).
100
+ - The default client ID used for `InteractiveBrowserCredential` was viable only in Node.js and not for the browser. Therefore, on v2 client ID is a required parameter when using this credential in browser apps.
101
+ - Identity v2 also removes the `postLogoutRedirectUri` from the options to the constructor for `InteractiveBrowserCredential`. This option wasn't being used. Instead of using this option, use MSAL directly. For more information, see [Authenticating with the @azure/msal-browser Public Client](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-the-azuremsal-browser-public-client).
102
+ - In Identity v2, `VisualStudioCodeCredential` throws a `CredentialUnavailableError` unless the new [@azure/identity-vscode](https://www.npmjs.com/package/@azure/identity-vscode) plugin is used.
103
+
104
+ - Standardizing the tracing span names to be `<className>.<operationName>` over `<className>-<operationName>`
105
+
106
+ #### Breaking Changes from 2.0.0-beta.4
107
+
108
+ - Removed the `allowMultiTenantAuthentication` option from all of the credentials. Multi-tenant authentication is now enabled by default. On Node.js, it can be disabled with the `AZURE_IDENTITY_DISABLE_MULTITENANTAUTH` environment variable.
109
+ - Removed support for specific Azure regions on `ClientSecretCredential` and `ClientCertificateCredential. This feature will be added back on the next beta.
110
+
111
+ #### Breaking Changes from 2.0.0-beta.6
112
+
113
+ - Stopped exporting the `ApplicationCredential` from the package. This will be re-introduced in the future.
114
+ - Removed the `CredentialPersistenceOptions` from `DefaultAzureCredential` and `EnvironmentCredential`.
115
+ - Merged the configuration and the options bag on the `OnBehalfOfCredential` into a single options bag.
116
+ - `AuthenticationRequiredError` (introduced in 2.0.0-beta.1) now has its parameters into a single options bag.
117
+ - `AuthenticationRequiredError` (introduced in 2.0.0-beta.1) now has its parameters in a single options bag, `AuthenticationRequiredErrorOptions`.
118
+ - `InteractiveBrowserCredentialOptions` has been renamed to `InteractiveBrowserCredentialNodeOptions`, and `InteractiveBrowserCredentialBrowserOptions` has been named `InteractiveBrowserCredentialInBrowserOptions`.
119
+
120
+ ### Bugs Fixed
121
+
122
+ - `ClientSecretCredential`, `ClientCertificateCredential`, and `UsernamePasswordCredential` throw if the required parameters aren't provided (even in JavaScript).
123
+ - Fixed a bug that caused `AzureCliCredential` to fail when a custom tenant ID was provided.
124
+ - Caught up with the bug fixes for Azure POD Identity that were implemented on version 1.5.1.
125
+
126
+ ### Other Changes
127
+
128
+ Identity v2 no longer includes native dependencies (neither ordinary, peer, nor optional dependencies). Previous distributions of `@azure/identity` included an optional dependency on `keytar`, which caused issues for some users in restrictive environments.
129
+
130
+ Identity v2 for JavaScript now also depends on the latest available versions of `@azure/msal-common`, `@azure/msal-node`, and `@azure/msal-browser`. Our goal is to always be up-to-date with the MSAL versions.
131
+
3
132
  ## 2.0.0-beta.6 (2021-09-09)
4
133
 
5
134
  ### Features Added
@@ -14,7 +143,6 @@
14
143
  #### Breaking Changes from 2.0.0-beta.5
15
144
 
16
145
  - The property named `selectedCredential` that was added to `ChainedTokenCredential` and `DefaultAzureCredential` has been removed, since customers reported that logging was enough.
17
- - Renamed the `allowUnencryptedStorage` property of `TokenCachePersistenceOptions` to `unsafeAllowUnencryptedStorage` to make it clear that enabling the unencrypted storage feature is not generally safe for production use.
18
146
  - Changed the name of the "extension" API to the "plugin" API to reduce confusion between this package and VS Code extensions. The function `useIdentityExtension` was renamed to `useIdentityPlugin`, and "extension packages" are now known as "plugin packages".
19
147
  - Renamed the `allowUnencryptedStorage` property of `TokenCachePersistenceOptions` to `unsafeAllowUnencryptedStorage` to make it clear that enabling the unencrypted storage feature is not generally safe for production use.
20
148
 
@@ -95,7 +223,7 @@
95
223
 
96
224
  ### Key Bugs Fixed
97
225
 
98
- - Fixed an issue in which `InteractiveBrowserCredential` on Node would sometimes cause the process to hang if there was no browser available.
226
+ - Fixed an issue in which `InteractiveBrowserCredential` on Node would sometimes cause the process to not respond if there was no browser available.
99
227
  - Fixed an issue in which the `AZURE_AUTHORITY_HOST` environment variable was not properly picked up in Node.js.
100
228
 
101
229
  ## 2.0.0-beta.3 (2021-05-12)
@@ -158,7 +286,7 @@ This update marks the preview for the first major version update of the `@azure/
158
286
  - This feature uses DPAPI on Windows, it tries to use the Keychain on OSX and the Keyring on Linux.
159
287
  - To learn more on the usage, please refer to our docs on the `TokenCachePersistenceOptions` interface.
160
288
  - **IMPORTANT:** As part of this beta, this feature is only supported in Node 10, 12 and 14.
161
- - Changes to `InteractiveBrowserCredential`, `DeviceCodeCredential`, and `UsernamePasswordCredential`:
289
+ - Changes to `InteractiveBrowserCredential` and `DeviceCodeCredential`:
162
290
  - You can now control when the credential requests user input with the new `disableAutomaticAuthentication` option added to the options you pass to the credential constructors.
163
291
  - When enabled, this option stops the `getToken()` method from requesting user input in case the credential is unable to authenticate silently.
164
292
  - If `getToken()` fails to authenticate without user interaction, and `disableAutomaticAuthentication` has been set to true, a new error will be thrown: `AuthenticationRequired`. You may use this error to identify scenarios when manual authentication needs to be triggered (with `authenticate()`, as described in the next point).
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  ## Azure Identity client library for JavaScript
2
2
 
3
- The Azure Identity library provides [Azure Active Directory (AAD)](https://docs.microsoft.com/azure/active-directory/fundamentals/active-directory-whatis) token authentication through a set of convenient [TokenCredential](https://docs.microsoft.com/javascript/api/@azure/core-auth/tokencredential) implementations. It enables Azure SDK clients to authenticate with AAD, while also allowing other JavaScript and TypeScript apps to authenticate with AAD work and school accounts, Microsoft personal accounts (MSA), and other Identity providers through the [AAD B2C](https://docs.microsoft.com/azure/active-directory-b2c/overview) service.
3
+ The Azure Identity library provides [Azure Active Directory (Azure AD)](https://docs.microsoft.com/azure/active-directory/fundamentals/active-directory-whatis) token authentication through a set of convenient [TokenCredential](https://docs.microsoft.com/javascript/api/@azure/core-auth/tokencredential) implementations.
4
4
 
5
- You can find examples for these various credentials in the [Azure Identity Examples Page](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md)
5
+ For examples of various credentials, see the [Azure Identity examples page](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md).
6
6
 
7
7
  Key links:
8
8
 
@@ -14,6 +14,10 @@ Key links:
14
14
 
15
15
  ## Getting started
16
16
 
17
+ ### Migrate from v1 to v2 of @azure/identity
18
+
19
+ If you're using v1 of `@azure/identity`, see the [migration guide](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/migration-v1-v2.md) to update to v2.
20
+
17
21
  ### Currently supported environments
18
22
 
19
23
  - [LTS versions of Node.js](https://nodejs.org/about/releases/)
@@ -82,6 +86,14 @@ To authenticate with [Azure PowerShell][azure_powershell] users can run the `Con
82
86
 
83
87
  If interactive authentication cannot be supported in the session, then the `-UseDeviceAuthentication` argument will force the cmdlet to use a device code authentication flow instead, similar to the corresponding option in the Azure CLI credential.
84
88
 
89
+ #### Authenticate via Visual Studio Code
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 IDE. Apps using `DefaultAzureCredential` or `VisualStudioCodeCredential` can then use this account to authenticate calls in their app when running locally.
92
+
93
+ To authenticate in Visual Studio Code, first ensure the Azure Account extension is installed. Once the extension is installed, open the **Command Palette** and run the **Azure: Sign In** command.
94
+
95
+ Additionally, use the [`@azure/identity-vscode`](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity-vscode) plugin package. This package provides the dependencies of `VisualStudioCodeCredential` and enables it. See [Plugins](##plugins).
96
+
85
97
  ### Authenticate the client in browsers
86
98
 
87
99
  To authenticate Azure SDKs within web browsers, we currently offer the `InteractiveBrowserCredential`, which can be set to use redirection or popups to complete the authentication flow. It is necessary to [create an Azure App Registration](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) in the portal for your web application first.
@@ -211,6 +223,24 @@ The [Managed identity authentication](https://docs.microsoft.com/azure/active-di
211
223
 
212
224
  For examples of how to use managed identity for authentication please refer to [the examples](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-in-azure-with-managed-identity)
213
225
 
226
+ ## Cloud configuration
227
+
228
+ Credentials default to authenticating to the Azure AD endpoint for Azure Public Cloud. To access resources in other clouds, such as Azure Government or a private cloud, configure credentials with the `authorityHost` argument in the constructor. The `AzureAuthorityHosts` interface defines authorities for well-known clouds. For the US Government cloud, you could instantiate a credential this way:
229
+
230
+ ```ts
231
+ import { AzureAuthorityHosts, ClientSecretCredential } from "@azure/identity";
232
+ const credential = new ClientSecretCredential(
233
+ "<YOUR_TENANT_ID>",
234
+ "<YOUR_CLIENT_ID>",
235
+ "<YOUR_CLIENT_SECRET>",
236
+ {
237
+ authorityHost: AzureAuthorityHosts.AzureGovernment
238
+ }
239
+ );
240
+ ```
241
+
242
+ Not all credentials require this configuration. Credentials that authenticate through a development tool, such as `AzureCliCredential`, use that tool's configuration. Similarly, `VisualStudioCodeCredential` accepts an `authorityHost` argument but defaults to the `authorityHost` matching Visual Studio Code's **Azure: Cloud** setting.
243
+
214
244
  ## Credential Classes
215
245
 
216
246
  ### Authenticating Azure Hosted Applications
@@ -253,7 +283,13 @@ Credentials raise `AuthenticationError` when they fail to authenticate. This cla
253
283
 
254
284
  ### Logging
255
285
 
256
- Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
286
+ Enabling logging may help uncover useful information about failures. To see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. You can read this environment variable from the *.env* file by explicitly specifying a file path:
287
+
288
+ ```javascript
289
+ require("dotenv").config({ path: ".env" });
290
+ ```
291
+
292
+ Alternatively, logging can be enabled at runtime by calling `setLogLevel` from the `@azure/logger` package:
257
293
 
258
294
  ```javascript
259
295
  import { setLogLevel } from "@azure/logger";
@@ -261,12 +297,24 @@ import { setLogLevel } from "@azure/logger";
261
297
  setLogLevel("info");
262
298
  ```
263
299
 
300
+ For assistance with troubleshooting, see the [troubleshooting guide](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/Troubleshooting.md).
301
+
264
302
  ## Next steps
265
303
 
266
304
  ### Read the documentation
267
305
 
268
306
  API documentation for this library can be found on our [documentation site](https://docs.microsoft.com/javascript/api/@azure/identity).
269
307
 
308
+ ### Client library support
309
+
310
+ Client and management libraries listed on the [Azure SDK releases page](https://azure.github.io/azure-sdk/releases/latest/js.html) that support Azure AD authentication accept credentials from this library. Learn more about using these libraries in their documentation, which is linked from the releases page.
311
+
312
+ ### Known Issues
313
+
314
+ #### Azure AD B2C support
315
+
316
+ This library does not support the [Azure AD B2C](https://docs.microsoft.com/azure/active-directory-b2c/overview) service.
317
+
270
318
  ### Provide Feedback
271
319
 
272
320
  If you encounter bugs or have suggestions, please [open an issue](https://github.com/Azure/azure-sdk-for-js/issues).