Skip to content

Draft: Settings Sync user session ID header POC

Cindy Halim requested to merge ch_user-session-id-poc into main

Issue: [Investigation] Can we use User Session ID head... (#401 - closed)

What does this MR do and why?

This MR is a POC to explore:

  • Possibility of reading/writing the sync.user-session-id value in indexedDB
  • Possibility of passing an arbitrary header to Settings Sync requests

and is not meant to be merged.

How to set up and validate locally

Passing arbitrary header to Settings Sync requests:

  • This step requires changes in the VSCode fork side
  • Apply the following patch in the vscode submodule in gitlab-web-ide-vscode-fork project:
diff --git a/src/vs/platform/userDataSync/common/userDataSyncStoreService.ts b/src/vs/platform/userDataSync/common/userDataSyncStoreService.ts
index 32c4086b550..a8a6b836187 100644
--- a/src/vs/platform/userDataSync/common/userDataSyncStoreService.ts
+++ b/src/vs/platform/userDataSync/common/userDataSyncStoreService.ts
@@ -30,6 +30,7 @@ const CONFIGURATION_SYNC_STORE_KEY = 'configurationSync.store';
 const SYNC_PREVIOUS_STORE = 'sync.previous.store';
 const DONOT_MAKE_REQUESTS_UNTIL_KEY = 'sync.donot-make-requests-until';
 const USER_SESSION_ID_KEY = 'sync.user-session-id';
+const CONTEXT_ID_KEY = 'sync.context-id';
 const MACHINE_SESSION_ID_KEY = 'sync.machine-session-id';
 const REQUEST_SESSION_LIMIT = 100;
 const REQUEST_SESSION_INTERVAL = 1000 * 60 * 5; /* 5 minutes */
@@ -629,9 +630,14 @@ export class UserDataSyncStoreClient extends Disposable {
 		headers['X-Machine-Session-Id'] = machineSessionId;
 
 		const userSessionId = this.storageService.get(USER_SESSION_ID_KEY, StorageScope.APPLICATION);
+		const contextId = this.storageService.get(CONTEXT_ID_KEY, StorageScope.APPLICATION);
 		if (userSessionId !== undefined) {
 			headers['X-User-Session-Id'] = userSessionId;
 		}
+
+		if (contextId !== undefined) {
+			headers['X-Context-Id'] = contextId;
+		}
 	}
 
 }
  • Observe X-Context-Id header passed in making requests to Settings Sync API.
Edited by Cindy Halim

Merge request reports

Loading