-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Identity] Update identity plugin file structure so that versions aren't strictly tied to identity package #20340
Changes from all commits
a5b880d
0b7cfc4
bfda0eb
b7b929a
6a43bb8
3f707ea
ca81f59
5aba61a
dc52379
346f799
c334ec5
481a2d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Azure Identity Common client library for JavaScript | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: This isn't a "client" library and we should freely break the README template here. Just "Azure Identity Common Plugin Library" or something like that. I do think it's nice to have the README, even if we ditch the package.json or other associated files. |
||
|
||
An internal support library for the various Azure Identity libraries. | ||
|
||
This package contains common code that needs to be shared among the other Azure Identity libraries. It is not published to NPM and is not meant for usage by any other consumers. | ||
|
||
## Identity client libraries | ||
|
||
The following client libraries use this package: | ||
|
||
- [@azure/identity](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md) | ||
- [@azure/identity-vscode](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity-vscode/README.md) | ||
- [@azure/identity-cache-persistence](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity-cache-persistence/README.md) | ||
|
||
## Getting started | ||
|
||
For information on getting started, please see our [Identity client libraries](#identity-client-libraries). | ||
|
||
## Key concepts | ||
|
||
For information on key concepts, please see our [Identity client libraries](#identity-client-libraries). | ||
|
||
## Examples | ||
|
||
For examples, please see our [Identity client libraries](#identity-client-libraries). | ||
|
||
## Next steps | ||
|
||
For information on next steps, please see our [Identity client libraries](#identity-client-libraries). | ||
|
||
## Troubleshooting | ||
|
||
If you run into issues while using this library, directly or indirectly, please feel free to [file an issue](https://github.com/Azure/azure-sdk-for-js/issues/new). | ||
|
||
## Contributing | ||
|
||
If you'd like to contribute to this library, please 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. | ||
|
||
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fidentity%2Fidentity-common%2FREADME.png) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
{ | ||
"name": "@azure/identity-common", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we add this package.json here, we need to also add it to the rush configuration and set up a full build setup for it. There are pros and cons to that approach. At the end of the day I don't think that's what we want, and we need to make sure these files in identity-common are isolated modules without any external dependencies. That's problematic for the shared MSAL test configuration. I think the easiest solution for the test configuration is probably just to duplicate it, much as it may pain me. |
||
"sideEffects": false, | ||
"sdk-type": "client", | ||
"private": true, | ||
"author": "Microsoft Corporation", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"description": "Common internal functionality for all of the Azure Identity clients and plugins in the Azure SDK for JavaScript", | ||
"repository": "github:Azure/azure-sdk-for-js", | ||
"keywords": [ | ||
"azure", | ||
"cloud", | ||
"active directory", | ||
"authentication", | ||
"credential", | ||
"certificate", | ||
"managed identity", | ||
"client secret", | ||
"access token" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/Azure/azure-sdk-for-js/issues" | ||
}, | ||
"main": "./src/index.ts", | ||
"module": "dist-esm/index.js", | ||
"types": "./types/index.d.ts", | ||
"engines": { | ||
"node": ">=12.0.0" | ||
}, | ||
"scripts": { | ||
"audit": "echo skipped", | ||
"build:samples": "echo skipped", | ||
"build:es6": "tsc -p tsconfig.json", | ||
"build:nodebrowser": "echo skipped", | ||
"build:test": "echo skipped", | ||
"build": "npm run clean && npm run extract-api && npm run build:es6 && npm run build:nodebrowser", | ||
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", | ||
"clean": "rimraf dist-esm dist-test types *.tgz *.log samples/typescript/dist", | ||
"execute:js-samples": "echo skipped", | ||
"execute:ts-samples": "echo skipped", | ||
"execute:samples": "npm run build:samples && npm run execute:js-samples && npm run execute:ts-samples", | ||
"extract-api": "echo skipped", | ||
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\"", | ||
"integration-test:browser": "echo skipped", | ||
"integration-test:node": "echo skipped", | ||
"integration-test:node:no-timeout": "echo skipped", | ||
"integration-test": "npm run integration-test:node && npm run integration-test:browser", | ||
"lint:fix": "eslint package.json src --ext .ts --fix --fix-type [problem,suggestion]", | ||
"lint": "eslint package.json src --ext .ts", | ||
"pack": "npm pack 2>&1", | ||
"test:browser": "npm run clean && npm run build:test && npm run unit-test:browser", | ||
"test:node": "npm run clean && npm run build:test && npm run unit-test:node", | ||
"test": "npm run clean && npm run build:test && npm run unit-test", | ||
"unit-test:browser": "echo skipped", | ||
"unit-test:node": "echo skipped", | ||
"unit-test:node:no-timeout": "echo skipped", | ||
"unit-test": "npm run unit-test:node && npm run unit-test:browser", | ||
"docs": "echo Skipped." | ||
}, | ||
"dependencies": { | ||
"@azure/core-client": "^1.4.0", | ||
"tslib": "^2.2.0" | ||
}, | ||
"devDependencies": { | ||
"@azure/test-utils": "^1.0.0", | ||
"@azure/eslint-plugin-azure-sdk": "^3.0.0", | ||
"@azure-tools/test-recorder": "^1.0.0", | ||
"eslint": "^7.15.0", | ||
"prettier": "^2.5.1", | ||
"rimraf": "^3.0.0", | ||
"typescript": "~4.2.0", | ||
"sinon": "^9.0.2" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
export * from "../src"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this. This is Do we need this file at all? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { CachePluginControl } from "../../../identity/src/plugins/provider"; | ||
import { VSCodeCredentialFinder } from "../visualStudioCodeCredentialPlugin"; | ||
|
||
/** | ||
* The type of an Azure Identity plugin, a function accepting a plugin | ||
* context. | ||
*/ | ||
export type IdentityPlugin = (context: unknown) => void; | ||
|
||
/** | ||
* Plugin context entries for controlling VisualStudioCodeCredential. | ||
*/ | ||
export interface VisualStudioCodeCredentialControl { | ||
setVsCodeCredentialFinder(finder: VSCodeCredentialFinder): void; | ||
} | ||
|
||
/** | ||
* Context options passed to a plugin during initialization. | ||
* | ||
* Plugin authors are responsible for casting their plugin context values | ||
* to this type. | ||
* | ||
* @internal | ||
*/ | ||
export interface AzurePluginContext { | ||
cachePluginControl: CachePluginControl; | ||
vsCodeCredentialControl: VisualStudioCodeCredentialControl; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should move tests to identity-common, just sources. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the utility file for the tests that the plugin packages depend on. I had to do that to silence the build errors that I was receiving because of the utils for tests and sources from plugins |
||
// Licensed under the MIT license. | ||
|
||
import { | ||
record, | ||
Recorder, | ||
RecorderEnvironmentSetup, | ||
TestContextInterface, | ||
pluginForIdentitySDK, | ||
} from "@azure-tools/test-recorder"; | ||
import Sinon, { createSandbox } from "sinon"; | ||
import { MsalBaseUtilities } from "../../identity/src/msal/utils"; | ||
|
||
export type MsalTestCleanup = () => Promise<void>; | ||
|
||
export interface MsalTestSetupResponse { | ||
cleanup: MsalTestCleanup; | ||
recorder: Recorder; | ||
sandbox: Sinon.SinonSandbox; | ||
} | ||
|
||
export function msalNodeTestSetup( | ||
testContext: TestContextInterface | Mocha.Context | ||
): MsalTestSetupResponse { | ||
const playbackValues = { | ||
correlationId: "client-request-id", | ||
}; | ||
const recorderEnvSetup: RecorderEnvironmentSetup = { | ||
replaceableVariables: { | ||
AZURE_TENANT_ID: PlaybackTenantId, | ||
AZURE_CLIENT_ID: "azure_client_id", | ||
AZURE_CLIENT_SECRET: "azure_client_secret", | ||
AZURE_USERNAME: "azure_username", | ||
AZURE_PASSWORD: "azure_password", | ||
}, | ||
customizationsOnRecordings: [ | ||
(recording: string): string => | ||
recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`), | ||
(recording: string): string => | ||
recording.replace(/"refresh_token":"[^"]*"/g, `"refresh_token":"refresh_token"`), | ||
(recording: string): string => | ||
recording.replace(/refresh_token=[^&]*/g, `refresh_token=refresh_token`), | ||
(recording: string): string => | ||
recording.replace( | ||
/client-request-id=[a-z0-9-]*/g, | ||
`client-request-id=${playbackValues.correlationId}` | ||
), | ||
(recording: string): string => | ||
recording.replace(/client_assertion=[a-zA-Z0-9-._]*/g, `client_assertion=client_assertion`), | ||
(recording: string): string => recording.replace(/esctx=[a-zA-Z0-9-_]*/g, `esctx=esctx`), | ||
(recording: string): string => recording.replace(/'fpc=[^;]*/g, `'fpc=fpc;`), | ||
// Device code specific | ||
(recording: string): string => | ||
recording.replace(/user_code":"[^"]*/g, `user_code":"USER_CODE`), | ||
(recording: string): string => | ||
recording.replace( | ||
/enter the code [A-Z0-9]* to authenticate/g, | ||
`enter the code USER_CODE to authenticate` | ||
), | ||
(recording: string): string => | ||
recording.replace(/device_code":"[^"]*/g, `device_code":"DEVICE_CODE`), | ||
(recording: string): string => | ||
recording.replace(/device_code=[^&]*/g, `device_code=DEVICE_CODE`), | ||
(recording: string): string => recording.replace(/"interval": *[0-9]*/g, `"interval": 0`), | ||
// This last part is a JWT token that comes from the service, that has three parts joined by a dot. | ||
// Our fake id_token has the following parts encoded in base64 and joined by a dot: | ||
// - {"typ":"JWT","alg":"RS256","kid":"kid"} | ||
// - {"aud":"aud","iss":"https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/v2.0","iat":1615337163,"nbf":1615337163,"exp":1615341063,"aio":"aio","idp":"https://sts.windows.net/idp/","name":"Daniel Rodríguez","oid":"oid","preferred_username":"danrodri@microsoft.com","rh":"rh.","sub":"sub","tid":"12345678-1234-1234-1234-123456789012","uti":"uti","ver":"2.0"} | ||
// - no_idea_whats_this | ||
(recording: string): string => | ||
recording.replace( | ||
/id_token":"[^"]*/g, | ||
`id_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6ImtpZCJ9.eyJhdWQiOiJhdWQiLCJpc3MiOiJodHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vMTIzNDU2NzgtMTIzNC0xMjM0LTEyMzQtMTIzNDU2Nzg5MDEyL3YyLjAiLCJpYXQiOjE2MTUzMzcxNjMsIm5iZiI6MTYxNTMzNzE2MywiZXhwIjoxNjE1MzQxMDYzLCJhaW8iOiJhaW8iLCJpZHAiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9pZHAvIiwibmFtZSI6IkRhbmllbCBSb2Ryw61ndWV6Iiwib2lkIjoib2lkIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiZGFucm9kcmlAbWljcm9zb2Z0LmNvbSIsInJoIjoicmguIiwic3ViIjoic3ViIiwidGlkIjoiMTIzNDU2NzgtMTIzNC0xMjM0LTEyMzQtMTIzNDU2Nzg5MDEyIiwidXRpIjoidXRpIiwidmVyIjoiMi4wIn0=.bm9faWRlYV93aGF0c190aGlz` | ||
), | ||
// client_info is base64-encoded JSON that contains information about the user and tenant IDs | ||
// The following replaces it with some dummy JSON that uses a UID/UTID of 12345678-1234-1234-1234-123456789012 | ||
(recording) => | ||
recording.replace( | ||
/client_info":"[^"]*/g, | ||
'client_info":"eyJ1aWQiOiIxMjM0NTY3OC0xMjM0LTEyMzQtMTIzNC0xMjM0NTY3ODkwMTIiLCJ1dGlkIjoiMTIzNDU2NzgtMTIzNC0xMjM0LTEyMzQtMTIzNDU2Nzg5MDEyIn0K' | ||
), | ||
], | ||
queryParametersToSkip: [], | ||
onLoadCallbackForPlayback: pluginForIdentitySDK, | ||
}; | ||
const recorder = record(testContext, recorderEnvSetup); | ||
const sandbox = createSandbox(); | ||
|
||
const stub = sandbox.stub(MsalBaseUtilities.prototype, "generateUuid"); | ||
stub.returns(playbackValues.correlationId); | ||
|
||
return { | ||
sandbox, | ||
recorder, | ||
async cleanup() { | ||
await recorder.stop(); | ||
sandbox.restore(); | ||
}, | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ | |
}, | ||
"files": [ | ||
"dist/", | ||
"dist-esm/identity/src", | ||
"dist-esm/identity-common/src", | ||
"dist-esm/identity-vscode/src", | ||
"types/identity-vscode.d.ts", | ||
"README.md", | ||
|
@@ -60,6 +60,7 @@ | |
"sideEffects": false, | ||
"dependencies": { | ||
"@azure/identity": "^2.0.1", | ||
"@azure/msal-common": "^4.5.1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment about the same line in identity-cache-persistence |
||
"keytar": "^7.6.0", | ||
"tslib": "^2.2.0" | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change required? Are we importing from it anywhere? Does this have to do with msalTestUtils?