@azure/identity 3.1.0-alpha.20221021.2 → 3.1.0-alpha.20221104.2
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.
- package/README.md +6 -5
- package/dist/index.js +87 -80
- package/dist/index.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.js +2 -2
- package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.js +5 -0
- package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js +8 -6
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js +1 -1
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +1 -1
- package/dist-esm/src/util/processMultiTenantRequest.browser.js.map +1 -1
- package/dist-esm/src/util/processMultiTenantRequest.js.map +1 -1
- package/package.json +1 -1
- package/types/identity.d.ts +7 -2
package/README.md
CHANGED
|
@@ -277,11 +277,12 @@ Not all credentials require this configuration. Credentials that authenticate th
|
|
|
277
277
|
|
|
278
278
|
#### Username and password
|
|
279
279
|
|
|
280
|
-
| Variable name | Value
|
|
281
|
-
| ----------------- |
|
|
282
|
-
| `AZURE_CLIENT_ID` | ID of an Azure AD application
|
|
283
|
-
| `
|
|
284
|
-
| `
|
|
280
|
+
| Variable name | Value |
|
|
281
|
+
| ----------------- | --------------------------------------- |
|
|
282
|
+
| `AZURE_CLIENT_ID` | ID of an Azure AD application |
|
|
283
|
+
| `AZURE_TENANT_ID` | ID of the application's Azure AD tenant |
|
|
284
|
+
| `AZURE_USERNAME` | a username (usually an email address) |
|
|
285
|
+
| `AZURE_PASSWORD` | that user's password |
|
|
285
286
|
|
|
286
287
|
Configuration is attempted in the above order. For example, if values for a client secret and certificate are both present, the client secret will be used.
|
|
287
288
|
|
package/dist/index.js
CHANGED
|
@@ -512,6 +512,78 @@ function deserializeAuthenticationRecord(serializedRecord) {
|
|
|
512
512
|
return parsed;
|
|
513
513
|
}
|
|
514
514
|
|
|
515
|
+
// Copyright (c) Microsoft Corporation.
|
|
516
|
+
// Licensed under the MIT license.
|
|
517
|
+
function createConfigurationErrorMessage(tenantId) {
|
|
518
|
+
return `The current credential is not configured to acquire tokens for tenant ${tenantId}. To enable acquiring tokens for this tenant add it to the AdditionallyAllowedTenants on the credential options, or add "*" to AdditionallyAllowedTenants to allow acquiring tokens for any tenant.`;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Of getToken contains a tenantId, this functions allows picking this tenantId as the appropriate for authentication,
|
|
522
|
+
* unless multitenant authentication has been disabled through the AZURE_IDENTITY_DISABLE_MULTITENANTAUTH (on Node.js),
|
|
523
|
+
* or unless the original tenant Id is `adfs`.
|
|
524
|
+
* @internal
|
|
525
|
+
*/
|
|
526
|
+
function processMultiTenantRequest(tenantId, getTokenOptions, additionallyAllowedTenantIds = []) {
|
|
527
|
+
var _a;
|
|
528
|
+
let resolvedTenantId;
|
|
529
|
+
if (process.env.AZURE_IDENTITY_DISABLE_MULTITENANTAUTH) {
|
|
530
|
+
resolvedTenantId = tenantId;
|
|
531
|
+
}
|
|
532
|
+
else if (tenantId === "adfs") {
|
|
533
|
+
resolvedTenantId = tenantId;
|
|
534
|
+
}
|
|
535
|
+
else {
|
|
536
|
+
resolvedTenantId = (_a = getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.tenantId) !== null && _a !== void 0 ? _a : tenantId;
|
|
537
|
+
}
|
|
538
|
+
if (tenantId &&
|
|
539
|
+
resolvedTenantId !== tenantId &&
|
|
540
|
+
!additionallyAllowedTenantIds.includes("*") &&
|
|
541
|
+
!additionallyAllowedTenantIds.some((t) => t.localeCompare(resolvedTenantId) === 0)) {
|
|
542
|
+
throw new Error(createConfigurationErrorMessage(tenantId));
|
|
543
|
+
}
|
|
544
|
+
return resolvedTenantId;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// Copyright (c) Microsoft Corporation.
|
|
548
|
+
/**
|
|
549
|
+
* @internal
|
|
550
|
+
*/
|
|
551
|
+
function checkTenantId(logger, tenantId) {
|
|
552
|
+
if (!tenantId.match(/^[0-9a-zA-Z-.:/]+$/)) {
|
|
553
|
+
const error = new Error("Invalid tenant id provided. You can locate your tenant id by following the instructions listed here: https://docs.microsoft.com/partner-center/find-ids-and-domain-names.");
|
|
554
|
+
logger.info(formatError("", error));
|
|
555
|
+
throw error;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* @internal
|
|
560
|
+
*/
|
|
561
|
+
function resolveTenantId(logger, tenantId, clientId) {
|
|
562
|
+
if (tenantId) {
|
|
563
|
+
checkTenantId(logger, tenantId);
|
|
564
|
+
return tenantId;
|
|
565
|
+
}
|
|
566
|
+
if (!clientId) {
|
|
567
|
+
clientId = DeveloperSignOnClientId;
|
|
568
|
+
}
|
|
569
|
+
if (clientId !== DeveloperSignOnClientId) {
|
|
570
|
+
return "common";
|
|
571
|
+
}
|
|
572
|
+
return "organizations";
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* @internal
|
|
576
|
+
*/
|
|
577
|
+
function resolveAddionallyAllowedTenantIds(additionallyAllowedTenants) {
|
|
578
|
+
if (!additionallyAllowedTenants || additionallyAllowedTenants.length === 0) {
|
|
579
|
+
return [];
|
|
580
|
+
}
|
|
581
|
+
if (additionallyAllowedTenants.includes("*")) {
|
|
582
|
+
return ALL_TENANTS;
|
|
583
|
+
}
|
|
584
|
+
return additionallyAllowedTenants;
|
|
585
|
+
}
|
|
586
|
+
|
|
515
587
|
// Copyright (c) Microsoft Corporation.
|
|
516
588
|
// Licensed under the MIT license.
|
|
517
589
|
function getIdentityTokenEndpointSuffix(tenantId) {
|
|
@@ -928,78 +1000,6 @@ var RegionalAuthority;
|
|
|
928
1000
|
RegionalAuthority["GovernmentUSDodCentral"] = "usdodcentral";
|
|
929
1001
|
})(RegionalAuthority || (RegionalAuthority = {}));
|
|
930
1002
|
|
|
931
|
-
// Copyright (c) Microsoft Corporation.
|
|
932
|
-
// Licensed under the MIT license.
|
|
933
|
-
function createConfigurationErrorMessage(tenantId) {
|
|
934
|
-
return `The current credential is not configured to acquire tokens for tenant ${tenantId}. To enable acquiring tokens for this tenant add it to the AdditionallyAllowedTenants on the credential options, or add "*" to AdditionallyAllowedTenants to allow acquiring tokens for any tenant.`;
|
|
935
|
-
}
|
|
936
|
-
/**
|
|
937
|
-
* Of getToken contains a tenantId, this functions allows picking this tenantId as the appropriate for authentication,
|
|
938
|
-
* unless multitenant authentication has been disabled through the AZURE_IDENTITY_DISABLE_MULTITENANTAUTH (on Node.js),
|
|
939
|
-
* or unless the original tenant Id is `adfs`.
|
|
940
|
-
* @internal
|
|
941
|
-
*/
|
|
942
|
-
function processMultiTenantRequest(tenantId, getTokenOptions, additionallyAllowedTenantIds = []) {
|
|
943
|
-
var _a;
|
|
944
|
-
let resolvedTenantId;
|
|
945
|
-
if (process.env.AZURE_IDENTITY_DISABLE_MULTITENANTAUTH) {
|
|
946
|
-
resolvedTenantId = tenantId;
|
|
947
|
-
}
|
|
948
|
-
else if (tenantId === "adfs") {
|
|
949
|
-
resolvedTenantId = tenantId;
|
|
950
|
-
}
|
|
951
|
-
else {
|
|
952
|
-
resolvedTenantId = (_a = getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.tenantId) !== null && _a !== void 0 ? _a : tenantId;
|
|
953
|
-
}
|
|
954
|
-
if (tenantId &&
|
|
955
|
-
resolvedTenantId !== tenantId &&
|
|
956
|
-
!additionallyAllowedTenantIds.includes("*") &&
|
|
957
|
-
!additionallyAllowedTenantIds.some((t) => t.localeCompare(resolvedTenantId) === 0)) {
|
|
958
|
-
throw new Error(createConfigurationErrorMessage(tenantId));
|
|
959
|
-
}
|
|
960
|
-
return resolvedTenantId;
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
// Copyright (c) Microsoft Corporation.
|
|
964
|
-
/**
|
|
965
|
-
* @internal
|
|
966
|
-
*/
|
|
967
|
-
function checkTenantId(logger, tenantId) {
|
|
968
|
-
if (!tenantId.match(/^[0-9a-zA-Z-.:/]+$/)) {
|
|
969
|
-
const error = new Error("Invalid tenant id provided. You can locate your tenant id by following the instructions listed here: https://docs.microsoft.com/partner-center/find-ids-and-domain-names.");
|
|
970
|
-
logger.info(formatError("", error));
|
|
971
|
-
throw error;
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
/**
|
|
975
|
-
* @internal
|
|
976
|
-
*/
|
|
977
|
-
function resolveTenantId(logger, tenantId, clientId) {
|
|
978
|
-
if (tenantId) {
|
|
979
|
-
checkTenantId(logger, tenantId);
|
|
980
|
-
return tenantId;
|
|
981
|
-
}
|
|
982
|
-
if (!clientId) {
|
|
983
|
-
clientId = DeveloperSignOnClientId;
|
|
984
|
-
}
|
|
985
|
-
if (clientId !== DeveloperSignOnClientId) {
|
|
986
|
-
return "common";
|
|
987
|
-
}
|
|
988
|
-
return "organizations";
|
|
989
|
-
}
|
|
990
|
-
/**
|
|
991
|
-
* @internal
|
|
992
|
-
*/
|
|
993
|
-
function resolveAddionallyAllowedTenantIds(additionallyAllowedTenants) {
|
|
994
|
-
if (!additionallyAllowedTenants || additionallyAllowedTenants.length === 0) {
|
|
995
|
-
return [];
|
|
996
|
-
}
|
|
997
|
-
if (additionallyAllowedTenants.includes("*")) {
|
|
998
|
-
return ALL_TENANTS;
|
|
999
|
-
}
|
|
1000
|
-
return additionallyAllowedTenants;
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
1003
|
// Copyright (c) Microsoft Corporation.
|
|
1004
1004
|
/**
|
|
1005
1005
|
* The current persistence provider, undefined by default.
|
|
@@ -1026,20 +1026,21 @@ const msalNodeFlowCacheControl = {
|
|
|
1026
1026
|
*/
|
|
1027
1027
|
class MsalNode extends MsalBaseUtilities {
|
|
1028
1028
|
constructor(options) {
|
|
1029
|
-
var _a, _b, _c;
|
|
1029
|
+
var _a, _b, _c, _d;
|
|
1030
1030
|
super(options);
|
|
1031
1031
|
this.requiresConfidential = false;
|
|
1032
1032
|
this.msalConfig = this.defaultNodeMsalConfig(options);
|
|
1033
1033
|
this.tenantId = resolveTenantId(options.logger, options.tenantId, options.clientId);
|
|
1034
|
+
this.additionallyAllowedTenantIds = resolveAddionallyAllowedTenantIds((_a = options === null || options === void 0 ? void 0 : options.tokenCredentialOptions) === null || _a === void 0 ? void 0 : _a.additionallyAllowedTenants);
|
|
1034
1035
|
this.clientId = this.msalConfig.auth.clientId;
|
|
1035
1036
|
if (options === null || options === void 0 ? void 0 : options.getAssertion) {
|
|
1036
1037
|
this.getAssertion = options.getAssertion;
|
|
1037
1038
|
}
|
|
1038
1039
|
// If persistence has been configured
|
|
1039
|
-
if (persistenceProvider !== undefined && ((
|
|
1040
|
+
if (persistenceProvider !== undefined && ((_b = options.tokenCachePersistenceOptions) === null || _b === void 0 ? void 0 : _b.enabled)) {
|
|
1040
1041
|
this.createCachePlugin = () => persistenceProvider(options.tokenCachePersistenceOptions);
|
|
1041
1042
|
}
|
|
1042
|
-
else if ((
|
|
1043
|
+
else if ((_c = options.tokenCachePersistenceOptions) === null || _c === void 0 ? void 0 : _c.enabled) {
|
|
1043
1044
|
throw new Error([
|
|
1044
1045
|
"Persistent token caching was requested, but no persistence provider was configured.",
|
|
1045
1046
|
"You must install the identity-cache-persistence plugin package (`npm install --save @azure/identity-cache-persistence`)",
|
|
@@ -1047,7 +1048,7 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1047
1048
|
"`useIdentityPlugin(cachePersistencePlugin)` before using `tokenCachePersistenceOptions`.",
|
|
1048
1049
|
].join(" "));
|
|
1049
1050
|
}
|
|
1050
|
-
this.azureRegion = (
|
|
1051
|
+
this.azureRegion = (_d = options.regionalAuthority) !== null && _d !== void 0 ? _d : process.env.AZURE_REGIONAL_AUTHORITY_NAME;
|
|
1051
1052
|
if (this.azureRegion === RegionalAuthority.AutoDiscoverRegion) {
|
|
1052
1053
|
this.azureRegion = "AUTO_DISCOVER";
|
|
1053
1054
|
}
|
|
@@ -1195,7 +1196,8 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1195
1196
|
* If disableAutomaticAuthentication is sent through the constructor, it will prevent MSAL from requesting the user input.
|
|
1196
1197
|
*/
|
|
1197
1198
|
async getToken(scopes, options = {}) {
|
|
1198
|
-
const tenantId = processMultiTenantRequest(this.tenantId, options) ||
|
|
1199
|
+
const tenantId = processMultiTenantRequest(this.tenantId, options, this.additionallyAllowedTenantIds) ||
|
|
1200
|
+
this.tenantId;
|
|
1199
1201
|
options.authority = getAuthority(tenantId, this.authorityHost);
|
|
1200
1202
|
options.correlationId = (options === null || options === void 0 ? void 0 : options.correlationId) || this.generateUuid();
|
|
1201
1203
|
await this.init(options);
|
|
@@ -1294,6 +1296,11 @@ function getPropertyFromVSCode(property) {
|
|
|
1294
1296
|
* Connects to Azure using the credential provided by the VSCode extension 'Azure Account'.
|
|
1295
1297
|
* Once the user has logged in via the extension, this credential can share the same refresh token
|
|
1296
1298
|
* that is cached by the extension.
|
|
1299
|
+
*
|
|
1300
|
+
* It's a [known issue](https://github.com/Azure/azure-sdk-for-js/issues/20500) that this credential doesn't
|
|
1301
|
+
* work with [Azure Account extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account)
|
|
1302
|
+
* versions newer than **0.9.11**. A long-term fix to this problem is in progress. In the meantime, consider
|
|
1303
|
+
* authenticating with {@link AzureCliCredential}.
|
|
1297
1304
|
*/
|
|
1298
1305
|
class VisualStudioCodeCredential {
|
|
1299
1306
|
/**
|
|
@@ -3088,8 +3095,8 @@ function getAdditionallyAllowedTenants() {
|
|
|
3088
3095
|
const credentialName$1 = "EnvironmentCredential";
|
|
3089
3096
|
const logger$5 = credentialLogger(credentialName$1);
|
|
3090
3097
|
/**
|
|
3091
|
-
* Enables authentication to Azure Active Directory using client secret
|
|
3092
|
-
*
|
|
3098
|
+
* Enables authentication to Azure Active Directory using a client secret or certificate, or as a user
|
|
3099
|
+
* with a username and password.
|
|
3093
3100
|
*/
|
|
3094
3101
|
class EnvironmentCredential {
|
|
3095
3102
|
/**
|
|
@@ -3429,7 +3436,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3429
3436
|
reject(new Error("Aborted"));
|
|
3430
3437
|
});
|
|
3431
3438
|
}
|
|
3432
|
-
openPromise.
|
|
3439
|
+
openPromise.catch((e) => {
|
|
3433
3440
|
cleanup();
|
|
3434
3441
|
reject(e);
|
|
3435
3442
|
});
|