@microsoft/vscode-azext-azureauth 4.1.1 → 4.2.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.
- package/CHANGELOG.md +4 -0
- package/README.md +0 -2
- package/l10n/bundle.l10n.json +5 -0
- package/out/src/AzureAuthentication.d.ts +1 -1
- package/out/src/AzureDevOpsSubscriptionProvider.js +23 -28
- package/out/src/NotSignedInError.js +2 -2
- package/out/src/VSCodeAzureSubscriptionProvider.js +44 -55
- package/out/src/getSessionFromVSCode.d.ts +2 -1
- package/out/src/getSessionFromVSCode.js +14 -3
- package/out/src/signInToTenant.js +3 -4
- package/out/src/utils/configuredAzureEnv.js +5 -6
- package/out/src/utils/getUnauthenticatedTenants.js +6 -12
- package/out/src/utils/isAuthenticationSessionRequest.d.ts +2 -0
- package/out/src/utils/isAuthenticationSessionRequest.js +11 -0
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.2.0
|
|
4
|
+
|
|
5
|
+
* [#2057](https://github.com/microsoft/vscode-azuretools/pull/2057) Support providing a challenge when getting sessions from VS Code
|
|
6
|
+
|
|
3
7
|
## 4.1.1 - 2025-02-03
|
|
4
8
|
|
|
5
9
|
* Fix `VSCodeAzureSubscriptionProvider` implementation of `getSubscriptions` filtering returned subscriptions by `getSubscriptionFilters()` when the `filter` parameter is a `GetSubscriptionsFilter` object.
|
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# VSCode Azure SDK for Node.js - Azure Auth
|
|
2
2
|
|
|
3
|
-
[](https://dev.azure.com/ms-azuretools/AzCode/_build/latest?definitionId=17)
|
|
4
|
-
|
|
5
3
|
This package provides a simple way to authenticate to Azure and receive Azure subscription information. It uses the [built-in Microsoft Authentication extension](https://github.com/microsoft/vscode/tree/main/extensions/microsoft-authentication) and does not rely on the [Azure Account extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account) in any way.
|
|
6
4
|
|
|
7
5
|
## Azure Subscription Provider
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Signing out programmatically is not supported. You must sign out by selecting the account in the Accounts menu and choosing Sign Out.": "Signing out programmatically is not supported. You must sign out by selecting the account in the Accounts menu and choosing Sign Out.",
|
|
3
|
+
"You are not signed in to an Azure account. Please sign in.": "You are not signed in to an Azure account. Please sign in.",
|
|
4
|
+
"The custom cloud choice is not configured. Please configure the setting `{0}.{1}`.": "The custom cloud choice is not configured. Please configure the setting `{0}.{1}`."
|
|
5
|
+
}
|
|
@@ -17,5 +17,5 @@ export interface AzureAuthentication {
|
|
|
17
17
|
*
|
|
18
18
|
* @returns A VS Code authentication session or undefined, if none could be obtained.
|
|
19
19
|
*/
|
|
20
|
-
getSessionWithScopes(scopes: string[]): vscode.ProviderResult<vscode.AuthenticationSession>;
|
|
20
|
+
getSessionWithScopes(scopes: string[] | vscode.AuthenticationSessionRequest): vscode.ProviderResult<vscode.AuthenticationSession>;
|
|
21
21
|
}
|
|
@@ -20,7 +20,8 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
20
20
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.AzureDevOpsSubscriptionProvider =
|
|
23
|
+
exports.AzureDevOpsSubscriptionProvider = void 0;
|
|
24
|
+
exports.createAzureDevOpsSubscriptionProviderFactory = createAzureDevOpsSubscriptionProviderFactory;
|
|
24
25
|
const vscode_1 = require("vscode");
|
|
25
26
|
const configuredAzureEnv_1 = require("./utils/configuredAzureEnv");
|
|
26
27
|
let azureDevOpsSubscriptionProvider;
|
|
@@ -30,7 +31,6 @@ function createAzureDevOpsSubscriptionProviderFactory(initializer) {
|
|
|
30
31
|
return azureDevOpsSubscriptionProvider;
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
|
-
exports.createAzureDevOpsSubscriptionProviderFactory = createAzureDevOpsSubscriptionProviderFactory;
|
|
34
34
|
/**
|
|
35
35
|
* AzureSubscriptionProvider implemented to authenticate via federated DevOps service connection, using workflow identity federation
|
|
36
36
|
* To learn how to configure your DevOps environment to use this provider, refer to the README.md
|
|
@@ -83,8 +83,8 @@ class AzureDevOpsSubscriptionProvider {
|
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
getTenants() {
|
|
86
|
-
var _a;
|
|
87
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
var _a;
|
|
88
88
|
return [{
|
|
89
89
|
tenantId: (_a = this._tokenCredential) === null || _a === void 0 ? void 0 : _a.tenantId,
|
|
90
90
|
account: {
|
|
@@ -102,36 +102,31 @@ class AzureDevOpsSubscriptionProvider {
|
|
|
102
102
|
* @returns The list of subscriptions for the tenant.
|
|
103
103
|
*/
|
|
104
104
|
getSubscriptionsForTenant(tenantId) {
|
|
105
|
-
var _a, e_1, _b, _c;
|
|
106
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
var _a, e_1, _b, _c;
|
|
107
107
|
const { client, credential, authentication } = yield this.getSubscriptionClient(tenantId);
|
|
108
108
|
const environment = (0, configuredAzureEnv_1.getConfiguredAzureEnv)();
|
|
109
109
|
const subscriptions = [];
|
|
110
110
|
try {
|
|
111
|
-
for (var _d = true, _e = __asyncValues(client.subscriptions.list()), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
|
|
111
|
+
for (var _d = true, _e = __asyncValues(client.subscriptions.list()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
112
112
|
_c = _f.value;
|
|
113
113
|
_d = false;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
finally {
|
|
133
|
-
_d = true;
|
|
134
|
-
}
|
|
114
|
+
const subscription = _c;
|
|
115
|
+
subscriptions.push({
|
|
116
|
+
authentication,
|
|
117
|
+
environment: environment,
|
|
118
|
+
credential: credential,
|
|
119
|
+
isCustomCloud: environment.isCustomCloud,
|
|
120
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
121
|
+
name: subscription.displayName,
|
|
122
|
+
subscriptionId: subscription.subscriptionId,
|
|
123
|
+
/* eslint-enable @typescript-eslint/no-non-null-assertion */
|
|
124
|
+
tenantId,
|
|
125
|
+
account: {
|
|
126
|
+
id: "test-account-id",
|
|
127
|
+
label: "test-account",
|
|
128
|
+
},
|
|
129
|
+
});
|
|
135
130
|
}
|
|
136
131
|
}
|
|
137
132
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -152,8 +147,8 @@ class AzureDevOpsSubscriptionProvider {
|
|
|
152
147
|
* @returns A client, the credential used by the client, and the authentication function
|
|
153
148
|
*/
|
|
154
149
|
getSubscriptionClient(_tenantId, scopes) {
|
|
155
|
-
var _a, _b;
|
|
156
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
var _a, _b;
|
|
157
152
|
const armSubs = yield Promise.resolve().then(() => require('@azure/arm-resources-subscriptions'));
|
|
158
153
|
if (!this._tokenCredential) {
|
|
159
154
|
throw new Error('Not signed in');
|
|
@@ -226,8 +221,8 @@ function getTokenCredential(serviceConnectionId, domain, clientId) {
|
|
|
226
221
|
* API reference: https://learn.microsoft.com/en-us/rest/api/azure/devops/distributedtask/oidctoken/create
|
|
227
222
|
*/
|
|
228
223
|
function requestOidcToken(oidcRequestUrl, systemAccessToken) {
|
|
229
|
-
var _a;
|
|
230
224
|
return __awaiter(this, void 0, void 0, function* () {
|
|
225
|
+
var _a;
|
|
231
226
|
const { ServiceClient } = yield Promise.resolve().then(() => require('@azure/core-client'));
|
|
232
227
|
const { createHttpHeaders, createPipelineRequest } = yield Promise.resolve().then(() => require('@azure/core-rest-pipeline'));
|
|
233
228
|
const genericClient = new ServiceClient();
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.NotSignedInError = void 0;
|
|
8
|
+
exports.isNotSignedInError = isNotSignedInError;
|
|
8
9
|
const vscode = require("vscode");
|
|
9
10
|
/**
|
|
10
11
|
* An error indicating the user is not signed in.
|
|
@@ -26,5 +27,4 @@ exports.NotSignedInError = NotSignedInError;
|
|
|
26
27
|
function isNotSignedInError(error) {
|
|
27
28
|
return !!error && typeof error === 'object' && error.isNotSignedInError === true;
|
|
28
29
|
}
|
|
29
|
-
exports.isNotSignedInError = isNotSignedInError;
|
|
30
30
|
//# sourceMappingURL=NotSignedInError.js.map
|
|
@@ -25,6 +25,7 @@ const vscode = require("vscode");
|
|
|
25
25
|
const getSessionFromVSCode_1 = require("./getSessionFromVSCode");
|
|
26
26
|
const NotSignedInError_1 = require("./NotSignedInError");
|
|
27
27
|
const configuredAzureEnv_1 = require("./utils/configuredAzureEnv");
|
|
28
|
+
const isAuthenticationSessionRequest_1 = require("./utils/isAuthenticationSessionRequest");
|
|
28
29
|
const EventDebounce = 5 * 1000; // 5 seconds
|
|
29
30
|
/**
|
|
30
31
|
* A class for obtaining Azure subscription information using VSCode's built-in authentication
|
|
@@ -78,45 +79,35 @@ class VSCodeAzureSubscriptionProvider extends vscode.Disposable {
|
|
|
78
79
|
* @returns A list of tenants.
|
|
79
80
|
*/
|
|
80
81
|
getTenants(account) {
|
|
81
|
-
var _a, e_1, _b, _c, _d, e_2, _e, _f;
|
|
82
|
-
var _g;
|
|
83
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
var _a, e_1, _b, _c, _d, e_2, _e, _f;
|
|
84
|
+
var _g;
|
|
84
85
|
const startTimeMs = Date.now();
|
|
85
86
|
const results = [];
|
|
86
87
|
try {
|
|
87
|
-
for (var _h = true, _j = __asyncValues(account ? [account] : yield vscode.authentication.getAccounts((0, configuredAzureEnv_1.getConfiguredAuthProviderId)())), _k; _k = yield _j.next(), _a = _k.done, !_a;) {
|
|
88
|
+
for (var _h = true, _j = __asyncValues(account ? [account] : yield vscode.authentication.getAccounts((0, configuredAzureEnv_1.getConfiguredAuthProviderId)())), _k; _k = yield _j.next(), _a = _k.done, !_a; _h = true) {
|
|
88
89
|
_c = _k.value;
|
|
89
90
|
_h = false;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const tenant = _f;
|
|
101
|
-
results.push(Object.assign(Object.assign({}, tenant), { account }));
|
|
102
|
-
}
|
|
103
|
-
finally {
|
|
104
|
-
_l = true;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
91
|
+
account = _c;
|
|
92
|
+
// Added check. Without this the getSubscriptionClient function throws the NotSignedInError
|
|
93
|
+
if (yield this.isSignedIn(undefined, account)) {
|
|
94
|
+
const { client } = yield this.getSubscriptionClient(account, undefined, undefined);
|
|
95
|
+
try {
|
|
96
|
+
for (var _l = true, _m = (e_2 = void 0, __asyncValues(client.tenants.list())), _o; _o = yield _m.next(), _d = _o.done, !_d; _l = true) {
|
|
97
|
+
_f = _o.value;
|
|
98
|
+
_l = false;
|
|
99
|
+
const tenant = _f;
|
|
100
|
+
results.push(Object.assign(Object.assign({}, tenant), { account }));
|
|
107
101
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
finally { if (e_2) throw e_2.error; }
|
|
102
|
+
}
|
|
103
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
104
|
+
finally {
|
|
105
|
+
try {
|
|
106
|
+
if (!_l && !_d && (_e = _m.return)) yield _e.call(_m);
|
|
114
107
|
}
|
|
108
|
+
finally { if (e_2) throw e_2.error; }
|
|
115
109
|
}
|
|
116
110
|
}
|
|
117
|
-
finally {
|
|
118
|
-
_h = true;
|
|
119
|
-
}
|
|
120
111
|
}
|
|
121
112
|
}
|
|
122
113
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -148,9 +139,9 @@ class VSCodeAzureSubscriptionProvider extends vscode.Disposable {
|
|
|
148
139
|
* Use {@link isSignedIn} and/or {@link signIn} before this method to ensure
|
|
149
140
|
* the user is signed in.
|
|
150
141
|
*/
|
|
151
|
-
getSubscriptions(
|
|
152
|
-
|
|
153
|
-
|
|
142
|
+
getSubscriptions() {
|
|
143
|
+
return __awaiter(this, arguments, void 0, function* (filter = true) {
|
|
144
|
+
var _a, _b;
|
|
154
145
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug('auth: Loading subscriptions...');
|
|
155
146
|
const startTime = Date.now();
|
|
156
147
|
const configuredTenantFilter = yield this.getTenantFilters();
|
|
@@ -211,8 +202,8 @@ class VSCodeAzureSubscriptionProvider extends vscode.Disposable {
|
|
|
211
202
|
* checks all accounts for a session.
|
|
212
203
|
*/
|
|
213
204
|
isSignedIn(tenantId, account) {
|
|
214
|
-
var _a, _b;
|
|
215
205
|
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
var _a, _b;
|
|
216
207
|
function silentlyCheckForSession(tenantId, account) {
|
|
217
208
|
return __awaiter(this, void 0, void 0, function* () {
|
|
218
209
|
return !!(yield (0, getSessionFromVSCode_1.getSessionFromVSCode)([], tenantId, { createIfNone: false, silent: true, account }));
|
|
@@ -248,8 +239,8 @@ class VSCodeAzureSubscriptionProvider extends vscode.Disposable {
|
|
|
248
239
|
* @returns True if the user is signed in, false otherwise.
|
|
249
240
|
*/
|
|
250
241
|
signIn(tenantId, account) {
|
|
251
|
-
var _a, _b;
|
|
252
242
|
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
+
var _a, _b;
|
|
253
244
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`auth: Signing in (account="${(_b = account === null || account === void 0 ? void 0 : account.label) !== null && _b !== void 0 ? _b : 'none'}") (tenantId="${tenantId !== null && tenantId !== void 0 ? tenantId : 'none'}")`);
|
|
254
245
|
const session = yield (0, getSessionFromVSCode_1.getSessionFromVSCode)([], tenantId, {
|
|
255
246
|
createIfNone: true,
|
|
@@ -309,8 +300,8 @@ class VSCodeAzureSubscriptionProvider extends vscode.Disposable {
|
|
|
309
300
|
* @returns The list of subscriptions for the tenant.
|
|
310
301
|
*/
|
|
311
302
|
getSubscriptionsForTenant(account, tenantId) {
|
|
312
|
-
var _a, e_3, _b, _c;
|
|
313
303
|
return __awaiter(this, void 0, void 0, function* () {
|
|
304
|
+
var _a, e_3, _b, _c;
|
|
314
305
|
// If the user is not signed in to this tenant or account, then return an empty list
|
|
315
306
|
// This is to prevent the NotSignedInError from being thrown in getSubscriptionClient
|
|
316
307
|
if (!(yield this.isSignedIn(tenantId, account))) {
|
|
@@ -320,27 +311,22 @@ class VSCodeAzureSubscriptionProvider extends vscode.Disposable {
|
|
|
320
311
|
const environment = (0, configuredAzureEnv_1.getConfiguredAzureEnv)();
|
|
321
312
|
const subscriptions = [];
|
|
322
313
|
try {
|
|
323
|
-
for (var _d = true, _e = __asyncValues(client.subscriptions.list()), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
|
|
314
|
+
for (var _d = true, _e = __asyncValues(client.subscriptions.list()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
324
315
|
_c = _f.value;
|
|
325
316
|
_d = false;
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
finally {
|
|
342
|
-
_d = true;
|
|
343
|
-
}
|
|
317
|
+
const subscription = _c;
|
|
318
|
+
subscriptions.push({
|
|
319
|
+
authentication: authentication,
|
|
320
|
+
environment: environment,
|
|
321
|
+
credential: credential,
|
|
322
|
+
isCustomCloud: environment.isCustomCloud,
|
|
323
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
324
|
+
name: subscription.displayName,
|
|
325
|
+
subscriptionId: subscription.subscriptionId,
|
|
326
|
+
tenantId: tenantId !== null && tenantId !== void 0 ? tenantId : subscription.tenantId,
|
|
327
|
+
/* eslint-enable @typescript-eslint/no-non-null-assertion */
|
|
328
|
+
account: account
|
|
329
|
+
});
|
|
344
330
|
}
|
|
345
331
|
}
|
|
346
332
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -384,7 +370,10 @@ class VSCodeAzureSubscriptionProvider extends vscode.Disposable {
|
|
|
384
370
|
authentication: {
|
|
385
371
|
getSession: () => session,
|
|
386
372
|
getSessionWithScopes: (scopes) => {
|
|
387
|
-
|
|
373
|
+
// in order to handle a challenge, we must enable createIfNone so
|
|
374
|
+
// that we can prompt the user to step-up their session with MFA
|
|
375
|
+
// otherwise, never prompt the user
|
|
376
|
+
return (0, getSessionFromVSCode_1.getSessionFromVSCode)(scopes, tenantId, Object.assign(Object.assign({}, ((0, isAuthenticationSessionRequest_1.isAuthenticationSessionRequest)(scopes) ? { createIfNone: true } : { silent: true })), { account }));
|
|
388
377
|
},
|
|
389
378
|
}
|
|
390
379
|
};
|
|
@@ -5,8 +5,9 @@ import * as vscode from "vscode";
|
|
|
5
5
|
* * Getting the list of scopes, adding the tenant id to the scope list if needed
|
|
6
6
|
*
|
|
7
7
|
* @param scopes - top-level resource scopes (e.g. http://management.azure.com, http://storage.azure.com) or .default scopes. All resources/scopes will be normalized to the `.default` scope for each resource.
|
|
8
|
+
* Use `vscode.AuthenticationSessionRequest` if you need to pass in a challenge (WWW-Authenticate header). Note: Use of `vscode.AuthenticationSessionRequest` requires VS Code 1.104 or newer.
|
|
8
9
|
* @param tenantId - (Optional) The tenant ID, will be added to the scopes
|
|
9
10
|
* @param options - see {@link vscode.AuthenticationGetSessionOptions}
|
|
10
11
|
* @returns An authentication session if available, or undefined if there are no sessions
|
|
11
12
|
*/
|
|
12
|
-
export declare function getSessionFromVSCode(scopes?: string | string[], tenantId?: string, options?: vscode.AuthenticationGetSessionOptions): Promise<vscode.AuthenticationSession | undefined>;
|
|
13
|
+
export declare function getSessionFromVSCode(scopes?: string | string[] | vscode.AuthenticationSessionRequest, tenantId?: string, options?: vscode.AuthenticationGetSessionOptions): Promise<vscode.AuthenticationSession | undefined>;
|
|
@@ -13,9 +13,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.getSessionFromVSCode =
|
|
16
|
+
exports.getSessionFromVSCode = getSessionFromVSCode;
|
|
17
17
|
const vscode = require("vscode");
|
|
18
18
|
const configuredAzureEnv_1 = require("./utils/configuredAzureEnv");
|
|
19
|
+
const isAuthenticationSessionRequest_1 = require("./utils/isAuthenticationSessionRequest");
|
|
19
20
|
function ensureEndingSlash(value) {
|
|
20
21
|
return value.endsWith('/') ? value : `${value}/`;
|
|
21
22
|
}
|
|
@@ -46,20 +47,30 @@ function getScopes(scopes, tenantId) {
|
|
|
46
47
|
}
|
|
47
48
|
return scopeArr;
|
|
48
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Deconstructs and rebuilds the scopes arg in order to use the above utils to modify the scopes array.
|
|
52
|
+
* And then returns the proper type to pass directly to vscode.authentication.getSession
|
|
53
|
+
*/
|
|
54
|
+
function formScopesArg(scopes, tenantId) {
|
|
55
|
+
var _a;
|
|
56
|
+
const initialScopeList = typeof scopes === 'string' ? [scopes] : Array.isArray(scopes) ? scopes : Array.from((_a = scopes === null || scopes === void 0 ? void 0 : scopes.scopes) !== null && _a !== void 0 ? _a : []);
|
|
57
|
+
const scopeList = getScopes(initialScopeList, tenantId);
|
|
58
|
+
return (0, isAuthenticationSessionRequest_1.isAuthenticationSessionRequest)(scopes) ? { scopes: scopeList, challenge: scopes.challenge } : scopeList;
|
|
59
|
+
}
|
|
49
60
|
/**
|
|
50
61
|
* Wraps {@link vscode.authentication.getSession} and handles:
|
|
51
62
|
* * Passing the configured auth provider id
|
|
52
63
|
* * Getting the list of scopes, adding the tenant id to the scope list if needed
|
|
53
64
|
*
|
|
54
65
|
* @param scopes - top-level resource scopes (e.g. http://management.azure.com, http://storage.azure.com) or .default scopes. All resources/scopes will be normalized to the `.default` scope for each resource.
|
|
66
|
+
* Use `vscode.AuthenticationSessionRequest` if you need to pass in a challenge (WWW-Authenticate header). Note: Use of `vscode.AuthenticationSessionRequest` requires VS Code 1.104 or newer.
|
|
55
67
|
* @param tenantId - (Optional) The tenant ID, will be added to the scopes
|
|
56
68
|
* @param options - see {@link vscode.AuthenticationGetSessionOptions}
|
|
57
69
|
* @returns An authentication session if available, or undefined if there are no sessions
|
|
58
70
|
*/
|
|
59
71
|
function getSessionFromVSCode(scopes, tenantId, options) {
|
|
60
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
return yield vscode.authentication.getSession((0, configuredAzureEnv_1.getConfiguredAuthProviderId)(),
|
|
73
|
+
return yield vscode.authentication.getSession((0, configuredAzureEnv_1.getConfiguredAuthProviderId)(), formScopesArg(scopes, tenantId), options);
|
|
62
74
|
});
|
|
63
75
|
}
|
|
64
|
-
exports.getSessionFromVSCode = getSessionFromVSCode;
|
|
65
76
|
//# sourceMappingURL=getSessionFromVSCode.js.map
|
|
@@ -13,7 +13,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.signInToTenant =
|
|
16
|
+
exports.signInToTenant = signInToTenant;
|
|
17
17
|
const vscode = require("vscode");
|
|
18
18
|
const getUnauthenticatedTenants_1 = require("./utils/getUnauthenticatedTenants");
|
|
19
19
|
/**
|
|
@@ -28,12 +28,11 @@ function signInToTenant(subscriptionProvider) {
|
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
exports.signInToTenant = signInToTenant;
|
|
32
31
|
function pickTenant(subscriptionProvider) {
|
|
33
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
33
|
const pick = yield vscode.window.showQuickPick(getPicks(subscriptionProvider), {
|
|
35
|
-
placeHolder: 'Select a Tenant (Directory) to Sign In To',
|
|
36
|
-
matchOnDescription: true,
|
|
34
|
+
placeHolder: 'Select a Tenant (Directory) to Sign In To', // TODO: localize
|
|
35
|
+
matchOnDescription: true, // allow searching by tenantId
|
|
37
36
|
ignoreFocusOut: true,
|
|
38
37
|
});
|
|
39
38
|
return pick === null || pick === void 0 ? void 0 : pick.tenant.tenantId;
|
|
@@ -13,7 +13,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.getConfiguredAzureEnv = getConfiguredAzureEnv;
|
|
17
|
+
exports.setConfiguredAzureEnv = setConfiguredAzureEnv;
|
|
18
|
+
exports.getConfiguredAuthProviderId = getConfiguredAuthProviderId;
|
|
17
19
|
const azureEnv = require("@azure/ms-rest-azure-env"); // This package is so small that it's not worth lazy loading
|
|
18
20
|
const vscode = require("vscode");
|
|
19
21
|
// These strings come from https://github.com/microsoft/vscode/blob/eac16e9b63a11885b538db3e0b533a02a2fb8143/extensions/microsoft-authentication/package.json#L40-L99
|
|
@@ -49,7 +51,6 @@ function getConfiguredAzureEnv() {
|
|
|
49
51
|
}
|
|
50
52
|
return Object.assign(Object.assign({}, azureEnv.Environment.get(azureEnv.Environment.AzureCloud.name)), { isCustomCloud: false });
|
|
51
53
|
}
|
|
52
|
-
exports.getConfiguredAzureEnv = getConfiguredAzureEnv;
|
|
53
54
|
/**
|
|
54
55
|
* Sets the configured Azure cloud.
|
|
55
56
|
*
|
|
@@ -58,8 +59,8 @@ exports.getConfiguredAzureEnv = getConfiguredAzureEnv;
|
|
|
58
59
|
*
|
|
59
60
|
* @param target (Optional) The configuration target to use, by default {@link vscode.ConfigurationTarget.Global}.
|
|
60
61
|
*/
|
|
61
|
-
function setConfiguredAzureEnv(
|
|
62
|
-
return __awaiter(this,
|
|
62
|
+
function setConfiguredAzureEnv(cloud_1) {
|
|
63
|
+
return __awaiter(this, arguments, void 0, function* (cloud, target = vscode.ConfigurationTarget.Global) {
|
|
63
64
|
const authProviderConfig = vscode.workspace.getConfiguration(CustomCloudConfigurationSection);
|
|
64
65
|
if (typeof cloud === 'undefined' || !cloud) {
|
|
65
66
|
// Use public cloud implicitly--set `environment` setting to `undefined`
|
|
@@ -83,7 +84,6 @@ function setConfiguredAzureEnv(cloud, target = vscode.ConfigurationTarget.Global
|
|
|
83
84
|
}
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
|
-
exports.setConfiguredAzureEnv = setConfiguredAzureEnv;
|
|
87
87
|
/**
|
|
88
88
|
* Gets the ID of the authentication provider configured to be used
|
|
89
89
|
* @returns The provider ID to use, either `'microsoft'` or `'microsoft-sovereign-cloud'`
|
|
@@ -91,5 +91,4 @@ exports.setConfiguredAzureEnv = setConfiguredAzureEnv;
|
|
|
91
91
|
function getConfiguredAuthProviderId() {
|
|
92
92
|
return getConfiguredAzureEnv().name === azureEnv.Environment.AzureCloud.name ? 'microsoft' : 'microsoft-sovereign-cloud';
|
|
93
93
|
}
|
|
94
|
-
exports.getConfiguredAuthProviderId = getConfiguredAuthProviderId;
|
|
95
94
|
//# sourceMappingURL=configuredAzureEnv.js.map
|
|
@@ -20,27 +20,22 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
20
20
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.getUnauthenticatedTenants =
|
|
23
|
+
exports.getUnauthenticatedTenants = getUnauthenticatedTenants;
|
|
24
24
|
/**
|
|
25
25
|
* @returns list of tenants that VS Code doesn't have sessions for
|
|
26
26
|
*/
|
|
27
27
|
function getUnauthenticatedTenants(subscriptionProvider) {
|
|
28
|
-
var _a, e_1, _b, _c;
|
|
29
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
var _a, e_1, _b, _c;
|
|
30
30
|
const tenants = yield subscriptionProvider.getTenants();
|
|
31
31
|
const unauthenticatedTenants = [];
|
|
32
32
|
try {
|
|
33
|
-
for (var _d = true, tenants_1 = __asyncValues(tenants), tenants_1_1; tenants_1_1 = yield tenants_1.next(), _a = tenants_1_1.done, !_a;) {
|
|
33
|
+
for (var _d = true, tenants_1 = __asyncValues(tenants), tenants_1_1; tenants_1_1 = yield tenants_1.next(), _a = tenants_1_1.done, !_a; _d = true) {
|
|
34
34
|
_c = tenants_1_1.value;
|
|
35
35
|
_d = false;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
unauthenticatedTenants.push(tenant);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
finally {
|
|
43
|
-
_d = true;
|
|
36
|
+
const tenant = _c;
|
|
37
|
+
if (!(yield subscriptionProvider.isSignedIn(tenant.tenantId, tenant.account))) {
|
|
38
|
+
unauthenticatedTenants.push(tenant);
|
|
44
39
|
}
|
|
45
40
|
}
|
|
46
41
|
}
|
|
@@ -54,5 +49,4 @@ function getUnauthenticatedTenants(subscriptionProvider) {
|
|
|
54
49
|
return unauthenticatedTenants;
|
|
55
50
|
});
|
|
56
51
|
}
|
|
57
|
-
exports.getUnauthenticatedTenants = getUnauthenticatedTenants;
|
|
58
52
|
//# sourceMappingURL=getUnauthenticatedTenants.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.isAuthenticationSessionRequest = isAuthenticationSessionRequest;
|
|
8
|
+
function isAuthenticationSessionRequest(scopes) {
|
|
9
|
+
return !!(scopes && typeof scopes === 'object' && 'challenge' in scopes);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=isAuthenticationSessionRequest.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/vscode-azext-azureauth",
|
|
3
3
|
"author": "Microsoft Corporation",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.2.0",
|
|
5
5
|
"description": "Azure authentication helpers for Visual Studio Code",
|
|
6
6
|
"tags": [
|
|
7
7
|
"azure",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"lint": "eslint --ext .ts .",
|
|
29
29
|
"lint-fix": "eslint --ext .ts . --fix",
|
|
30
30
|
"test": "node ./out/test/runTest.js",
|
|
31
|
-
"package": "npm pack"
|
|
31
|
+
"package": "npm pack",
|
|
32
|
+
"l10n": "npx @vscode/l10n-dev export --outDir ./l10n ./src"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@azure/core-auth": "^1.4.0",
|
|
@@ -41,16 +42,16 @@
|
|
|
41
42
|
"@types/node-fetch": "2.6.7",
|
|
42
43
|
"@types/semver": "^7.3.9",
|
|
43
44
|
"@types/uuid": "^9.0.1",
|
|
44
|
-
"@types/vscode": "1.
|
|
45
|
+
"@types/vscode": "^1.94.0",
|
|
45
46
|
"@typescript-eslint/eslint-plugin": "^5.53.0",
|
|
46
47
|
"@vscode/test-electron": "^2.3.8",
|
|
47
48
|
"eslint": "^8.34.0",
|
|
48
49
|
"eslint-plugin-import": "^2.22.1",
|
|
49
50
|
"glob": "^7.1.6",
|
|
50
|
-
"mocha": "^
|
|
51
|
+
"mocha": "^11.1.0",
|
|
51
52
|
"mocha-junit-reporter": "^2.0.2",
|
|
52
53
|
"mocha-multi-reporters": "^1.1.7",
|
|
53
|
-
"typescript": "^
|
|
54
|
+
"typescript": "^5.8.2"
|
|
54
55
|
},
|
|
55
56
|
"dependencies": {
|
|
56
57
|
"@azure/arm-resources-subscriptions": "^2.1.0",
|