Skip to content

Commit

Permalink
Ability to use MSAL in the Desktop (microsoft#225272)
Browse files Browse the repository at this point in the history
* Ability to use MSAL in the Desktop

* add comment about MSAL workaround
  • Loading branch information
TylerLeonhardt authored Aug 9, 2024
1 parent 2b8f4b8 commit 70d2774
Show file tree
Hide file tree
Showing 18 changed files with 1,929 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ module.exports = withBrowserDefaults({
resolve: {
alias: {
'./node/authServer': path.resolve(__dirname, 'src/browser/authServer'),
'./node/buffer': path.resolve(__dirname, 'src/browser/buffer')
'./node/buffer': path.resolve(__dirname, 'src/browser/buffer'),
'./node/authProvider': path.resolve(__dirname, 'src/browser/authProvider'),
}
}
});
11 changes: 11 additions & 0 deletions extensions/microsoft-authentication/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@
]
}
}
},
{
"title": "Microsoft",
"properties": {
"microsoft.useMsal": {
"type": "boolean",
"default": false,
"description": "%useMsal.description%"
}
}
}
]
},
Expand All @@ -117,6 +127,7 @@
},
"dependencies": {
"@azure/ms-rest-azure-env": "^2.0.0",
"@azure/msal-node": "^2.12.0",
"@vscode/extension-telemetry": "^0.9.0"
},
"repository": {
Expand Down
1 change: 1 addition & 0 deletions extensions/microsoft-authentication/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "Microsoft authentication provider",
"signIn": "Sign In",
"signOut": "Sign Out",
"useMsal.description": "Use the Microsoft Authentication Library (MSAL) to sign in with a Microsoft account.",
"microsoft-sovereign-cloud.environment.description": {
"message": "The Sovereign Cloud to use for authentication. If you select `custom`, you must also set the `#microsoft-sovereign-cloud.customEnvironment#` setting.",
"comment": [
Expand Down
9 changes: 8 additions & 1 deletion extensions/microsoft-authentication/src/UriEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
import * as vscode from 'vscode';

export class UriEventHandler extends vscode.EventEmitter<vscode.Uri> implements vscode.UriHandler {
public handleUri(uri: vscode.Uri) {
private _disposable = vscode.window.registerUriHandler(this);

handleUri(uri: vscode.Uri) {
this.fire(uri);
}

override dispose(): void {
super.dispose();
this._disposable.dispose();
}
}
29 changes: 29 additions & 0 deletions extensions/microsoft-authentication/src/browser/authProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AuthenticationProvider, AuthenticationProviderAuthenticationSessionsChangeEvent, AuthenticationSession, EventEmitter } from 'vscode';

export class MsalAuthProvider implements AuthenticationProvider {
private _onDidChangeSessions = new EventEmitter<AuthenticationProviderAuthenticationSessionsChangeEvent>();
onDidChangeSessions = this._onDidChangeSessions.event;

initialize(): Thenable<void> {
throw new Error('Method not implemented.');
}

getSessions(): Thenable<AuthenticationSession[]> {
throw new Error('Method not implemented.');
}
createSession(): Thenable<AuthenticationSession> {
throw new Error('Method not implemented.');
}
removeSession(): Thenable<void> {
throw new Error('Method not implemented.');
}

dispose() {
this._onDidChangeSessions.dispose();
}
}
Loading

0 comments on commit 70d2774

Please sign in to comment.