-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Board Review: Introducing an @azure/identity extension API, @azure/identity-persistence and @azure/identity-vscode #2896
Comments
scheduled for 6/3 2-4pm pst |
I've got a couple of questions I'd love to discuss during the review today:
|
@tg-msft some pre-emptive answers below:
Yes, this is an API breaking change across a major version boundary. A user can no longer
While it's primarily about factoring the Identity SDK apart, it sets a precedent in our repo as well by establishing a pattern for doing this kind of dependency injection. The implementation is tightly coupled with the Identity package implementation, though, so it's not a generally reusable abstraction.
In general, there is a representation of an "extension" that is exported from the extension package (an "extension provider"), and the identity package contains logic for consuming those extension representations. The extension is basically a function that is called with an "extension context" that allows mutating certain, sanctioned internal properties of the @azure/identity package. For example, they can set a cache plugin for the Node auth flows, and they can add credentials to the DefaultAzureCredential list.
The last extension applied has final authority, but they do not necessarily conflict. If it sets a cache plugin, it will overwrite any previously configured cache plugins. However, two different extensions could add separate credentials to the default credential list, for example.
Yes and no. Yes because you could explicitly alias and require two different versions of it. I don't really know what to make of that scenario (@xirzec). An extension mutates static properties of the module. When an extension is registered it is registered for all consumers of that module within the process (however, there could be multiple copies of the package naturally if the version constraints require it, for example I could load Identity 2.0.0-beta.4 but one of my dependencies could load Identity 1.3.0, and the extension would only be applied to the 2.0.0-beta.4 copy).
The current implementation makes it hard for 3rd party extensions, and the API contract for extensions isn't flexible enough to do much more than what we've already provided (though someone could theoretically use it to provide a custom implementation of a cache plugin, for example). Someone would have to look at our code and see how we interact with the extension system. We use various tricks to hide the implementation details of the extension subsystem from the public API surface, so they'd effectively need a copy of our
The extension API becomes part of our API contract. If we break it, we'd have to treat it as a breaking change, so it's important that we get it right through the beta cycles.
This would be supported as long as there haven't been breaking changes in the extension API. The identity-vscode package, for example, doesn't rely on any internals from
Same story as above. As long as the extension API is stable, a newer Identity package should never break an old extension. For example, if the MSAL definition of a cache plugin were to change, we would have to treat that as a breaking change, because the extension API provides access to that system.
Yes. The extension packages depend on
No. Well, maybe. You can alias packages in NPM and get two versions of the same extension package. With our existing packages, there isn't much point to this, and two versions of the persistence extension would overwrite one another. Two versions of VisualStudioCodeCredential would just result in two copies of that credential being added to the DefaultAzureCredential list.
We will have pointers in the README files that explain the extensions, and we will also add a "stub" credential to @azure/identity that, if DefaultAzureCredential fails, will display a message explaining the identity-vscode package. When the extension is registered, it'll replace the stub with the real credential, so users will only see the message if DAC fails and VisualStudioCodeCredential wasn't available.
We did consider this option. We also considered the inverted alternative of having
Personally, I can't wait to find out! At the end of the day, these are just packages, and so they'll get their own pages on docs.ms. The extension API is currently hidden (effectively) from the API listing, so it won't show up, but the |
Recording[MS INTERNAL ONLY] |
This issue is for a board review of the new extension API for
@azure/identity
as well as two companion packages:@azure/identity-persistence
, providing access to persistent token caching@azure/identity-vscode
, extracting the existingVisualStudioCodeCredential
into a separate packageThis is a scenario and client packages that are unique to the Azure SDK for JavaScript. The scenarios are explained below. We are primarily seeking advice about the names of the packages and the overall architectural approach of creating an extensible Azure Identity API.
Our immediate goal is to reach a consensus on the names of the packages and the extension approach, so that we can proceed with a beta release and user studies.
Contacts and Timeline
About the client library
This review consists of modifications to the existing
@azure/identity
library, as well as two new packages that have not previously been released (and therefore have no available reference documentation):@azure/identity-persistence
@azure/identity-vscode
Understanding the Scenario
The Azure Identity package for JavaScript utilizes native machine-code dependencies to support certain functionality. Specifically:
However, requiring our downstream customers to install these native module depdendencies has proven problematic. Some of the native dependencies do not offer prebuilt binaries, either, so customers wishing to use that functionality are required to install C/C++ build tools to install those dependencies. We are proposing this alternative extension-based architecture to provide this functionality optionally for customers who want to use Azure Identity, but don't wish to use any machine code dependencies. For example, we have customers who:
In the past, we have listed our machine code dependencies as "optional" dependencies. However, changes to NPM v7 have rendered that strategy ineffective, as NPM v7 now attepmpts to install optional dependencies by default. We have also considered leaving the dependencies unlisted altogether, but we are concerned about discoverability issues, and doing so would violate core principles of the JavaScript packaging ecosystem.
In order to alleviate these concerns, we are proposing the following changes:
@azure/identity
that will enable other package to export "plugin" objects that can be used to enhance@azure/identity
.VisualStudioCodeCredential
from@azure/identity
and move it to a new package,@azure/identity-vscode
.@azure/identity-vscode
, export a plugin object that, when added to@azure/identity
at runtime will addVisualStudioCodeCredential
to the list of credentials tried byDefaultAzureCredential
.@azure/identity-persistence
that exports a plugin that will enable persistent token caching through OS-native secure storage when it is added to@azure/identity
.Sample Programs
The proposed design and implementation is currently in a Draft PR state, and links to our most up-to-date draft samples can be found at the following links:
@azure/identity-persistence
sample@azure/identity-vscode
samplesIn general, you can observe that each of the samples follows this pattern:
JavaScript Prior Art
Some other packages use similar extension systems, and our primary example of such a package in the JavaScript ecosystem is the Chai assertion framework, which we use as part of our testing strategy and which boasts 3.3 million weekly downloads. It has a very similar extension system, for example, the
chai-as-promised
extension package extendschai
with support for asynchronous operations:After "using" the extension,
chai
is extended with additional functionality as specified by thechaiAsPromised
plugin. Our proposal is to extend Azure Identity for JavaScript with a similar system and leverage that system to solve the problem of machine code dependencies in the mainline@azure/identity
package.The text was updated successfully, but these errors were encountered: