Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into alex/sign-with-msbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
alexweininger committed Aug 23, 2024
2 parents 205aa2e + 5fc8cb4 commit ce8c8b0
Show file tree
Hide file tree
Showing 37 changed files with 417 additions and 188 deletions.
44 changes: 22 additions & 22 deletions appservice/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 36 additions & 36 deletions appsettings/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions auth/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion auth/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@microsoft/vscode-azext-azureauth",
"author": "Microsoft Corporation",
"version": "2.4.1",
"version": "2.5.0",
"description": "Azure authentication helpers for Visual Studio Code",
"tags": [
"azure",
Expand Down
9 changes: 8 additions & 1 deletion auth/src/AzureAuthentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ import type * as vscode from 'vscode';
* Represents a means of obtaining authentication data for an Azure subscription.
*/
export interface AzureAuthentication {
/**
* Gets a VS Code authentication session for an Azure subscription.
* Always uses the default scope, `https://management.azure.com/.default/` and respects `microsoft-sovereign-cloud.environment` setting.
*
* @returns A VS Code authentication session or undefined, if none could be obtained.
*/
getSession(): vscode.ProviderResult<vscode.AuthenticationSession>;
/**
* Gets a VS Code authentication session for an Azure subscription.
*
* @param scopes - The scopes for which the authentication is needed.
*
* @returns A VS Code authentication session or undefined, if none could be obtained.
*/
getSession(scopes?: string[]): vscode.ProviderResult<vscode.AuthenticationSession>;
getSessionWithScopes(scopes: string[]): vscode.ProviderResult<vscode.AuthenticationSession>;
}
29 changes: 15 additions & 14 deletions auth/src/AzureDevOpsSubscriptionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,26 @@ export class AzureDevOpsSubscriptionProvider implements AzureSubscriptionProvide
}

const accessToken = (await this._tokenCredential?.getToken("https://management.azure.com/.default"))?.token || '';
const getSession = () => {
return {
accessToken,
id: this._tokenCredential?.tenantId || '',
account: {
id: this._tokenCredential?.tenantId || '',
label: this._tokenCredential?.tenantId || '',
},
tenantId: this._tokenCredential?.tenantId || '',
scopes: scopes || [],
};
};
return {
client: new armSubs.SubscriptionClient(this._tokenCredential,),
credential: this._tokenCredential,
authentication: {
getSession: (_scopes: string[] | undefined) => {
return {
accessToken,
id: this._tokenCredential?.tenantId || '',
account: {
id: this._tokenCredential?.tenantId || '',
label: this._tokenCredential?.tenantId || '',
},
tenantId: this._tokenCredential?.tenantId || '',
scopes: scopes || [],
};

}
getSession,
getSessionWithScopes: getSession,
}
};
}
}

public onDidSignIn: Event<void> = () => { return new Disposable(() => { /*empty*/ }) };
Expand Down
5 changes: 4 additions & 1 deletion auth/src/VSCodeAzureSubscriptionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ export class VSCodeAzureSubscriptionProvider extends vscode.Disposable implement
client: new armSubs.SubscriptionClient(credential, { endpoint }),
credential: credential,
authentication: {
getSession: () => session
getSession: () => session,
getSessionWithScopes: (scopes) => {
return getSessionFromVSCode(scopes, tenantId, { createIfNone: false, silent: true })
},
}
};
}
Expand Down
6 changes: 5 additions & 1 deletion azure-pipelines/1esmain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ parameters:
- name: useAzureFederatedCredentials
type: boolean
default: false
- name: additionalSetupSteps
type: stepList
default: []

# `resources` specifies the location of templates to pick up, use it to get 1ES templates
resources:
Expand All @@ -31,4 +34,5 @@ extends:
# Execute stages from the AzExt stages template
- template: ./1esstages.yml
parameters:
useAzureFederatedCredentials: ${{ parameters.useAzureFederatedCredentials }}
useAzureFederatedCredentials: ${{ parameters.useAzureFederatedCredentials }}
additionalSetupSteps: ${{ parameters.additionalSetupSteps }}
Loading

0 comments on commit ce8c8b0

Please sign in to comment.