1
1
import * as vscode from 'vscode' ;
2
2
import { Uri } from 'vscode' ;
3
- import { extensionId } from '../extension' ;
3
+ import { extensionId , ServerSpec } from '../extension' ;
4
4
5
5
export async function getPortalUriWithCredentials ( name : string , scope ?: vscode . ConfigurationScope ) : Promise < Uri | undefined > {
6
6
@@ -10,22 +10,24 @@ export async function getPortalUriWithCredentials(name: string, scope?: vscode.C
10
10
if ( typeof spec !== 'undefined' ) {
11
11
const webServer = spec . webServer ;
12
12
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 ;
13
17
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*
18
22
const passwordEncoded = encodeURIComponent ( spec . password ) ;
19
23
queryString += `&CachePassword=${ passwordEncoded } &IRISPassword=${ passwordEncoded } ` ;
20
- }
21
- if ( spec ?. username ) {
22
24
const usernameEncoded = encodeURIComponent ( spec . username ) ;
23
25
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 ;
24
29
}
25
30
26
- // Add a dummy cache-buster and push the actual credentials offscreen
27
- queryString = '_=' + new Date ( ) . getTime ( ) . toString ( ) . padEnd ( 480 , ' ' ) + queryString ;
28
-
29
31
return vscode . Uri . parse ( `${ webServer . scheme } ://${ webServer . host } :${ webServer . port } ${ webServer . pathPrefix } /csp/sys/UtilHome.csp?${ queryString } ` , true ) ;
30
32
}
31
33
} )
0 commit comments