Skip to content

Commit 2e8152c

Browse files
committed
Get authentication session info from workbench html in dev mode
1 parent 779436d commit 2e8152c

2 files changed

Lines changed: 39 additions & 12 deletions

File tree

src/vs/code/browser/workbench/workbench-dev.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
<!-- Workbench Configuration -->
1515
<meta id="vscode-workbench-web-configuration" data-settings="{{WORKBENCH_WEB_CONFIGURATION}}">
1616

17-
<!-- Builtin Extensions (running out of sources) -->
17+
<!-- running out of sources -->
18+
<!-- Builtin Extensions -->
1819
<meta id="vscode-workbench-builtin-extensions" data-settings="{{WORKBENCH_BUILTIN_EXTENSIONS}}">
20+
<!-- Authentication Session Info -->
21+
<meta id="vscode-workbench-authentication-session" data-settings="{{WORKBENCH_AUTHENTICATION_SESSION}}">
1922

2023
<!-- Workarounds/Hacks (remote user data uri) -->
2124
<meta id="vscode-remote-user-data-uri" data-settings="{{REMOTE_USER_DATA_URI}}">

src/vs/workbench/services/userData/browser/userDataInit.ts

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
1919
import { IRequestService } from 'vs/platform/request/common/request';
2020
import { CONFIGURATION_SYNC_STORE_KEY, IUserDataSyncStoreClient, SyncResource } from 'vs/platform/userDataSync/common/userDataSync';
2121
import { URI } from 'vs/base/common/uri';
22-
import { getCurrentAuthenticationSessionInfo } from 'vs/workbench/services/authentication/browser/authenticationService';
22+
import { AuthenticationSessionInfo, getCurrentAuthenticationSessionInfo } from 'vs/workbench/services/authentication/browser/authenticationService';
2323
import { getSyncAreaLabel } from 'vs/workbench/services/userDataSync/common/userDataSync';
2424
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions } from 'vs/workbench/common/contributions';
2525
import { Registry } from 'vs/platform/registry/common/platform';
@@ -80,18 +80,13 @@ export class UserDataInitializationService implements IUserDataInitializationSer
8080
return;
8181
}
8282

83-
if (!this.environmentService.options?.credentialsProvider) {
84-
this.logService.trace(`Skipping initializing user data as credentials provider is not provided`);
85-
return;
86-
}
83+
const authenticationSession = await this.getCurrentAuthenticationSessionInfo();
8784

88-
let authenticationSession;
89-
try {
90-
authenticationSession = await getCurrentAuthenticationSessionInfo(this.environmentService, this.productService);
91-
} catch (error) {
92-
this.logService.error(error);
93-
}
9485
if (!authenticationSession) {
86+
if (!this.environmentService.options?.credentialsProvider) {
87+
this.logService.trace(`Skipping initializing user data as credentials provider is not provided`);
88+
return;
89+
}
9590
this.logService.trace(`Skipping initializing user data as authentication session is not set`);
9691
return;
9792
}
@@ -105,6 +100,35 @@ export class UserDataInitializationService implements IUserDataInitializationSer
105100
return this._userDataSyncStoreClientPromise;
106101
}
107102

103+
private async getCurrentAuthenticationSessionInfo(): Promise<AuthenticationSessionInfo | undefined> {
104+
if (this.environmentService.options?.credentialsProvider) {
105+
try {
106+
const currentAuthenticationSessionInfo = await getCurrentAuthenticationSessionInfo(this.environmentService, this.productService);
107+
if (currentAuthenticationSessionInfo) {
108+
return currentAuthenticationSessionInfo;
109+
}
110+
} catch (error) {
111+
this.logService.error(error);
112+
return undefined;
113+
}
114+
}
115+
116+
if (!this.environmentService.isBuilt) {
117+
const authenticationSessionInfoElement = document.getElementById('vscode-workbench-authentication-session');
118+
const authenticationSessionInfoElementAttribute = authenticationSessionInfoElement ? authenticationSessionInfoElement.getAttribute('data-settings') : undefined;
119+
if (authenticationSessionInfoElementAttribute) {
120+
try {
121+
return JSON.parse(authenticationSessionInfoElementAttribute);
122+
} catch (error) {
123+
this.logService.error(error);
124+
return undefined;
125+
}
126+
}
127+
}
128+
129+
return undefined;
130+
}
131+
108132
async initializeRequiredResources(): Promise<void> {
109133
return this.initialize([SyncResource.Settings, SyncResource.GlobalState]);
110134
}

0 commit comments

Comments
 (0)