Skip to content

Commit a676e69

Browse files
Merge pull request #85 from gjsjohnmurray/fix-84
fix #84 Only supply credentials to Portal if password came as plaintxt from settings
2 parents 44a4e18 + 848b710 commit a676e69

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.0.3 (28-Apr-2021)
2+
* Only supply credentials to Portal if password came as plaintext from settings (#84).
3+
14
## 2.0.2 (22-Apr-2021)
25
* Support <kbd>Alt</kbd> / <kbd>Option</kbd> modifier on Edit and View buttons to add workspace folder for server-side web application files.
36
* Add newly defined server to the 'Recent' list.

src/api/getPortalUriWithCredentials.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as vscode from 'vscode';
22
import { Uri } from 'vscode';
3-
import { extensionId } from '../extension';
3+
import { extensionId, ServerSpec } from '../extension';
44

55
export async function getPortalUriWithCredentials(name: string, scope?: vscode.ConfigurationScope): Promise<Uri | undefined> {
66

@@ -10,22 +10,24 @@ export async function getPortalUriWithCredentials(name: string, scope?: vscode.C
1010
if (typeof spec !== 'undefined') {
1111
const webServer = spec.webServer;
1212
let queryString = '';
13+
14+
// We can only pass credentials in cleartext as a queryparam, so only do this if user was willing to store password in cleartext in settings.
15+
const settingsSpec: ServerSpec | undefined = vscode.workspace.getConfiguration('intersystems.servers', scope).get(name);
16+
spec.password = settingsSpec?.password;
1317

14-
// At this point we don't know if the target is IRIS or Cache, so add credentials in both formats.
15-
// Deliberately put password before username, otherwise it is visible in VS Code's confirmation dialog triggered target domain
16-
// hasn't been set as trusted. Likewise, deliberately put IRIS* after Cache*
17-
if (spec?.password) {
18+
if (spec?.password && spec?.username) {
19+
// At this point we don't know if the target is IRIS or Cache, so add credentials in both formats.
20+
// Deliberately put password before username, otherwise it is visible in VS Code's confirmation dialog triggered target domain
21+
// hasn't been set as trusted. Likewise, deliberately put IRIS* after Cache*
1822
const passwordEncoded = encodeURIComponent(spec.password);
1923
queryString += `&CachePassword=${passwordEncoded}&IRISPassword=${passwordEncoded}`;
20-
}
21-
if (spec?.username) {
2224
const usernameEncoded = encodeURIComponent(spec.username);
2325
queryString += `&CacheUsername=${usernameEncoded}&IRISUsername=${usernameEncoded}`;
26+
27+
// Add a cache-buster and push any credentials offscreen
28+
queryString = '_=' + new Date().getTime().toString().padEnd(480,' ') + queryString;
2429
}
2530

26-
// Add a dummy cache-buster and push the actual credentials offscreen
27-
queryString = '_=' + new Date().getTime().toString().padEnd(480,' ') + queryString;
28-
2931
return vscode.Uri.parse(`${webServer.scheme}://${webServer.host}:${webServer.port}${webServer.pathPrefix}/csp/sys/UtilHome.csp?${queryString}`, true);
3032
}
3133
})

0 commit comments

Comments
 (0)