Skip to content

Commit c8cb9fa

Browse files
committed
WIP
1 parent c6d7a8a commit c8cb9fa

File tree

7 files changed

+15287
-414
lines changed

7 files changed

+15287
-414
lines changed

package.json

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "servermanager",
33
"displayName": "InterSystems Server Manager",
4-
"version": "3.0.0-SNAPSHOT",
4+
"version": "3.0.0-SNAPSHOT-authentication-provider-20211126",
55
"publisher": "intersystems-community",
66
"description": "Define connections to InterSystems servers. Browse and manage those servers.",
77
"repository": {
@@ -15,7 +15,7 @@
1515
"multi-root ready"
1616
],
1717
"engines": {
18-
"vscode": "^1.61.0",
18+
"vscode": "^1.63.0",
1919
"node": "^10.2.0"
2020
},
2121
"icon": "images/logo.png",
@@ -45,7 +45,6 @@
4545
"lint-fix": "tslint --project tsconfig.json -t verbose --fix"
4646
},
4747
"dependencies": {
48-
"@types/vscode": "^1.61.0",
4948
"axios": "^0.21.2",
5049
"axios-cookiejar-support": "^1.0.1",
5150
"node-cmd": "^4.0.0",
@@ -231,9 +230,27 @@
231230
},
232231
"additionalProperties": false
233232
},
234-
"intersystemsServerManager.useAuthenticationProvider": {
235-
"type": "boolean",
236-
"markdownDescription": "Use the 'intersystems-server-credentials' authentication provider for password management. Extensions that use the getServerSpec API will no longer receive a password in the response object. Instead they should call [`vscode.authentication`](https://code.visualstudio.com/api/references/vscode-api#authentication)`.getSession('intersystems-server-credentials', [serverName, userName])`. The `accessToken` property of the [`AuthenticationSession`](https://code.visualstudio.com/api/references/vscode-api#AuthenticationSession) promise returned is the password. If `serverName` or `userName` is omitted the user will be prompted.",
233+
"intersystemsServerManager.authentication.provider": {
234+
"type": "string",
235+
"description": "Authentication provider that Server Manager will use for accessing InterSystems servers and for fulfilling the API it published to other extensions.",
236+
"enum": ["none", "intersystems-server-credentials"],
237+
"enumDescriptions": [
238+
"Do not use VS Code's authentication model. Credential storage is handled natively by Server Manager, but it is unable to identify which extensions are accessing those credentials via Server Manager's API.",
239+
"Use Server Manager's embedded authentication provider."
240+
],
241+
"default": "none",
242+
"scope": "application"
243+
},
244+
"intersystemsServerManager.authentication.forgetPasswordOnSignout": {
245+
"type": "string",
246+
"description": "Whether to delete an account's stored password after signing out.",
247+
"enum": ["ask", "always", "never"],
248+
"enumDescriptions": [
249+
"Ask each time, after signout has completed.",
250+
"Always delete stored password after signing out.",
251+
"Retain stored password after signing out."
252+
],
253+
"default": "ask",
237254
"scope": "application"
238255
}
239256
}

src/api/getServerSpec.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as vscode from "vscode";
2+
import { AUTHENTICATION_PROVIDER } from "../authenticationProvider";
23
import { filePassword } from "../commands/managePasswords";
34
import { IServerSpec } from "../extension";
45
import { Keychain } from "../keychain";
@@ -35,13 +36,19 @@ export async function getServerSpec(
3536
return undefined;
3637
}
3738

39+
const useOurAuthProvider = (
40+
vscode.workspace
41+
.getConfiguration("intersystemsServerManager.authentication")
42+
.get<string>("provider", "") === AUTHENTICATION_PROVIDER
43+
);
44+
3845
server.name = name;
3946
server.description = server.description || "";
4047
server.webServer.scheme = server.webServer.scheme || "http";
4148
server.webServer.port = server.webServer.port || (server.webServer.scheme === "https" ? 443 : 80);
4249
server.webServer.pathPrefix = server.webServer.pathPrefix || "";
4350

44-
if (noCredentials) {
51+
if (noCredentials && !useOurAuthProvider) {
4552
server.username = undefined;
4653
server.password = undefined;
4754
} else {
@@ -67,8 +74,9 @@ export async function getServerSpec(
6774
}
6875
}
6976

70-
// Obtain password from session cache or keychain unless trying to connect anonymously
71-
if (server.username && !server.password) {
77+
// Obtain password from session cache or keychain
78+
// unless trying to connect anonymously or using the AuthenticationProvider
79+
if (server.username && !server.password && !useOurAuthProvider) {
7280
if (credentialCache[name] && credentialCache[name].username === server.username) {
7381
server.password = credentialCache[name].password;
7482
} else {
@@ -87,7 +95,7 @@ export async function getServerSpec(
8795
}
8896

8997
}
90-
if (server.username && !server.password) {
98+
if (server.username && !server.password && !useOurAuthProvider) {
9199
const doInputBox = async (): Promise<string | undefined> => {
92100
return await new Promise<string | undefined>((resolve, reject) => {
93101
const inputBox = vscode.window.createInputBox();
@@ -130,6 +138,12 @@ export async function getServerSpec(
130138
}
131139
});
132140
}
141+
142+
// When authentication provider is being used we should only have a password if it came from the deprecated
143+
// property of the settings object. Otherwise return it as undefined.
144+
if (useOurAuthProvider && !server.password) {
145+
server.password = undefined;
146+
}
133147
}
134148
return server;
135149
}

0 commit comments

Comments
 (0)