@microsoft/vscode-azext-azureauth 4.0.3 → 4.1.1
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/AzureFederatedCredentialsGuide.md +174 -174
- package/CHANGELOG.md +98 -90
- package/LICENSE.md +21 -21
- package/README.md +156 -152
- package/out/src/AzureAuthentication.d.ts +21 -21
- package/out/src/AzureAuthentication.js +6 -6
- package/out/src/AzureDevOpsSubscriptionProvider.d.ts +68 -68
- package/out/src/AzureDevOpsSubscriptionProvider.js +256 -256
- package/out/src/AzureSubscription.d.ts +49 -49
- package/out/src/AzureSubscription.js +6 -6
- package/out/src/AzureSubscriptionProvider.d.ts +82 -63
- package/out/src/AzureSubscriptionProvider.js +6 -6
- package/out/src/AzureTenant.d.ts +5 -5
- package/out/src/AzureTenant.js +6 -6
- package/out/src/NotSignedInError.d.ts +15 -15
- package/out/src/NotSignedInError.js +29 -29
- package/out/src/VSCodeAzureSubscriptionProvider.d.ts +117 -113
- package/out/src/VSCodeAzureSubscriptionProvider.js +394 -386
- package/out/src/getSessionFromVSCode.d.ts +12 -12
- package/out/src/getSessionFromVSCode.js +64 -64
- package/out/src/index.d.ts +10 -10
- package/out/src/index.js +30 -30
- package/out/src/signInToTenant.d.ts +6 -6
- package/out/src/signInToTenant.js +64 -64
- package/out/src/utils/configuredAzureEnv.d.ts +24 -24
- package/out/src/utils/configuredAzureEnv.js +94 -94
- package/out/src/utils/getUnauthenticatedTenants.d.ts +6 -6
- package/out/src/utils/getUnauthenticatedTenants.js +57 -57
- package/package.json +61 -61
package/README.md
CHANGED
|
@@ -1,152 +1,156 @@
|
|
|
1
|
-
# VSCode Azure SDK for Node.js - Azure Auth
|
|
2
|
-
|
|
3
|
-
[](https://dev.azure.com/ms-azuretools/AzCode/_build/latest?definitionId=17)
|
|
4
|
-
|
|
5
|
-
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
|
-
|
|
7
|
-
## Azure Subscription Provider
|
|
8
|
-
|
|
9
|
-
The `AzureSubscriptionProvider` interface describes the functions of this package.
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
/**
|
|
13
|
-
* An interface for obtaining Azure subscription information
|
|
14
|
-
*/
|
|
15
|
-
export interface AzureSubscriptionProvider {
|
|
16
|
-
/**
|
|
17
|
-
* Gets a list of tenants available to the user.
|
|
18
|
-
* Use {@link isSignedIn} to check if the user is signed in to a particular tenant.
|
|
19
|
-
*
|
|
20
|
-
* @returns A list of tenants.
|
|
21
|
-
*/
|
|
22
|
-
getTenants(): Promise<TenantIdDescription[]>;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Gets a list of Azure subscriptions available to the user.
|
|
26
|
-
*
|
|
27
|
-
* @param filter - Whether to filter the list returned
|
|
28
|
-
* by `getTenantFilters()` and `getSubscriptionFilters()`.
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
1
|
+
# VSCode Azure SDK for Node.js - Azure Auth
|
|
2
|
+
|
|
3
|
+
[](https://dev.azure.com/ms-azuretools/AzCode/_build/latest?definitionId=17)
|
|
4
|
+
|
|
5
|
+
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
|
+
|
|
7
|
+
## Azure Subscription Provider
|
|
8
|
+
|
|
9
|
+
The `AzureSubscriptionProvider` interface describes the functions of this package.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
/**
|
|
13
|
+
* An interface for obtaining Azure subscription information
|
|
14
|
+
*/
|
|
15
|
+
export interface AzureSubscriptionProvider {
|
|
16
|
+
/**
|
|
17
|
+
* Gets a list of tenants available to the user.
|
|
18
|
+
* Use {@link isSignedIn} to check if the user is signed in to a particular tenant.
|
|
19
|
+
*
|
|
20
|
+
* @returns A list of tenants.
|
|
21
|
+
*/
|
|
22
|
+
getTenants(): Promise<TenantIdDescription[]>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Gets a list of Azure subscriptions available to the user.
|
|
26
|
+
*
|
|
27
|
+
* @param filter - Whether to filter the list returned. When:
|
|
28
|
+
* - `true`: according to the list returned by `getTenantFilters()` and `getSubscriptionFilters()`.
|
|
29
|
+
* - `false`: return all subscriptions.
|
|
30
|
+
* - `GetSubscriptionsFilter`: according to the values in the filter.
|
|
31
|
+
*
|
|
32
|
+
* Optional, default true.
|
|
33
|
+
*
|
|
34
|
+
* @returns A list of Azure subscriptions.
|
|
35
|
+
*
|
|
36
|
+
* @throws A {@link NotSignedInError} If the user is not signed in to Azure.
|
|
37
|
+
* Use {@link isSignedIn} and/or {@link signIn} before this method to ensure
|
|
38
|
+
* the user is signed in.
|
|
39
|
+
*/
|
|
40
|
+
getSubscriptions(filter: boolean): Promise<AzureSubscription[]>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Checks to see if a user is signed in.
|
|
44
|
+
*
|
|
45
|
+
* @param tenantId (Optional) Provide to check if a user is signed in to a specific tenant.
|
|
46
|
+
*
|
|
47
|
+
* @returns True if the user is signed in, false otherwise.
|
|
48
|
+
*/
|
|
49
|
+
isSignedIn(tenantId?: string): Promise<boolean>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Asks the user to sign in or pick an account to use.
|
|
53
|
+
*
|
|
54
|
+
* @param tenantId (Optional) Provide to sign in to a specific tenant.
|
|
55
|
+
*
|
|
56
|
+
* @returns True if the user is signed in, false otherwise.
|
|
57
|
+
*/
|
|
58
|
+
signIn(tenantId?: string): Promise<boolean>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* An event that is fired when the user signs in. Debounced to fire at most once every 5 seconds.
|
|
62
|
+
*/
|
|
63
|
+
onDidSignIn: vscode.Event<void>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Signs the user out
|
|
67
|
+
*
|
|
68
|
+
* @deprecated Not currently supported by VS Code auth providers
|
|
69
|
+
*
|
|
70
|
+
* @throws Throws an {@link Error} every time
|
|
71
|
+
*/
|
|
72
|
+
signOut(): Promise<void>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* An event that is fired when the user signs out. Debounced to fire at most once every 5 seconds.
|
|
76
|
+
*/
|
|
77
|
+
onDidSignOut: vscode.Event<void>;
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
If the caller calls `getSubscriptions()` when the user is not signed in, a `NotSignedInError` will be thrown. You can check to see if a caught error is an instance of this error with `isNotSignedInError()`.
|
|
82
|
+
|
|
83
|
+
## Azure Cloud Configuration
|
|
84
|
+
Two methods are available for controlling the VSCode settings that determine what cloud is connected to when enumerating subscriptions.
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
/**
|
|
88
|
+
* Gets the configured Azure environment.
|
|
89
|
+
*
|
|
90
|
+
* @returns The configured Azure environment from the `microsoft-sovereign-cloud.endpoint` setting.
|
|
91
|
+
*/
|
|
92
|
+
export declare function getConfiguredAzureEnv(): azureEnv.Environment & {
|
|
93
|
+
isCustomCloud: boolean;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Sets the configured Azure cloud.
|
|
98
|
+
*
|
|
99
|
+
* @param cloud Use `'AzureCloud'` for public Azure cloud, `'AzureChinaCloud'` for Azure China, or `'AzureUSGovernment'` for Azure US Government.
|
|
100
|
+
* These are the same values as the cloud names in `@azure/ms-rest-azure-env`. For a custom cloud, use an instance of the `@azure/ms-rest-azure-env` `EnvironmentParameters`.
|
|
101
|
+
*
|
|
102
|
+
* @param target (Optional) The configuration target to use, by default {@link vscode.ConfigurationTarget.Global}.
|
|
103
|
+
*/
|
|
104
|
+
export declare function setConfiguredAzureEnv(cloud: string | azureEnv.EnvironmentParameters, target?: vscode.ConfigurationTarget): Promise<void>;
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Azure DevOps Subscription Provider
|
|
108
|
+
|
|
109
|
+
The auth package also exports `AzureDevOpsSubscriptionProvider`, a class which implements the `AzureSubscriptionProvider` interface, which authenticates via
|
|
110
|
+
a federated Azure DevOps service connection, using [workflow identity federation](https://learn.microsoft.com/entra/workload-id/workload-identity-federation).
|
|
111
|
+
|
|
112
|
+
This provider only works when running in the context of an Azure DevOps pipeline. It can be used to run end-to-end tests that require authentication to Azure,
|
|
113
|
+
without having to manage any secrets, passwords or connection strings.
|
|
114
|
+
|
|
115
|
+
The constructor expects an initializer object with three values set to identify your ADO service connection to be used for authentication.
|
|
116
|
+
These are:
|
|
117
|
+
|
|
118
|
+
- `serviceConnectionId`: The resource ID of your service connection, which can be found on the `resourceId` field of the URL at the address bar, when viewing the service connection in the Azure DevOps portal
|
|
119
|
+
- `domain`: The `Tenant ID` field of the service connection properties, which can be accessed by clicking "Edit" on the service connection page
|
|
120
|
+
- `clientId`: The `Service Principal Id` field of the service connection properties, which can be accessed by clicking "Edit" on the service connection page
|
|
121
|
+
|
|
122
|
+
Here is an example code of how you might use `AzureDevOpsSubscriptionProvider`:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import { AzureDevOpsSubscriptionProviderInitializer, AzureDevOpsSubscriptionProvider } from "@microsoft/vscode-azext-azureauth";
|
|
126
|
+
|
|
127
|
+
const initializer: AzureDevOpsSubscriptionProviderInitializer = {
|
|
128
|
+
serviceConnectionId: "<REPLACE_WITH_SERVICE_CONNECTION_ID>",
|
|
129
|
+
domain: "<REPLACE_WITH_DOMAIN>",
|
|
130
|
+
clientId: "<REPLACE_WITH_CLIENT_ID>",
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const subscriptionProvider = new AzureDevOpsSubscriptionProvider(initializer);
|
|
134
|
+
|
|
135
|
+
const signedIn = await subscriptionProvider.signIn();
|
|
136
|
+
if (!signedIn) {
|
|
137
|
+
throw new Error("Couldn't sign in");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const subscriptions = await subscriptionProvider.getSubscriptions();
|
|
141
|
+
|
|
142
|
+
// logic on the subscriptions object
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
For more detailed steps on how to setup your Azure environment to use workflow identity federation and use this `AzureDevOpsSubscriptionProvider` object effectively,
|
|
146
|
+
as well as the values needed to pass to `new AzureDevOpsSubscriptionProvider()`, please navigate to the workflow identity federation [guide](AzureFederatedCredentialsGuide.md).
|
|
147
|
+
|
|
148
|
+
## Logs
|
|
149
|
+
|
|
150
|
+
View the Microsoft Authentication extension logs by running the `Developer: Show Logs...` command from the VS Code command palette.
|
|
151
|
+
|
|
152
|
+
Change the log level by running the `Developer: Set Log Level...` command from the VS Code command palette. Select `Microsoft Authentication` from the list of loggers and then select the desired log level.
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
[MIT](LICENSE.md)
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type * as vscode from 'vscode';
|
|
2
|
-
/**
|
|
3
|
-
* Represents a means of obtaining authentication data for an Azure subscription.
|
|
4
|
-
*/
|
|
5
|
-
export interface AzureAuthentication {
|
|
6
|
-
/**
|
|
7
|
-
* Gets a VS Code authentication session for an Azure subscription.
|
|
8
|
-
* Always uses the default scope, `https://management.azure.com/.default/` and respects `microsoft-sovereign-cloud.environment` setting.
|
|
9
|
-
*
|
|
10
|
-
* @returns A VS Code authentication session or undefined, if none could be obtained.
|
|
11
|
-
*/
|
|
12
|
-
getSession(): vscode.ProviderResult<vscode.AuthenticationSession>;
|
|
13
|
-
/**
|
|
14
|
-
* Gets a VS Code authentication session for an Azure subscription.
|
|
15
|
-
*
|
|
16
|
-
* @param scopes - The scopes for which the authentication is needed.
|
|
17
|
-
*
|
|
18
|
-
* @returns A VS Code authentication session or undefined, if none could be obtained.
|
|
19
|
-
*/
|
|
20
|
-
getSessionWithScopes(scopes: string[]): vscode.ProviderResult<vscode.AuthenticationSession>;
|
|
21
|
-
}
|
|
1
|
+
import type * as vscode from 'vscode';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a means of obtaining authentication data for an Azure subscription.
|
|
4
|
+
*/
|
|
5
|
+
export interface AzureAuthentication {
|
|
6
|
+
/**
|
|
7
|
+
* Gets a VS Code authentication session for an Azure subscription.
|
|
8
|
+
* Always uses the default scope, `https://management.azure.com/.default/` and respects `microsoft-sovereign-cloud.environment` setting.
|
|
9
|
+
*
|
|
10
|
+
* @returns A VS Code authentication session or undefined, if none could be obtained.
|
|
11
|
+
*/
|
|
12
|
+
getSession(): vscode.ProviderResult<vscode.AuthenticationSession>;
|
|
13
|
+
/**
|
|
14
|
+
* Gets a VS Code authentication session for an Azure subscription.
|
|
15
|
+
*
|
|
16
|
+
* @param scopes - The scopes for which the authentication is needed.
|
|
17
|
+
*
|
|
18
|
+
* @returns A VS Code authentication session or undefined, if none could be obtained.
|
|
19
|
+
*/
|
|
20
|
+
getSessionWithScopes(scopes: string[]): vscode.ProviderResult<vscode.AuthenticationSession>;
|
|
21
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
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 });
|
|
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
7
|
//# sourceMappingURL=AzureAuthentication.js.map
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import { Event } from 'vscode';
|
|
2
|
-
import { AzureSubscription } from './AzureSubscription';
|
|
3
|
-
import { AzureSubscriptionProvider } from './AzureSubscriptionProvider';
|
|
4
|
-
import { AzureTenant } from './AzureTenant';
|
|
5
|
-
export interface AzureDevOpsSubscriptionProviderInitializer {
|
|
6
|
-
/**
|
|
7
|
-
* The resource ID of the Azure DevOps federated service connection,
|
|
8
|
-
* which can be found on the `resourceId` field of the URL at the address bar
|
|
9
|
-
* when viewing the service connection in the Azure DevOps portal
|
|
10
|
-
*/
|
|
11
|
-
serviceConnectionId: string;
|
|
12
|
-
/**
|
|
13
|
-
* The `Tenant ID` field of the service connection properties
|
|
14
|
-
*/
|
|
15
|
-
domain: string;
|
|
16
|
-
/**
|
|
17
|
-
* The `Service Principal Id` field of the service connection properties
|
|
18
|
-
*/
|
|
19
|
-
clientId: string;
|
|
20
|
-
}
|
|
21
|
-
export declare function createAzureDevOpsSubscriptionProviderFactory(initializer: AzureDevOpsSubscriptionProviderInitializer): () => Promise<AzureDevOpsSubscriptionProvider>;
|
|
22
|
-
/**
|
|
23
|
-
* AzureSubscriptionProvider implemented to authenticate via federated DevOps service connection, using workflow identity federation
|
|
24
|
-
* To learn how to configure your DevOps environment to use this provider, refer to the README.md
|
|
25
|
-
* NOTE: This provider is only available when running in an Azure DevOps pipeline
|
|
26
|
-
* Reference: https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation
|
|
27
|
-
*/
|
|
28
|
-
export declare class AzureDevOpsSubscriptionProvider implements AzureSubscriptionProvider {
|
|
29
|
-
private _tokenCredential;
|
|
30
|
-
/**
|
|
31
|
-
* The resource ID of the Azure DevOps federated service connection,
|
|
32
|
-
* which can be found on the `resourceId` field of the URL at the address bar
|
|
33
|
-
* when viewing the service connection in the Azure DevOps portal
|
|
34
|
-
*/
|
|
35
|
-
private _SERVICE_CONNECTION_ID;
|
|
36
|
-
/**
|
|
37
|
-
* The `Tenant ID` field of the service connection properties
|
|
38
|
-
*/
|
|
39
|
-
private _DOMAIN;
|
|
40
|
-
/**
|
|
41
|
-
* The `Service Principal Id` field of the service connection properties
|
|
42
|
-
*/
|
|
43
|
-
private _CLIENT_ID;
|
|
44
|
-
constructor({ serviceConnectionId, domain, clientId }: AzureDevOpsSubscriptionProviderInitializer);
|
|
45
|
-
getSubscriptions(_filter: boolean): Promise<AzureSubscription[]>;
|
|
46
|
-
isSignedIn(): Promise<boolean>;
|
|
47
|
-
signIn(): Promise<boolean>;
|
|
48
|
-
signOut(): Promise<void>;
|
|
49
|
-
getTenants(): Promise<AzureTenant[]>;
|
|
50
|
-
/**
|
|
51
|
-
* Gets the subscriptions for a given tenant.
|
|
52
|
-
*
|
|
53
|
-
* @param tenantId The tenant ID to get subscriptions for.
|
|
54
|
-
*
|
|
55
|
-
* @returns The list of subscriptions for the tenant.
|
|
56
|
-
*/
|
|
57
|
-
private getSubscriptionsForTenant;
|
|
58
|
-
/**
|
|
59
|
-
* Gets a fully-configured subscription client for a given tenant ID
|
|
60
|
-
*
|
|
61
|
-
* @param tenantId (Optional) The tenant ID to get a client for
|
|
62
|
-
*
|
|
63
|
-
* @returns A client, the credential used by the client, and the authentication function
|
|
64
|
-
*/
|
|
65
|
-
private getSubscriptionClient;
|
|
66
|
-
onDidSignIn: Event<void>;
|
|
67
|
-
onDidSignOut: Event<void>;
|
|
68
|
-
}
|
|
1
|
+
import { Event } from 'vscode';
|
|
2
|
+
import { AzureSubscription } from './AzureSubscription';
|
|
3
|
+
import { AzureSubscriptionProvider, GetSubscriptionsFilter } from './AzureSubscriptionProvider';
|
|
4
|
+
import { AzureTenant } from './AzureTenant';
|
|
5
|
+
export interface AzureDevOpsSubscriptionProviderInitializer {
|
|
6
|
+
/**
|
|
7
|
+
* The resource ID of the Azure DevOps federated service connection,
|
|
8
|
+
* which can be found on the `resourceId` field of the URL at the address bar
|
|
9
|
+
* when viewing the service connection in the Azure DevOps portal
|
|
10
|
+
*/
|
|
11
|
+
serviceConnectionId: string;
|
|
12
|
+
/**
|
|
13
|
+
* The `Tenant ID` field of the service connection properties
|
|
14
|
+
*/
|
|
15
|
+
domain: string;
|
|
16
|
+
/**
|
|
17
|
+
* The `Service Principal Id` field of the service connection properties
|
|
18
|
+
*/
|
|
19
|
+
clientId: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function createAzureDevOpsSubscriptionProviderFactory(initializer: AzureDevOpsSubscriptionProviderInitializer): () => Promise<AzureDevOpsSubscriptionProvider>;
|
|
22
|
+
/**
|
|
23
|
+
* AzureSubscriptionProvider implemented to authenticate via federated DevOps service connection, using workflow identity federation
|
|
24
|
+
* To learn how to configure your DevOps environment to use this provider, refer to the README.md
|
|
25
|
+
* NOTE: This provider is only available when running in an Azure DevOps pipeline
|
|
26
|
+
* Reference: https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation
|
|
27
|
+
*/
|
|
28
|
+
export declare class AzureDevOpsSubscriptionProvider implements AzureSubscriptionProvider {
|
|
29
|
+
private _tokenCredential;
|
|
30
|
+
/**
|
|
31
|
+
* The resource ID of the Azure DevOps federated service connection,
|
|
32
|
+
* which can be found on the `resourceId` field of the URL at the address bar
|
|
33
|
+
* when viewing the service connection in the Azure DevOps portal
|
|
34
|
+
*/
|
|
35
|
+
private _SERVICE_CONNECTION_ID;
|
|
36
|
+
/**
|
|
37
|
+
* The `Tenant ID` field of the service connection properties
|
|
38
|
+
*/
|
|
39
|
+
private _DOMAIN;
|
|
40
|
+
/**
|
|
41
|
+
* The `Service Principal Id` field of the service connection properties
|
|
42
|
+
*/
|
|
43
|
+
private _CLIENT_ID;
|
|
44
|
+
constructor({ serviceConnectionId, domain, clientId }: AzureDevOpsSubscriptionProviderInitializer);
|
|
45
|
+
getSubscriptions(_filter: boolean | GetSubscriptionsFilter): Promise<AzureSubscription[]>;
|
|
46
|
+
isSignedIn(): Promise<boolean>;
|
|
47
|
+
signIn(): Promise<boolean>;
|
|
48
|
+
signOut(): Promise<void>;
|
|
49
|
+
getTenants(): Promise<AzureTenant[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the subscriptions for a given tenant.
|
|
52
|
+
*
|
|
53
|
+
* @param tenantId The tenant ID to get subscriptions for.
|
|
54
|
+
*
|
|
55
|
+
* @returns The list of subscriptions for the tenant.
|
|
56
|
+
*/
|
|
57
|
+
private getSubscriptionsForTenant;
|
|
58
|
+
/**
|
|
59
|
+
* Gets a fully-configured subscription client for a given tenant ID
|
|
60
|
+
*
|
|
61
|
+
* @param tenantId (Optional) The tenant ID to get a client for
|
|
62
|
+
*
|
|
63
|
+
* @returns A client, the credential used by the client, and the authentication function
|
|
64
|
+
*/
|
|
65
|
+
private getSubscriptionClient;
|
|
66
|
+
onDidSignIn: Event<void>;
|
|
67
|
+
onDidSignOut: Event<void>;
|
|
68
|
+
}
|