3367e1ad4e
* chore: upgrade Code to 1.73.0 This upgrades Code to 1.73.0 via the tag. * chore: refresh integration patch * chore: clean up base-path patch Only change here was they moved lib/vscode/src/vs/platform/extensionResourceLoader/common/extensionResourceLoader.ts so I had to update it. Code still looks the same though. * chore: refresh proposed-api patch * chore: update marketplace patch Simlar to a previous patch, the location of lib/vscode/src/vs/platform/extensionResourceLoader/common/extensionResourceLoader.ts changed so I had to update this patch. No changes to code itself. * chore: update hash in webview patch I believe there was only one to update but I may have missed one. * chore: refresh disable-builtin-ext-update.diff * chore: refresh update-check quilt couldn't apply it so I had to add one change in manually to lib/vscode/src/vs/server/node/serverEnvironmentService.ts * chore: refresh logout patch * chore: refresh proxy-uri patch * chore: refresh local-storage patch * chore: refresh sourcemaps patch * chore: refresh disable-downloads patch * chore: refresh telemetry patch * refactor: re-apply display-language patch This kinda got removed but I added it back in. * refactor: drop exec-argv patch This was accepted upstream! :tada * chore: refresh getting-started patch * fixup: add missing slash in marketplace * fixup: update notes proposed-api patch * fixup: support this.args.log as string Seems like upstream now uses a string[] for this. For now, support string. See2b50ab06b1
* Revert "fixup: support this.args.log as string" This reverts commit78c02a1f13
. * fixup!: add log to toCodeArgs This was changed upstream from `string` to `string[]` so now we convert to an array in `toCodeArgs`. See78c02a1f13
* fixup: update telemetry description
108 lines
4.6 KiB
Diff
108 lines
4.6 KiB
Diff
Add a logout command and menu item
|
|
|
|
This will only show if you have authentication enabled.
|
|
|
|
This has e2e tests but are currently disabled and need to be fixed.
|
|
|
|
Index: code-server/lib/vscode/src/vs/base/common/product.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/base/common/product.ts
|
|
+++ code-server/lib/vscode/src/vs/base/common/product.ts
|
|
@@ -34,6 +34,7 @@ export interface IProductConfiguration {
|
|
readonly codeServerVersion?: string
|
|
readonly rootEndpoint?: string
|
|
readonly updateEndpoint?: string
|
|
+ readonly logoutEndpoint?: string
|
|
|
|
readonly version: string;
|
|
readonly date?: string;
|
|
Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
|
|
+++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
|
|
@@ -13,6 +13,7 @@ import { IEnvironmentService, INativeEnv
|
|
export const serverOptions: OptionDescriptions<Required<ServerParsedArgs>> = {
|
|
/* ----- code-server ----- */
|
|
'disable-update-check': { type: 'boolean' },
|
|
+ 'auth': { type: 'string' },
|
|
|
|
/* ----- server setup ----- */
|
|
|
|
@@ -92,6 +93,7 @@ export const serverOptions: OptionDescri
|
|
export interface ServerParsedArgs {
|
|
/* ----- code-server ----- */
|
|
'disable-update-check'?: boolean;
|
|
+ 'auth'?: string
|
|
|
|
/* ----- server setup ----- */
|
|
|
|
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
@@ -313,6 +313,7 @@ export class WebClientServer {
|
|
codeServerVersion: this._productService.codeServerVersion,
|
|
rootEndpoint: base,
|
|
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
|
|
+ logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
|
|
embedderIdentifier: 'server-distro',
|
|
extensionsGallery: this._productService.extensionsGallery,
|
|
},
|
|
Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/workbench/browser/client.ts
|
|
+++ code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
|
@@ -1,11 +1,15 @@
|
|
import { Disposable } from 'vs/base/common/lifecycle';
|
|
import { localize } from 'vs/nls';
|
|
+import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
|
+import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
|
import { ILogService } from 'vs/platform/log/common/log';
|
|
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
|
import { IProductService } from 'vs/platform/product/common/productService';
|
|
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
|
|
|
|
export class CodeServerClient extends Disposable {
|
|
+ static LOGOUT_COMMAND_ID = 'code-server.logout';
|
|
+
|
|
constructor (
|
|
@ILogService private logService: ILogService,
|
|
@INotificationService private notificationService: INotificationService,
|
|
@@ -81,6 +85,10 @@ export class CodeServerClient extends Di
|
|
if (this.productService.updateEndpoint) {
|
|
this.checkUpdates(this.productService.updateEndpoint)
|
|
}
|
|
+
|
|
+ if (this.productService.logoutEndpoint) {
|
|
+ this.addLogoutCommand(this.productService.logoutEndpoint);
|
|
+ }
|
|
}
|
|
|
|
private checkUpdates(updateEndpoint: string) {
|
|
@@ -132,4 +140,25 @@ export class CodeServerClient extends Di
|
|
|
|
updateLoop();
|
|
}
|
|
+
|
|
+ private addLogoutCommand(logoutEndpoint: string) {
|
|
+ CommandsRegistry.registerCommand(CodeServerClient.LOGOUT_COMMAND_ID, () => {
|
|
+ const logoutUrl = new URL(logoutEndpoint, window.location.href);
|
|
+ // Cookies must be set with absolute paths and must use the same path to
|
|
+ // be unset (we set it on the root) so send the relative root and the
|
|
+ // current href so the backend can derive the absolute path to the root.
|
|
+ logoutUrl.searchParams.set('base', this.productService.rootEndpoint || ".");
|
|
+ logoutUrl.searchParams.set('href', window.location.href);
|
|
+ window.location.assign(logoutUrl);
|
|
+ });
|
|
+
|
|
+ for (const menuId of [MenuId.CommandPalette, MenuId.MenubarHomeMenu]) {
|
|
+ MenuRegistry.appendMenuItem(menuId, {
|
|
+ command: {
|
|
+ id: CodeServerClient.LOGOUT_COMMAND_ID,
|
|
+ title: localize('logout', "Sign out of {0}", 'code-server'),
|
|
+ },
|
|
+ });
|
|
+ }
|
|
+ }
|
|
}
|