Skip to content

Commit 84a6c22

Browse files
committed
WIP
1 parent cfa4448 commit 84a6c22

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

package-lock.json

Lines changed: 4 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-objectscript",
33
"displayName": "InterSystems ObjectScript",
44
"description": "InterSystems ObjectScript language support for Visual Studio Code",
5-
"version": "1.1.2-SNAPSHOT",
5+
"version": "1.1.2-SNAPSHOT-authentication-provider-20211126",
66
"icon": "images/logo.png",
77
"aiKey": "9cd75d51-697c-406c-a929-2bcf46e97c64",
88
"categories": [
@@ -47,9 +47,8 @@
4747
}
4848
],
4949
"engines": {
50-
"vscode": "^1.43.0"
50+
"vscode": "^1.63.0"
5151
},
52-
"enableProposedApi": true,
5352
"enabledApiProposals": [
5453
"fileSearchProvider",
5554
"textSearchProvider"
@@ -1127,7 +1126,6 @@
11271126
"@types/mocha": "^7.0.2",
11281127
"@types/node": "^14.0.14",
11291128
"@types/request": "^2.48.5",
1130-
"@types/vscode": "^1.43.0",
11311129
"@types/ws": "^7.2.5",
11321130
"@types/xmldom": "^0.1.29",
11331131
"@typescript-eslint/eslint-plugin": "^4.32.0",

src/extension.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,30 @@ export async function resolveConnectionSpec(serverName: string): Promise<void> {
181181
if (serverName && serverName !== "" && !resolvedConnSpecs.has(serverName)) {
182182
const connSpec = await serverManagerApi.getServerSpec(serverName);
183183
if (connSpec) {
184+
await resolvePassword(connSpec);
184185
resolvedConnSpecs.set(serverName, connSpec);
185186
}
186187
}
187188
}
188189
}
189190

191+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
192+
export async function resolvePassword(serverSpec): Promise<void> {
193+
const AUTHENTICATION_PROVIDER = "intersystems-server-credentials";
194+
// This arises if setting says to use authentication provider
195+
if (typeof serverSpec.password === "undefined") {
196+
const scopes = [serverSpec.name, serverSpec.username || ""];
197+
let session = await vscode.authentication.getSession(AUTHENTICATION_PROVIDER, scopes, { silent: true });
198+
if (!session) {
199+
session = await vscode.authentication.getSession(AUTHENTICATION_PROVIDER, scopes, { createIfNone: true });
200+
}
201+
if (session) {
202+
serverSpec.username = session.scopes[1];
203+
serverSpec.password = session.accessToken;
204+
}
205+
}
206+
}
207+
190208
// Accessor for the cache of resolved connection specs
191209
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
192210
export function getResolvedConnectionSpec(key: string, dflt: any): any {

0 commit comments

Comments
 (0)