Skip to content

Commit

Permalink
[Identity] Migration guide (v1 to v2) (#17796)
Browse files Browse the repository at this point in the history
* [Identity] Migration guide

* Apply suggestions from code review

Co-authored-by: Scott Addie <[email protected]>

* reference in the README and fixed links

* Apply suggestions from code review

Co-authored-by: Scott Addie <[email protected]>

* Feedback by Ramya, and other small polishes

* removed the service fabric note

* Separated the changelog entries from the migration guide, and moved to version 2.0.0

* packages to v2

* fixed bad link -- though these Troubleshooting links wont work until Karishmas PR is merged

* Mentioning the lack of Service Fabric support

* improvements after thorough reading

* Update sdk/identity/identity/migration-v1-v2.md

Co-authored-by: Ramya Rao <[email protected]>

* improved the CHANGELOG and the migration guide

* using the caret

* all seems good now

* Update CHANGELOG.md

* Update CHANGELOG.md

* Small changes around RegionalAuthority

* Apply suggestions from code review

Co-authored-by: Scott Addie <[email protected]>

* Apply suggestions from code review

Co-authored-by: Ramya Rao <[email protected]>

* addressed more of the feedback

* Removed references to RegionalAuthorities

* moved network change out of breaking changes

* Apply suggestions from code review

Co-authored-by: Ramya Rao <[email protected]>

* [Identity] Disabling regional authority support (#18026)

* [Identity] Disabling regional authority support

* feedback from Scott Schaab

* [ai-form-recognizer] Merge 4.0.0-beta.1 (#18036)

* Obliterate existing FR SDK for clean history

* [ai-form-recognizer] Migrate Form Recognizer SDK work to public repo. (#17955)

* Migrate Form Recognizer SDK work to public repo.

* Fixed a couple of little things in the source.

* Updated README and CHANGELOG

* Use latest swagger

* Updated CHANGELOG

* Some more fixes

* WIP Migration Guide

* README fixes

* Renamed common options type

* Apply suggestions from code review

* Update CHANGELOG

* Fixed TypeScript version mismatch in dev-tool.

* re-recorded tests and enabled AAD

* Updated skip list

* added summaries to all samples

* Updated skip list

* Updated doc string

* Pick internal/hidden

* Generated camera-ready samples

* Extend migration guide

* Fix link

Co-authored-by: Will Temple <[email protected]>

Co-authored-by: Will Temple <[email protected]>

* Post release automated changes for keyvault releases (#18034)

Post release automated changes for azure-keyvault-keys

* [Schema Registry] Update changelog (#18041)

* [Azure Monitor OpenTelemetry Exporter]Update changelog for 1.0.0-beta.5 release (#18038)

* Update changelog

* Update sdk/monitor/monitor-opentelemetry-exporter/CHANGELOG.md

Co-authored-by: KarishmaGhiya <[email protected]>

* Update sdk/monitor/monitor-opentelemetry-exporter/CHANGELOG.md

Co-authored-by: KarishmaGhiya <[email protected]>

* Format

Co-authored-by: KarishmaGhiya <[email protected]>

* fix sample on readme (#18022)

* [EventGrid] Update System Events, Prepare for Release (#17977)

Update our swagger reference commit to pull in some new system events
and add them to our mappings.

* Handle multiple segments in service directory path (#18015)

Co-authored-by: Ben Broderick Phillips <[email protected]>

* Post release automated changes for azure-service-bus (#18045)

* [Synapse Artifacts] Re generate for October Release (#17981)

* Update synapse artifacts

* Undo recording changes

* Update changelog

* update recordings

* Update changelog

* Remove .deb file

* Revert change back (#18040)

Reverts back to a version that does not have mysterious Credential Issue

Co-authored-by: Sean Kane <[email protected]>

* [Schema Registry] Edit readme (#18048)

* Re-enable api extractor when building abort-controller (#17986)

This PR re-enables the use of api extractor in the build step for the abort-controller package.
I no longer see the problems reported in #10320 

Fixes #10320

* [Synapse Spark] Regenerate with latest release tag package-spark-2020-12-01 (#17980)

* Regenerate with latest release tag package-spark-2020-12-01

* Update changelog

* Post release automated changes for schemaregistry releases (#18051)

Post release automated changes for azure-schema-registry-avro

* Reduce test scope for test-utils pipeline (#18046)

* Reduce test scope for test-utils pipeline

* Post release automated changes for eventgrid releases (#18050)

Post release automated changes for azure-eventgrid

* [Schema Registry] Post release automation (#18052)

* [Schema Registry] Post release automation

* bump SR dep ver

* update changelog

* [Identity] Caught up with POD Identity fix added on 1.5.1 (#18054)

* remaining feedback from Ramya

* removed references to the troubleshooting guide

* Update sdk/identity/identity/CHANGELOG.md

Co-authored-by: Harsha Nalluru <[email protected]>

* added a placeholder for the Troubleshooting.md file

* Update sdk/identity/identity/CHANGELOG.md

Co-authored-by: Harsha Nalluru <[email protected]>

* last references to Identity 2.0.0-beta.7

* Fixed 2.0.0-beta.7 reference in monitor-query perf tests

Co-authored-by: Scott Addie <[email protected]>
Co-authored-by: Ramya Rao <[email protected]>
Co-authored-by: Will Temple <[email protected]>
Co-authored-by: Will Temple <[email protected]>
Co-authored-by: Azure SDK Bot <[email protected]>
Co-authored-by: Deyaaeldeen Almahallawi <[email protected]>
Co-authored-by: Hector Hernandez <[email protected]>
Co-authored-by: KarishmaGhiya <[email protected]>
Co-authored-by: KarishmaGhiya <[email protected]>
Co-authored-by: Matt Ellis <[email protected]>
Co-authored-by: Ben Broderick Phillips <[email protected]>
Co-authored-by: Jose Manuel Heredia Hidalgo <[email protected]>
Co-authored-by: Sean Kane <[email protected]>
Co-authored-by: praveenkuttappan <[email protected]>
Co-authored-by: Harsha Nalluru <[email protected]>
  • Loading branch information
16 people authored Oct 7, 2021
1 parent 2bb7759 commit 2a29ea7
Show file tree
Hide file tree
Showing 16 changed files with 278 additions and 16 deletions.
2 changes: 1 addition & 1 deletion sdk/identity/identity-cache-persistence/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"sideEffects": false,
"dependencies": {
"@azure/core-auth": "^1.3.0",
"@azure/identity": "^2.0.0-beta.7",
"@azure/identity": "^2.0.0",
"@azure/msal-node": "^1.3.0",
"@azure/msal-node-extensions": "1.0.0-alpha.9",
"keytar": "^7.6.0",
Expand Down
2 changes: 1 addition & 1 deletion sdk/identity/identity-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity-vscode/README.md",
"sideEffects": false,
"dependencies": {
"@azure/identity": "^2.0.0-beta.7",
"@azure/identity": "^2.0.0",
"keytar": "^7.6.0",
"tslib": "^2.2.0"
},
Expand Down
106 changes: 102 additions & 4 deletions sdk/identity/identity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,122 @@
# Release History

## 2.0.0-beta.7 (Unreleased)
## 2.0.0 (2021-10-12)

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.

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`.

### Features Added

### Breaking Changes
#### Plugin API

Identity v2 provides a top-level `useIdentityPlugin` function, which allows using two new plugin packages:

- [@azure/identity-vscode](https://www.npmjs.com/package/@azure/identity-vscode), which provides the dependencies of `VisualStudioCodeCredential` and enables it.
- If the `@azure/identity-vscode` plugin isn't used through the `useIdentityPlugin` function, the `VisualStudioCodeCredential` exposed by Identity v2 will throw a `CredentialUnavailableError`.
- [@azure/identity-cache-persistence](https://www.npmjs.com/package/@azure/identity-cache-persistence), which provides persistent token caching.

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.

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`:

```ts
import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";

useIdentityPlugin(cachePersistencePlugin);

async function main() {
const credential = new DeviceCodeCredential({
tokenCachePersistenceOptions: {
enabled: true
}
});
}
```

#### New credentials

Identity v2 includes three new credential types:

- `AzurePowerShellCredential`, which re-uses any account previously authenticated with the `Az.Account` PowerShell module.
- `ApplicationCredential`, which is a simplified `DefaultAzureCredential` that only includes `EnvironmentCredential` and `ManagedIdentityCredential`.
- `OnBehalfOfCredential`, which enables the [On-Behalf-Of authentication flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow).

#### New features in all credentials

Identity v2 enables:

- 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).
- 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.
- 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).
- Support for multi-tenant authentication on all credentials except `ManagedIdentityCredential`.
- At the moment, applications needing multi-tenancy support will need to call to the credentials' `getToken` directly, sending the new `tenantId` property.
- A sample with more context will be provided in a future date.
- 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/).

#### New features in InteractiveBrowserCredential and DeviceCodeCredential

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.

- When enabled, this option stops the `getToken()` method from requesting user input in case the credential is unable to authenticate silently.
- 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).

A new method `authenticate()` is added to these credentials which is similar to `getToken()`, but it does not read the `disableAutomaticAuthentication` option described above.

- Use this to get an `AuthenticationRecord` which you can then use to create new credentials that will re-use the token information.
- 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.
- `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.

Learn more via the below samples
- [Samples around controlling user interaction](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#control-user-interaction).
- [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).

#### New features in ManagedIdentityCredential

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.

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.

#### Other features

- The Node.js version of `InteractiveBrowserCredential` has [Proof Key for Code Exchange (PKCE)](https://datatracker.ietf.org/doc/html/rfc7636) enabled by default.
- `InteractiveBrowserCredential` has a new `loginHint` constructor option, which allows a username to be pre-selected for interactive logins.
- In `AzureCliCredential`, we allow specifying a `tenantId` in the parameters through the `AzureCliCredentialOptions`.
- A new error, named `AuthenticationRequiredError`, has been added. This error shows up when a credential fails to authenticate silently.
- 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).
- 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.

### Breaking changes

#### Breaking changes from v1

- For `ClientCertificateCredential` specifically, the validity of the PEM certificate is evaluated on `getToken` and not on the constructor.
- 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.
- 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.
- Breaking changes to InteractiveBrowserCredential
- 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).
- 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.
- 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).
- In Identity v2, `VisualStudioCodeCredential` throws a `CredentialUnavailableError` unless the new [@azure/identity-vscode](https://www.npmjs.com/package/@azure/identity-vscode) plugin is used.

#### Breaking Changes from 2.0.0-beta.4

- 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.
- Removed support for specific Azure regions on `ClientSecretCredential` and `ClientCertificateCredential. This feature will be added back on the next beta.


### Bugs Fixed

- `ClientSecretCredential`, `ClientCertificateCredential`, and `UsernamePasswordCredential` throw if the required parameters aren't provided (even in JavaScript).
- Fixed a bug that caused `AzureCliCredential` to fail when a custom tenant ID was provided.
- Caught up with the bug fixes for Azure POD Identity that were implemented on version 1.5.1.

### Other Changes

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.

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.

## 2.0.0-beta.6 (2021-09-09)

### Features Added
Expand Down Expand Up @@ -176,7 +274,7 @@ This update marks the preview for the first major version update of the `@azure/
- This feature uses DPAPI on Windows, it tries to use the Keychain on OSX and the Keyring on Linux.
- To learn more on the usage, please refer to our docs on the `TokenCachePersistenceOptions` interface.
- **IMPORTANT:** As part of this beta, this feature is only supported in Node 10, 12 and 14.
- Changes to `InteractiveBrowserCredential`, `DeviceCodeCredential`, and `UsernamePasswordCredential`:
- Changes to `InteractiveBrowserCredential` and `DeviceCodeCredential`:
- 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.
- When enabled, this option stops the `getToken()` method from requesting user input in case the credential is unable to authenticate silently.
- 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).
Expand Down
4 changes: 4 additions & 0 deletions sdk/identity/identity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Key links:

## Getting started

### Migrate from v1 to v2 of @azure/identity

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.

### Currently supported environments

- [LTS versions of Node.js](https://nodejs.org/about/releases/)
Expand Down
1 change: 1 addition & 0 deletions sdk/identity/identity/Troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Troubleshooting
Loading

0 comments on commit 2a29ea7

Please sign in to comment.